/usr/share/doc/qdbm-doc/plapidoc/Depot.pm.html is in qdbm-doc 1.8.78-6build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | <?xml version="1.0" encoding="UTF-8"?>
<!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" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="contents" href="./" />
<link rev="made" href="mailto:mikio@fallabs.com" />
<title>Depot (QDBM for Perl)</title>
<style type="text/css">html { margin: 0em 0em; padding 0em 0em; background: #eeeeee none; }
body { background-color: #eeeeee; color: #111111; padding: 1.5em 2em; margin: 0em 0em;
border-left: double 3.0em #ddeedd; border-right: solid 1.0em #ddeedd;
font-style: normal; font-weight: normal; font-family: serif; }
h1 { margin-top: 0.8em; margin-bottom: 1.3em; font-weight: bold; font-family: sans-serif; }
h2 { margin-top: 1.8em; margin-bottom: 1.1em; font-weight: bold; font-family: sans-serif; }
h3 { margin-top: 1.8em; margin-bottom: 0.8em; font-weight: bold; font-family: sans-serif; }
p,ul,ol,dl { line-height: 140%; }
em { color: #111111; font-style: italic; font-weight: normal; font-family: serif; }
kbd { color: #111111; font-style: normal; font-weight: bold; font-family: monospace; }
a { color: #0022aa; text-decoration: none; }
a:hover { color: #0033ee; text-decoration: underline; }
a.head { color: #111111; text-decoration: none; }
.note { text-align: right; }
</style>
</head>
<body>
<div class="note">[<a href="index.html">Back</a>]</div>
<h1>API of Depot</h1>
<hr />
<dl>
<dt><kbd>use Depot;</kbd></dt>
<dd>
Module `Depot' should be loaded in application codes.
An instance of the class `Depot' is used as a database handle.
</dd>
</dl>
<dl>
<dt><kbd>$Depot::errmsg;</kbd></dt>
<dd>
Global Variable: The message of the last happened error.
</dd>
</dl>
<dl>
<dt><kbd>$depot = new Depot($name, $omode, $bnum);</kbd></dt>
<dd>
Constructor: Get the database handle.
`$name' specifies the name of a database file.
`$omode' specifies the connection mode: `Depot::OWRITER' as a writer, `Depot::OREADER' as a
reader. If the mode is `Depot::OWRITER', the following may be added by bitwise or:
`Depot::OCREAT', which means it creates a new database if not exist, `Depot::OTRUNC', which
means it creates a new database regardless if one exists. Both of `Depot::OREADER' and
`Depot::OWRITER' can be added to by bitwise or: `Depot::ONOLCK', which means it opens a
database file without file locking, or `Depot::OLCKNB', which means locking is performed
without blocking. `Depot::OCREAT' can be added to by bitwise or: `Depot::OSPARSE', which means
it creates a database file as a sparse file. If it is undef, `Depot::OREADER' is specified.
`$bnum' specifies the number of elements of the bucket array. If it is undef or not more
than 0, the default value is specified. The size of a bucket array is determined on creating,
and can not be changed except for by optimization of the database. Suggested size of a
bucket array is about from 0.5 to 4 times of the number of all records to store.
The return value is the database handle or undef if it is not successful.
While connecting as a writer, an exclusive lock is invoked to the database file.
While connecting as a reader, a shared lock is invoked to the database file. The thread
blocks until the lock is achieved. If `Depot::ONOLCK' is used, the application is responsible
for exclusion control.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->close();</kbd></dt>
<dd>
Method: Close the database handle.
If successful, the return value is true, else, it is false.
Because the region of a closed handle is released, it becomes impossible to use the handle.
Updating a database is assured to be written when the handle is closed. If a writer opens
a database but does not close it appropriately, the database will be broken.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->put($key, $val, $dmode);</kbd></dt>
<dd>
Method: Store a record.
`$key' specifies a key. If it is undef, this method has no effect.
`$val' specifies a value. If it is undef, this method has no effect.
`$dmode' specifies behavior when the key overlaps, by the following values: `Depot::DOVER',
which means the specified value overwrites the existing one, `Depot::DKEEP', which means the
existing value is kept, `Depot::DCAT', which means the specified value is concatenated at
the end of the existing value. If it is undef, `Depot::DOVER' is specified.
If successful, the return value is true, else, it is false.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->out($key);</kbd></dt>
<dd>
Method: Delete a record.
`$key' specifies a key. If it is undef, this method has no effect.
If successful, the return value is true, else, it is false. False is returned when no
record corresponds to the specified key.
</dd>
</dl>
<dl>
<dt><kbd>$str = $depot->get($key, $start, $max);</kbd></dt>
<dd>
Method: Retrieve a record.
`$key' specifies a key. If it is undef, this method has no effect.
`$start' specifies the offset address of the beginning of the region of the value to be read.
If it is negative or undef, the offset is specified as 0.
`$max' specifies the max size to be read. If it is negative or undef, the size to read is
unlimited.
If successful, the return value is a scalar of the value of the corresponding record, else, it
is undef. undef is returned when no record corresponds to the specified key or the size of
the value of the corresponding record is less than `$start'.
</dd>
</dl>
<dl>
<dt><kbd>$num = $depot->vsiz($key);</kbd></dt>
<dd>
Method: Get the size of the value of a record.
`$key' specifies a key. If it is undef, this method has no effect.
If successful, the return value is the size of the value of the corresponding record, else,
it is -1.
Because this method does not read the entity of a record, it is faster than `get'.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->iterinit();</kbd></dt>
<dd>
Method: Initialize the iterator of the database handle.
If successful, the return value is true, else, it is false.
The iterator is used in order to access the key of every record stored in a database.
</dd>
</dl>
<dl>
<dt><kbd>$str = $depot->iternext();</kbd></dt>
<dd>
Method: Get the next key of the iterator.
If successful, the return value is a scalar of the value of the next key, else, it is undef.
undef is returned when no record is to be get out of the iterator.
It is possible to access every record by iteration of calling this method. However, it is
not assured if updating the database is occurred while the iteration. Besides, the order of
this traversal access method is arbitrary, so it is not assured that the order of storing
matches the one of the traversal access.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->setalign($align);</kbd></dt>
<dd>
Method: Set alignment of the database handle.
`$align' specifies the basic size of alignment. If it is undef, alignment is cleared.
If successful, the return value is true, else, it is false.
If alignment is set to a database, the efficiency of overwriting values is improved.
The size of alignment is suggested to be average size of the values of the records to be
stored. If alignment is positive, padding whose size is multiple number of the alignment
is placed. If alignment is negative, as `vsiz' is the size of a value, the size of padding
is calculated with `(vsiz / pow(2, abs(align) - 1))'. Because alignment setting is not
saved in a database, you should specify alignment every opening a database.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->setfbpsiz($size);</kbd></dt>
<dd>
Method: Set the size of the free block pool.
`$size' specifies the size of the free block pool. If it is undef, the free block pool is not
used.
If successful, the return value is true, else, it is false.
The default size of the free block pool is 16. If the size is greater, the space efficiency of
overwriting values is improved with the time efficiency sacrificed.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->sync();</kbd></dt>
<dd>
Method: Synchronize updating contents with the file and the device.
If successful, the return value is true, else, it is false.
This method is useful when another process uses the connected database file.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->optimize($bnum);</kbd></dt>
<dd>
Method: Optimize the database.
`$bnum' specifies the number of the elements of the bucket array. If it is undef or not more
than 0, the default value is specified.
If successful, the return value is true, else, it is false.
In an alternating succession of deleting and storing with overwrite or concatenate,
dispensable regions accumulate. This method is useful to do away with them.
</dd>
</dl>
<dl>
<dt><kbd>$num = $depot->fsiz();</kbd></dt>
<dd>
Method: Get the size of the database file.
If successful, the return value is the size of the database file, else, it is -1.
</dd>
</dl>
<dl>
<dt><kbd>$num = $depot->bnum();</kbd></dt>
<dd>
Method: Get the number of the elements of the bucket array.
If successful, the return value is the number of the elements of the bucket array, else, it
is -1.
</dd>
</dl>
<dl>
<dt><kbd>$num = $depot->rnum();</kbd></dt>
<dd>
Method: Get the number of the records stored in the database.
If successful, the return value is the number of the records stored in the database, else,
it is -1.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->writable();</kbd></dt>
<dd>
Method: Check whether the database handle is a writer or not.
The return value is true if the handle is a writer, false if not.
</dd>
</dl>
<dl>
<dt><kbd>$bool = $depot->fatalerror();</kbd></dt>
<dd>
Method: Check whether the database has a fatal error or not.
The return value is true if the database has a fatal error, false if not.
</dd>
</dl>
<dl>
<dt><em>Called automatically by the garbage collector.</em></dt>
<dd>
Destructor: DESTROY: Release the resources.
If the database handle is not closed yet, it is closed.
</dd>
</dl>
<dl>
<dt><kbd>$depot = tie(%hash, "Depot", $name, $omode, $bnum);</kbd></dt>
<dd>
Tying Function: TIEHASH: Get the database handle.
</dd>
</dl>
<dl>
<dt><kbd>$bool = ($hash{$key} = $val);</kbd></dt>
<dd>
Tying Function: STORE: Store a record with overwrite.
</dd>
</dl>
<dl>
<dt><kbd>$bool = delete($hash{$key});</kbd></dt>
<dd>
Tying Function: DELETE: Delete a record.
</dd>
</dl>
<dl>
<dt><kbd>$bool = (%hash = ());</kbd></dt>
<dd>
Tying Function: CLEAR: Delete all records.
</dd>
</dl>
<dl>
<dt><kbd>$str = $hash{$key};</kbd></dt>
<dd>
Tying Function: FETCH: Retrieve whole value of a record.
</dd>
</dl>
<dl>
<dt><kbd>$bool = exists($hash{$val});</kbd></dt>
<dd>
Tying Function: EXISTS: Check whether a record exists or not.
</dd>
</dl>
<dl>
<dt><em>Called automatically by keys(), each(), and so on.</em></dt>
<dd>
Tying Function: FIRSTKEY: Get the first key.
</dd>
</dl>
<dl>
<dt><em>Called automatically by keys(), each(), and so on.</em></dt>
<dd>
Tying Function: NEXTKEY: Get the next key.
</dd>
</dl>
<dl>
<dt><kbd>$func = $depot->filter_store_key(\&nf);</kbd></dt>
<dd>
Method: set a filter invoked when writing a key.
`\&nf' specifies the reference of a filter function proofing `$_'. If it is undef, the
current filter function is cleared.
The return value is the old filter function.
</dd>
</dl>
<dl>
<dt><kbd>$func = $depot->filter_store_value(\&nf);</kbd></dt>
<dd>
Method: set a filter invoked when writing a value.
`\&nf' specifies the reference of a filter function proofing `$_'. If it is undef, the
current filter function is cleared.
The return value is the old filter function.
</dd>
</dl>
<dl>
<dt><kbd>$func = $depot->filter_fetch_key(\&nf);</kbd></dt>
<dd>
Method: set a filter invoked when reading a key.
`\&nf' specifies the reference of a filter function proofing `$_'. If it is undef, the
current filter function is cleared.
The return value is the old filter function.
</dd>
</dl>
<dl>
<dt><kbd>$func = $depot->filter_fetch_value(\&nf);</kbd></dt>
<dd>
Method: set a filter invoked when reading a value.
`\&nf' specifies the reference of a filter function proofing `$_'. If it is undef, the
current filter function is cleared.
The return value is the old filter function.
</dd>
</dl>
<hr />
<div class="note">Generated by mypldoc, 2010/08/05.</div>
</body>
</html>
|