Commit a7f628e3 authored by -urso-'s avatar -urso-

Initial import

darcs-hash:71440eea85d9ae542c351c1c5b7cbf44e0d157c5
parents
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>BDB</title>
<link rel="stylesheet" type="text/css" href="../style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
</head>
<body>
<div class="header">
<h1>BDB</h1>
<h2>Berkeley DB CFFI bindings</h2>
</div>
<h3>Example Usage (Secondary Databases)</h3>
<p>WARNING: this 'native' kind of using secondary databases with Berkeley DB is very C-centric, thus for
every callback function you create, cffi will create one and those functions and associated data (when using closures for example)
will not being garbage collected, even if databases were closed. Thus if you use alot of secondary databases, there will be
a lot of garbage being produced over time...
</p>
<pre>
CL-USER&gt; (asdf:oos 'asdf:load-op :bdb-playground)
NIL
CL-USER&gt; (in-package :bdb-playground)
#&lt;PACKAGE "BDB-PLAYGROUND"&gt;
BDB-PLAYGROUND&gt; (defun first-callback (sdb key data)
(values t (first data)))
FIRST-CALLBACK
BDB-PLAYGROUND&gt; (setq *callback* (create-assoc-callback #'first-callback))
#.(SB-SYS:INT-SAP #X050006F8)
BDB-PLAYGROUND&gt; (setq *db* (db-open "test.db" :create t))
#.(SB-SYS:INT-SAP #X08197120)
BDB-PLAYGROUND&gt; (setq *sdb* (db-open "sec.db" :create t :dup-sort t))
#.(SB-SYS:INT-SAP #X081995A0)
BDB-PLAYGROUND&gt; (db-associate *db* *sdb* *callback*)
T
BDB-PLAYGROUND&gt; (db-put *db* 1 '(max mustermann))
T
BDB-PLAYGROUND&gt; (db-put *db* 2 '(kater karlo))
T
BDB-PLAYGROUND&gt; (db-put *db* 3 '(micky maus))
T
BDB-PLAYGROUND&gt; (setq *cursor* (db-cursor *db*))
#.(SB-SYS:INT-SAP #X0819CF28)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
1
(MAX MUSTERMANN)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
2
(KATER KARLO)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
3
(MICKY MAUS)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-PLAYGROUND&gt; (db-cursor-close *cursor*)
T
BDB-PLAYGROUND&gt; (setq *cursor* (db-cursor *sdb*))
#.(SB-SYS:INT-SAP #X0819BB28)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
KATER
(KATER KARLO)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
MICKY
(MICKY MAUS)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
MAX
(MAX MUSTERMANN)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-PLAYGROUND&gt; ;;bye bye
</pre>
<div class="footer">
<a href="mailto:-urso-@web.de">Email</a>
</div>
<div class="check">
<a href="http://validator.w3.org/check/referer"> Valid XHTML 1.0 Strict</a>
</div>
</body>
</html>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>BDB</title>
<link rel="stylesheet" type="text/css" href="../style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
</head>
<body>
<div class="header">
<h1>BDB</h1>
<h2>Berkeley DB CFFI bindings</h2>
</div>
<h3>Example Usage</h3>
<pre>
CL-USER&gt; (asdf:oos 'asdf:load-op :bdb-playground)
NIL
CL-USER&gt; (in-package :bdb-playground)
#&lt;PACKAGE "BDB-PLAYGROUND"&gt;
BDB-PLAYGROUND&gt; (setq *db* (db-open "test-db.db" :create t :exclusive t))
#.(SB-SYS:INT-SAP #X08197120)
BDB-PLAYGROUND&gt; (db-put *db* "key1" "data1")
T
BDB-PLAYGROUND&gt; (db-put *db* "key2" "data2")
T
BDB-PLAYGROUND&gt; (db-put *db* "key3" "data3")
T
BDB-PLAYGROUND&gt; (db-put *db* "key4" "data4")
T
BDB-PLAYGROUND&gt; (db-get *db* "key2")
"data2"
BDB-PLAYGROUND&gt; (db-get *db* "key4")
"data4"
BDB-PLAYGROUND&gt; (db-get *db* "key1012")
NIL
BDB-PLAYGROUND&gt; (db-get *db* "key1012" :not-found t)
; Evaluation aborted | comment: used debugger to abort, cause of exception...
BDB-PLAYGROUND&gt; (db-get *db* "key1012" :not-found (lambda () "uhoh"))
"uhoh"
BDB-PLAYGROUND&gt; (setq *cursor* (db-cursor *db*))
#.(SB-SYS:INT-SAP #X08198338)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key1"
"data1"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key2"
"data2"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key3"
"data3"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key4"
"data4"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :first t)
"key1"
"data1"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :key "key3" :set t)
"key3"
"data3"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key4"
"data4"
BDB-PLAYGROUND&gt; (db-cursor-count *cursor*) ;;number of duplicates
1
BDB-PLAYGROUND&gt; (db-cursor-close *cursor*)
T
BDB-PLAYGROUND&gt; (db-close *db*)
T
BDB-PLAYGROUND&gt; (setq *db* (db-open "test-db.db"))
#.(SB-SYS:INT-SAP #X08197120)
BDB-PLAYGROUND&gt; (setq *cursor* (db-cursor *db*))
#.(SB-SYS:INT-SAP #X081982F0)
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key1"
"data1"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key2"
"data2"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key3"
"data3"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key4"
"data4"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-PLAYGROUND&gt; (db-cursor-close *cursor*)
T
BDB-PLAYGROUND&gt; (db-close *db*)
T
BDB-PLAYGROUND&gt; ;;thats it...
; No value
BDB-PLAYGROUND&gt;
</pre>
<div class="footer">
<a href="mailto:-urso-@web.de">Email</a>
</div>
<div class="check">
<a href="http://validator.w3.org/check/referer"> Valid XHTML 1.0 Strict</a>
</div>
</body>
</html>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>BDB</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
</head>
<body>
<div class="header">
<h1>BDB</h1>
<h2>Berkeley DB CFFI bindings</h2>
</div>
<h3>Introduction</h3>
<p>
BDB is a small (well it was supposed to be a small...) package offering CFFI-Bindings to Berkeley DB.
The package is supposed to be as lispy , but as near to the C library as possible.
<br/>
You can find more informations about Berkeley db on <a href="http://www.sleepycat.com">http://www.sleepycat.com</a>.
Since the package is supposed to be as near as possible to the C library, you should read the "Getting starting..." guides,
using the "bdb-playgound" package, to get a feeling on how to use Berkeley DB and/or bdb.
</p>
<h3>State</h3>
<table border="1">
<tr><td>Lisp Platforms:
</td>
<td>testest with SBCL 0.9.11 and 0.9.12 only (yet), but should work on other implementations
with CFFI support, too
</td>
</tr>
<tr><td>Berkeley DB Version: </td>
<td>4.3</td>
</tr>
<tr><td>Package version: </td>
<td>I don't use any versioning (at the moment), so get used to the darcs repo.
But at the moment consider this a initial pre pre pre pre pre alpha version...
</td>
</tr>
<tr><td>License</td>
<td> <a href="http://opensource.franz.com">LLGPL</a> </td>
</tr>
</table>
<h3>Packages</h3>
<p>
Sure, the package was supposed too be small, but unfortunatelly it grew and grew, thus it consists/needs several packages:
</p>
<table border="1">
<tr> <th>Package</th><th>Description</th><th>Dependencies</th><th>Documentation</th> </tr>
<tr>
<td>mycl-util</td>
<td>My private utility package, which i use/develop in, since I'm lerning CL (I'm just very new to CL...) </td>
<td>None</td>
<td> <a href="qbook/mycl-util/index.html">documentation</a> </td>
</tr>
<tr>
<td>cffi-util</td>
<td>Was once part of bdb package, but outsourced as new package. </td>
<td>
<a href="http://common-lisp.net/project/cffi">CFFI</a><br/>
<a href="http://common-lisp.net/project/bdb">mycl-util</a><br/>
<a href="http://cliki.net/trivial-gray-streams">trivial-gray-streams</a><br/>
<a href="http://weitz.de/flexi-streams">flexi-streams</a>
</td>
<td><a href="qbook/cffi-util/index.html">documentation</a> </td>
</tr>
<tr>
<td>bdb</td>
<td>These are the CFFI bindings to Berkley DB </td>
<td>
<a href="http://common-lisp.net/project/cffi">CFFI</a><br/>
<a href="http://common-lisp.net/project/bdb">mycl-util</a><br/>
<a href="http://common-lisp.net/project/bdb">cffi-util</a><br/>
</td>
<td><a href="qbook/bdb/index.html">documentation</a> </td>
</tr>
<tr>
<td>bdb-playground</td>
<td>
If you want to play/test the library, bdb-playground is a nice starting point,
since it uses cl-store for writing and reading the data into/from the database and
you can immediately start unsing the library.
</td>
<td>
<a href="http://common-lisp.net/project/bdb">bdb</a><br/>
<a href="http://common-lisp.net/project/cl-store">cl-store</a><br/>
</td>
<td><a href="qbook/bdb-playground/index.html">documentation</a> </td>
</tr>
</table>
<h3>Download/darcs</h3>
<table border="1">
<tr><th>project</th><th>darcs repo</th></tr>
<tr>
<td>mycl-util </td>
<td>darcs get http://common-lisp.net/project/bdb/darcs/mycl-util </td>
</tr>
<tr>
<td>cffi-util </td>
<td>darcs get http://common-lisp.net/project/bdb/darcs/cffi-util </td>
</tr>
<tr>
<td>bdb </td>
<td>darcs get http://common-lisp.net/project/bdb/darcs/bdb </td>
</tr>
<tr>
<td>bdb-playground </td>
<td>darcs get http://common-lisp.net/project/bdb/darcs/bdb-playground </td>
</tr>
</table>
<h3>Installation</h3>
<p>
bdb package:<br/>
The bdb package comes with a wrapper library for libdb, which must be compiled
and made available. You can find more infos on how to install in the
README file.<br/><br/>
All packages: <br/>
Just make all asdf files available and load via asdf.
</p>
<h3>Example Usage</h3>
<ol>
<li><a href="examples/simple.html">Simple db Example</a></li>
<li><a href="examples/secondary.html">Secondary Databases</a></li>
</ol>
<h3>Mailing Lists</h3>
<ul>
<li>
<a href="http://www.common-lisp.net/mailman/listinfo/bdb-devel">bdb-devel</a><br/>for developers
</li>
<li>
<a href="http://www.common-lisp.net/mailman/listinfo/bdb-announce">bdb-announce</a><br/>for announcements.
</li>
</ul>
<div class="footer">
<a href="mailto:-urso-@web.de">Email</a>
</div>
<div class="check">
<a href="http://validator.w3.org/check/referer"> Valid XHTML 1.0 Strict</a>
</div>
</body>
</html>
<html
><head
><title
>Berkley DB Playground</title
><link href="style.css" rel="stylesheet"
/><link title="Print" href="print.css" rel="alternate stylesheet"
/></head
><body
><div class="qbook"
><h1 class="title"
>Berkley DB Playground</h1
><div class="contents"
><h2
><a name="ASDF_0020info"
>ASDF info</a
>&nbsp;</h2
><div class="nav-links"
><span class="dead-nav-link"
>prev</span
> | <span class="dead-nav-link"
>up</span
> | <a href="Package_0020description.html"
>next</a
> | <a href="index.html"
>toc</a
></div
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>eval-when <span class="paren">(</span>:compile-toplevel :load-toplevel :execute<span class="paren">)</span></span><span class"body">
<span class="paren">(</span>unless <span class="paren">(</span>find-package :bdb-p-system<span class="paren">)</span>
<span class="paren">(</span>defpackage :bdb-p-system
<span class="paren">(</span>:use :common-lisp :asdf<span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span></span></pre
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>in-package :bdb-p-system<span class="paren">)</span></span><span class"body"></span></pre
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>defsystem :bdb-playground</span><span class"body">
:description &quot;Berkley DB Playground&quot;
:author &quot;&quot;
:version &quot;0.0,0&quot;
:components
<span class="paren">(</span><span class="paren">(</span>:module :src
:components <span class="paren">(</span><span class="paren">(</span>:file &quot;packages&quot;<span class="paren">)</span>
<span class="paren">(</span>:file &quot;util&quot;
:depends-on <span class="paren">(</span>&quot;packages&quot;<span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span>
:depends-on <span class="paren">(</span>:cl-store :bdb<span class="paren">)</span><span class="paren">)</span></span></pre
>
</div
></div
></body
></html
>
\ No newline at end of file
<html
><head
><title
>Berkley DB Playground</title
><link href="style.css" rel="stylesheet"
/><link title="Print" href="print.css" rel="alternate stylesheet"
/></head
><body
><div class="qbook"
><h1 class="title"
>Berkley DB Playground</h1
><div class="contents"
><h2
><a name="Database_0020functions"
>Database functions</a
>&nbsp;</h2
><div class="nav-links"
><a class="nav-link" href="Package_0020description.html"
>prev</a
> | <span class="dead-nav-link"
>up</span
> | <span class="nav-link"
>next</span
> | <a href="index.html"
>toc</a
></div
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>setf <span class="paren">(</span>symbol-function 'buf-writer<span class="paren">)</span></span><span class"body">
<span class="paren">(</span>make-cbuffer-writer #'cl-store:store<span class="paren">)</span><span class="paren">)</span></span></pre
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>setf <span class="paren">(</span>symbol-function 'buf-reader<span class="paren">)</span></span><span class"body">
<span class="paren">(</span>make-cbuffer-reader #'cl-store:restore<span class="paren">)</span><span class="paren">)</span></span></pre
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>setf <span class="paren">(</span>symbol-function 'db-put<span class="paren">)</span></span><span class"body">
<span class="paren">(</span>build-put-function #'buf-writer<span class="paren">)</span><span class="paren">)</span></span></pre
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>setf <span class="paren">(</span>symbol-function 'db-get<span class="paren">)</span></span><span class"body">
<span class="paren">(</span>build-get-function #'buf-writer #'buf-reader<span class="paren">)</span><span class="paren">)</span></span></pre
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>setf <span class="paren">(</span>symbol-function 'db-del<span class="paren">)</span></span><span class"body">
<span class="paren">(</span>build-del-function #'buf-writer<span class="paren">)</span><span class="paren">)</span></span></pre