ruby_odeum 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data/COPYING +504 -0
  2. data/LICENSE +504 -0
  3. data/README +50 -0
  4. data/bin/odeum_mgr +106 -0
  5. data/doc/rdoc/classes/Odeum.html +235 -0
  6. data/doc/rdoc/classes/Odeum.src/M000010.html +25 -0
  7. data/doc/rdoc/classes/Odeum.src/M000011.html +22 -0
  8. data/doc/rdoc/classes/Odeum.src/M000012.html +27 -0
  9. data/doc/rdoc/classes/Odeum.src/M000013.html +27 -0
  10. data/doc/rdoc/classes/Odeum.src/M000014.html +28 -0
  11. data/doc/rdoc/classes/Odeum/Document.html +382 -0
  12. data/doc/rdoc/classes/Odeum/Document.src/M000040.html +25 -0
  13. data/doc/rdoc/classes/Odeum/Document.src/M000041.html +22 -0
  14. data/doc/rdoc/classes/Odeum/Document.src/M000042.html +23 -0
  15. data/doc/rdoc/classes/Odeum/Document.src/M000043.html +23 -0
  16. data/doc/rdoc/classes/Odeum/Document.src/M000044.html +24 -0
  17. data/doc/rdoc/classes/Odeum/Document.src/M000045.html +32 -0
  18. data/doc/rdoc/classes/Odeum/Document.src/M000046.html +22 -0
  19. data/doc/rdoc/classes/Odeum/Document.src/M000047.html +22 -0
  20. data/doc/rdoc/classes/Odeum/Document.src/M000048.html +22 -0
  21. data/doc/rdoc/classes/Odeum/Document.src/M000049.html +22 -0
  22. data/doc/rdoc/classes/Odeum/Document.src/M000050.html +24 -0
  23. data/doc/rdoc/classes/Odeum/Document.src/M000051.html +27 -0
  24. data/doc/rdoc/classes/Odeum/Index.html +662 -0
  25. data/doc/rdoc/classes/Odeum/Index.src/M000015.html +46 -0
  26. data/doc/rdoc/classes/Odeum/Index.src/M000016.html +33 -0
  27. data/doc/rdoc/classes/Odeum/Index.src/M000017.html +35 -0
  28. data/doc/rdoc/classes/Odeum/Index.src/M000018.html +23 -0
  29. data/doc/rdoc/classes/Odeum/Index.src/M000019.html +22 -0
  30. data/doc/rdoc/classes/Odeum/Index.src/M000020.html +22 -0
  31. data/doc/rdoc/classes/Odeum/Index.src/M000021.html +22 -0
  32. data/doc/rdoc/classes/Odeum/Index.src/M000022.html +22 -0
  33. data/doc/rdoc/classes/Odeum/Index.src/M000023.html +22 -0
  34. data/doc/rdoc/classes/Odeum/Index.src/M000024.html +29 -0
  35. data/doc/rdoc/classes/Odeum/Index.src/M000025.html +23 -0
  36. data/doc/rdoc/classes/Odeum/Index.src/M000026.html +24 -0
  37. data/doc/rdoc/classes/Odeum/Index.src/M000027.html +23 -0
  38. data/doc/rdoc/classes/Odeum/Index.src/M000028.html +26 -0
  39. data/doc/rdoc/classes/Odeum/Index.src/M000029.html +24 -0
  40. data/doc/rdoc/classes/Odeum/Index.src/M000030.html +20 -0
  41. data/doc/rdoc/classes/Odeum/Index.src/M000031.html +22 -0
  42. data/doc/rdoc/classes/Odeum/Index.src/M000032.html +22 -0
  43. data/doc/rdoc/classes/Odeum/Index.src/M000033.html +22 -0
  44. data/doc/rdoc/classes/Odeum/Index.src/M000034.html +22 -0
  45. data/doc/rdoc/classes/Odeum/Index.src/M000035.html +20 -0
  46. data/doc/rdoc/classes/Odeum/Index.src/M000036.html +20 -0
  47. data/doc/rdoc/classes/Odeum/Index.src/M000037.html +22 -0
  48. data/doc/rdoc/classes/Odeum/Index.src/M000038.html +22 -0
  49. data/doc/rdoc/classes/Odeum/Index.src/M000039.html +22 -0
  50. data/doc/rdoc/classes/OdeumTest.html +257 -0
  51. data/doc/rdoc/classes/OdeumTest.src/M000001.html +18 -0
  52. data/doc/rdoc/classes/OdeumTest.src/M000002.html +19 -0
  53. data/doc/rdoc/classes/OdeumTest.src/M000003.html +27 -0
  54. data/doc/rdoc/classes/OdeumTest.src/M000004.html +25 -0
  55. data/doc/rdoc/classes/OdeumTest.src/M000005.html +44 -0
  56. data/doc/rdoc/classes/OdeumTest.src/M000006.html +20 -0
  57. data/doc/rdoc/classes/OdeumTest.src/M000007.html +39 -0
  58. data/doc/rdoc/classes/OdeumTest.src/M000008.html +59 -0
  59. data/doc/rdoc/classes/OdeumTest.src/M000009.html +41 -0
  60. data/doc/rdoc/created.rid +1 -0
  61. data/doc/rdoc/files/COPYING.html +756 -0
  62. data/doc/rdoc/files/LICENSE.html +756 -0
  63. data/doc/rdoc/files/README.html +175 -0
  64. data/doc/rdoc/files/ext/odeum_index/odeum_index_c.html +101 -0
  65. data/doc/rdoc/files/test/test_odeum_rb.html +109 -0
  66. data/doc/rdoc/fr_class_index.html +30 -0
  67. data/doc/rdoc/fr_file_index.html +31 -0
  68. data/doc/rdoc/fr_method_index.html +77 -0
  69. data/doc/rdoc/index.html +24 -0
  70. data/doc/rdoc/rdoc-style.css +208 -0
  71. data/ext/odeum_index/cabin.c +2735 -0
  72. data/ext/odeum_index/cabin.h +1040 -0
  73. data/ext/odeum_index/curia.c +1114 -0
  74. data/ext/odeum_index/curia.h +430 -0
  75. data/ext/odeum_index/depot.c +1910 -0
  76. data/ext/odeum_index/depot.h +439 -0
  77. data/ext/odeum_index/extconf.rb +10 -0
  78. data/ext/odeum_index/myconf.c +668 -0
  79. data/ext/odeum_index/myconf.h +523 -0
  80. data/ext/odeum_index/odeum.c +1743 -0
  81. data/ext/odeum_index/odeum.h +541 -0
  82. data/ext/odeum_index/odeum_index.c +991 -0
  83. data/ext/odeum_index/villa.c +1923 -0
  84. data/ext/odeum_index/villa.h +470 -0
  85. data/ext/odeum_index/vista.c +159 -0
  86. data/ext/odeum_index/vista.h +111 -0
  87. data/test/test_odeum.rb +174 -0
  88. metadata +138 -0
@@ -0,0 +1,470 @@
1
+ /*************************************************************************************************
2
+ * The advanced API of QDBM
3
+ * Copyright (C) 2000-2005 Mikio Hirabayashi
4
+ * This file is part of QDBM, Quick Database Manager.
5
+ * QDBM is free software; you can redistribute it and/or modify it under the terms of the GNU
6
+ * Lesser General Public License as published by the Free Software Foundation; either version
7
+ * 2.1 of the License or any later version. QDBM is distributed in the hope that it will be
8
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10
+ * details.
11
+ * You should have received a copy of the GNU Lesser General Public License along with QDBM; if
12
+ * not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
13
+ * 02111-1307 USA.
14
+ *************************************************************************************************/
15
+
16
+
17
+ #ifndef _VILLA_H /* duplication check */
18
+ #define _VILLA_H
19
+
20
+ #if defined(__cplusplus) /* export for C++ */
21
+ extern "C" {
22
+ #endif
23
+
24
+
25
+ #include <depot.h>
26
+ #include <cabin.h>
27
+ #include <stdlib.h>
28
+
29
+
30
+
31
+ /*************************************************************************************************
32
+ * API
33
+ *************************************************************************************************/
34
+
35
+
36
+ typedef struct { /* type of structure for a record */
37
+ CBDATUM *key; /* datum of the key */
38
+ CBDATUM *first; /* datum of the first value */
39
+ CBLIST *rest; /* list of the rest values */
40
+ } VLREC;
41
+
42
+ typedef struct { /* type of structure for index of a page */
43
+ int pid; /* ID number of the referring page */
44
+ CBDATUM *key; /* threshold key of the page */
45
+ } VLIDX;
46
+
47
+ typedef struct { /* type of structure for a leaf page */
48
+ int id; /* ID number of the leaf */
49
+ int dirty; /* whether to be written back or not */
50
+ CBLIST *recs; /* list of records */
51
+ int prev; /* ID number of the previous leaf */
52
+ int next; /* ID number of the next leaf */
53
+ } VLLEAF;
54
+
55
+ typedef struct { /* type of structure for a node page */
56
+ int id; /* ID number of the node */
57
+ int dirty; /* whether to be written back or not */
58
+ int heir; /* ID of the child before the first index */
59
+ CBLIST *idxs; /* list of indexes */
60
+ } VLNODE;
61
+
62
+ /* type of the pointer to a comparing function.
63
+ `aptr' specifies the pointer to the region of one key.
64
+ `asiz' specifies the size of the region of one key.
65
+ `bptr' specifies the pointer to the region of the other key.
66
+ `bsiz' specifies the size of the region of the other key.
67
+ The return value is positive if the former is big, negative if the latter is big, 0 if both
68
+ are equivalent. */
69
+ typedef int (*VLCFUNC)(const char *aptr, int asiz, const char *bptr, int bsiz);
70
+ extern VLCFUNC VL_CMPLEX; /* lexical comparing function */
71
+ extern VLCFUNC VL_CMPINT; /* native integer comparing function */
72
+ extern VLCFUNC VL_CMPNUM; /* big endian number comparing function */
73
+ extern VLCFUNC VL_CMPDEC; /* decimal string comparing function */
74
+
75
+ typedef struct { /* type of structure for a database handle */
76
+ DEPOT *depot; /* internal database handle */
77
+ VLCFUNC cmp; /* pointer to the comparing function */
78
+ int wmode; /* whether writable or not */
79
+ int zmode; /* whether compress leaves or not */
80
+ int root; /* ID number of the root page */
81
+ int last; /* ID number of the last leaf */
82
+ int lnum; /* number of leaves */
83
+ int nnum; /* number of nodes */
84
+ int rnum; /* number of records */
85
+ CBMAP *leafc; /* cache for leaves */
86
+ CBMAP *nodec; /* cache for nodes */
87
+ int curleaf; /* ID number of the leaf where the cursor is */
88
+ int curknum; /* index of the key where the cursor is */
89
+ int curvnum; /* index of the value where the cursor is */
90
+ int leafrecmax; /* max number of records in a leaf */
91
+ int nodeidxmax; /* max number of indexes in a node */
92
+ int leafcnum; /* max number of caching leaves */
93
+ int nodecnum; /* max number of caching nodes */
94
+ int avglsiz; /* average size of each leave */
95
+ int avgnsiz; /* average size of each node */
96
+ int tran; /* whether in the transaction or not */
97
+ int rbroot; /* root for rollback */
98
+ int rblast; /* last for rollback */
99
+ int rblnum; /* lnum for rollback */
100
+ int rbnnum; /* nnum for rollback */
101
+ int rbrnum; /* rnum for rollback */
102
+ } VILLA;
103
+
104
+ enum { /* enumeration for open modes */
105
+ VL_OREADER = 1 << 0, /* open as a reader */
106
+ VL_OWRITER = 1 << 1, /* open as a writer */
107
+ VL_OCREAT = 1 << 2, /* a writer creating */
108
+ VL_OTRUNC = 1 << 3, /* a writer truncating */
109
+ VL_ONOLCK = 1 << 4, /* open without locking */
110
+ VL_OZCOMP = 1 << 5 /* compress leaves */
111
+ };
112
+
113
+ enum { /* enumeration for write modes */
114
+ VL_DOVER, /* overwrite an existing value */
115
+ VL_DKEEP, /* keep an existing value */
116
+ VL_DDUP /* allow duplication of records */
117
+ };
118
+
119
+ enum { /* enumeration for jump modes */
120
+ VL_JFORWARD, /* step forward */
121
+ VL_JBACKWARD /* step backward */
122
+ };
123
+
124
+
125
+ /* Get a database handle.
126
+ `name' specifies the name of a database file.
127
+ `omode' specifies the connection mode: `VL_OWRITER' as a writer, `VL_OREADER' as a reader.
128
+ If the mode is `VL_OWRITER', the following may be added by bitwise or: `VL_OCREAT', which
129
+ means it creates a new database if not exist, `VL_OTRUNC', which means it creates a new
130
+ database regardless if one exists, `VL_OZCOMP', which means leaves in the database are
131
+ compressed. Both of `VL_OREADER' and `VL_OWRITER' can be added to by bitwise or:
132
+ `VL_ONOLCK', which means it opens a database file without file locking.
133
+ `cmp' specifies a comparing function: `VL_CMPLEX' comparing keys in lexical order,
134
+ `VL_CMPINT' comparing keys as objects of `int' in native byte order, `VL_CMPNUM' comparing
135
+ keys as numbers of big endian, `VL_CMPDEC' comparing keys as decimal strings. Any function
136
+ based on the declaration of the type `VLCFUNC' can be assigned to the comparing function.
137
+ The comparing function should be kept same in the life of a database.
138
+ The return value is the database handle or `NULL' if it is not successful.
139
+ While connecting as a writer, an exclusive lock is invoked to the database file.
140
+ While connecting as a reader, a shared lock is invoked to the database file. The thread
141
+ blocks until the lock is achieved. `VL_OZCOMP' is available only if QDBM was built with
142
+ ZLIB enabled. If `VL_ONOLCK' is used, the application is responsible for exclusion control. */
143
+ VILLA *vlopen(const char *name, int omode, VLCFUNC cmp);
144
+
145
+
146
+ /* Close a database handle.
147
+ `villa' specifies a database handle.
148
+ If successful, the return value is true, else, it is false.
149
+ Because the region of a closed handle is released, it becomes impossible to use the handle.
150
+ Updating a database is assured to be written when the handle is closed. If a writer opens
151
+ a database but does not close it appropriately, the database will be broken. If the
152
+ transaction is activated and not committed, it is aborted. */
153
+ int vlclose(VILLA *villa);
154
+
155
+
156
+ /* Store a record.
157
+ `villa' specifies a database handle connected as a writer.
158
+ `kbuf' specifies the pointer to the region of a key.
159
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
160
+ with `strlen(kbuf)'.
161
+ `vbuf' specifies the pointer to the region of a value.
162
+ `vsiz' specifies the size of the region of the value. If it is negative, the size is
163
+ assigned with `strlen(vbuf)'.
164
+ `dmode' specifies behavior when the key overlaps, by the following values: `VL_DOVER',
165
+ which means the specified value overwrites the existing one, `VL_DKEEP', which means the
166
+ existing value is kept, `VL_DDUP', which means duplication of keys is allowed.
167
+ If successful, the return value is true, else, it is false.
168
+ A duplicated record is stored at the tail of the records of the same key. The cursor becomes
169
+ unavailable due to updating database. */
170
+ int vlput(VILLA *villa, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode);
171
+
172
+
173
+ /* Delete a record.
174
+ `villa' specifies a database handle connected as a writer.
175
+ `kbuf' specifies the pointer to the region of a key.
176
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
177
+ with `strlen(kbuf)'.
178
+ If successful, the return value is true, else, it is false. False is returned when no
179
+ record corresponds to the specified key.
180
+ When the key of duplicated records is specified, the first record of the same key is deleted.
181
+ The cursor becomes unavailable due to updating database. */
182
+ int vlout(VILLA *villa, const char *kbuf, int ksiz);
183
+
184
+
185
+ /* Retrieve a record.
186
+ `villa' specifies a database handle.
187
+ `kbuf' specifies the pointer to the region of a key.
188
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
189
+ with `strlen(kbuf)'.
190
+ `sp' specifies the pointer to a variable to which the size of the region of the return
191
+ value is assigned. If it is `NULL', it is not used.
192
+ If successful, the return value is the pointer to the region of the value of the
193
+ corresponding record, else, it is `NULL'. `NULL' is returned when no record corresponds to
194
+ the specified key.
195
+ When the key of duplicated records is specified, the value of the first record of the same
196
+ key is selected. Because an additional zero code is appended at the end of the region of the
197
+ return value, the return value can be treated as a character string. Because the region of
198
+ the return value is allocated with the `malloc' call, it should be released with the `free'
199
+ call if it is no longer in use. */
200
+ char *vlget(VILLA *villa, const char *kbuf, int ksiz, int *sp);
201
+
202
+
203
+ /* Get the number of records corresponding a key.
204
+ `villa' specifies a database handle.
205
+ `kbuf' specifies the pointer to the region of a key.
206
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
207
+ with `strlen(kbuf)'.
208
+ The return value is the number of corresponding records. If no record corresponds, 0 is
209
+ returned. */
210
+ int vlvnum(VILLA *villa, const char *kbuf, int ksiz);
211
+
212
+
213
+ /* Store plural records corresponding a key.
214
+ `villa' specifies a database handle connected as a writer.
215
+ `kbuf' specifies the pointer to the region of a key.
216
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
217
+ with `strlen(kbuf)'.
218
+ `vals' specifies a list handle of values. The list should not be empty.
219
+ If successful, the return value is true, else, it is false.
220
+ The cursor becomes unavailable due to updating database. */
221
+ int vlputlist(VILLA *villa, const char *kbuf, int ksiz, const CBLIST *vals);
222
+
223
+
224
+ /* Delete all records corresponding a key.
225
+ `villa' specifies a database handle connected as a writer.
226
+ `kbuf' specifies the pointer to the region of a key.
227
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
228
+ with `strlen(kbuf)'.
229
+ If successful, the return value is true, else, it is false. False is returned when no
230
+ record corresponds to the specified key.
231
+ The cursor becomes unavailable due to updating database. */
232
+ int vloutlist(VILLA *villa, const char *kbuf, int ksiz);
233
+
234
+
235
+ /* Retrieve values of all records corresponding a key.
236
+ `villa' specifies a database handle.
237
+ `kbuf' specifies the pointer to the region of a key.
238
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
239
+ with `strlen(kbuf)'.
240
+ If successful, the return value is a list handle of the values of the corresponding records,
241
+ else, it is `NULL'. `NULL' is returned when no record corresponds to the specified key.
242
+ Because the handle of the return value is opened with the function `cblistopen', it should
243
+ be closed with the function `cblistclose' if it is no longer in use. */
244
+ CBLIST *vlgetlist(VILLA *villa, const char *kbuf, int ksiz);
245
+
246
+
247
+ /* Move the cursor to the first record.
248
+ `villa' specifies a database handle.
249
+ If successful, the return value is true, else, it is false. False is returned if there is
250
+ no record in the database. */
251
+ int vlcurfirst(VILLA *villa);
252
+
253
+
254
+ /* Move the cursor to the last record.
255
+ `villa' specifies a database handle.
256
+ If successful, the return value is true, else, it is false. False is returned if there is
257
+ no record in the database. */
258
+ int vlcurlast(VILLA *villa);
259
+
260
+
261
+ /* Move the cursor to the previous record.
262
+ `villa' specifies a database handle.
263
+ If successful, the return value is true, else, it is false. False is returned if there is
264
+ no previous record. */
265
+ int vlcurprev(VILLA *villa);
266
+
267
+
268
+ /* Move the cursor to the next record.
269
+ `villa' specifies a database handle.
270
+ If successful, the return value is true, else, it is false. False is returned if there is
271
+ no next record. */
272
+ int vlcurnext(VILLA *villa);
273
+
274
+
275
+ /* Move the cursor to position around a record.
276
+ `villa' specifies a database handle.
277
+ `kbuf' specifies the pointer to the region of a key.
278
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
279
+ with `strlen(kbuf)'.
280
+ `jmode' specifies detail adjustment: `VL_JFORWARD', which means that the cursor is set to
281
+ the first record of the same key and that the cursor is set to the next substitute if
282
+ completely matching record does not exist, `VL_JBACKWARD', which means that the cursor is
283
+ set to the last record of the same key and that the cursor is set to the previous substitute
284
+ if completely matching record does not exist.
285
+ If successful, the return value is true, else, it is false. False is returned if there is
286
+ no record corresponding the condition. */
287
+ int vlcurjump(VILLA *villa, const char *kbuf, int ksiz, int jmode);
288
+
289
+
290
+ /* Get the key of the record where the cursor is.
291
+ `villa' specifies a database handle.
292
+ `sp' specifies the pointer to a variable to which the size of the region of the return
293
+ value is assigned. If it is `NULL', it is not used.
294
+ If successful, the return value is the pointer to the region of the key of the corresponding
295
+ record, else, it is `NULL'. `NULL' is returned when no record corresponds to the cursor.
296
+ Because an additional zero code is appended at the end of the region of the
297
+ return value, the return value can be treated as a character string. Because the region of
298
+ the return value is allocated with the `malloc' call, it should be released with the `free'
299
+ call if it is no longer in use. */
300
+ char *vlcurkey(VILLA *villa, int *sp);
301
+
302
+
303
+ /* Get the value of the record where the cursor is.
304
+ `villa' specifies a database handle.
305
+ `sp' specifies the pointer to a variable to which the size of the region of the return
306
+ value is assigned. If it is `NULL', it is not used.
307
+ If successful, the return value is the pointer to the region of the value of the
308
+ corresponding record, else, it is `NULL'. `NULL' is returned when no record corresponds to
309
+ the cursor.
310
+ Because an additional zero code is appended at the end of the region of the
311
+ return value, the return value can be treated as a character string. Because the region of
312
+ the return value is allocated with the `malloc' call, it should be released with the `free'
313
+ call if it is no longer in use. */
314
+ char *vlcurval(VILLA *villa, int *sp);
315
+
316
+
317
+ /* Set the tuning parameters for performance.
318
+ `villa' specifies a database handle.
319
+ `lrecmax' specifies the max number of records in a leaf node of B+ tree. If it is not more
320
+ than 0, the default value is specified.
321
+ `nidxmax' specifies the max number of indexes in a non-leaf node of B+ tree. If it is not
322
+ more than 0, the default value is specified.
323
+ `lcnum' specifies the max number of caching leaf nodes. If it is not more than 0, the
324
+ default value is specified.
325
+ `ncnum' specifies the max number of caching non-leaf nodes. If it is not more than 0, the
326
+ default value is specified.
327
+ The default setting is equivalent to `vlsettuning(49, 192, 1024, 512)'. Because tuning
328
+ parameters are not saved in a database, you should specify them every opening a database. */
329
+ void vlsettuning(VILLA *villa, int lrecmax, int nidxmax, int lcnum, int ncnum);
330
+
331
+
332
+ /* Synchronize updating contents with the file and the device.
333
+ `villa' specifies a database handle connected as a writer.
334
+ If successful, the return value is true, else, it is false.
335
+ This function is useful when another process uses the connected database file. This function
336
+ should not be used while the transaction is activated. */
337
+ int vlsync(VILLA *villa);
338
+
339
+
340
+ /* Optimize a database.
341
+ `villa' specifies a database handle connected as a writer.
342
+ If successful, the return value is true, else, it is false.
343
+ In an alternating succession of deleting and storing with overwrite or concatenate,
344
+ dispensable regions accumulate. This function is useful to do away with them. This function
345
+ should not be used while the transaction is activated. */
346
+ int vloptimize(VILLA *villa);
347
+
348
+
349
+ /* Get the name of a database.
350
+ `villa' specifies a database handle.
351
+ If successful, the return value is the pointer to the region of the name of the database,
352
+ else, it is `NULL'.
353
+ Because the region of the return value is allocated with the `malloc' call, it should be
354
+ released with the `free' call if it is no longer in use. */
355
+ char *vlname(VILLA *villa);
356
+
357
+
358
+ /* Get the size of a database file.
359
+ `villa' specifies a database handle.
360
+ If successful, the return value is the size of the database file, else, it is -1.
361
+ Because of the I/O buffer, the return value may be less than the hard size. */
362
+ int vlfsiz(VILLA *villa);
363
+
364
+
365
+ /* Get the number of the leaf nodes of B+ tree.
366
+ `villa' specifies a database handle.
367
+ If successful, the return value is the number of the leaf nodes, else, it is -1. */
368
+ int vllnum(VILLA *villa);
369
+
370
+
371
+ /* Get the number of the non-leaf nodes of B+ tree.
372
+ `villa' specifies a database handle.
373
+ If successful, the return value is the number of the non-leaf nodes, else, it is -1. */
374
+ int vlnnum(VILLA *villa);
375
+
376
+
377
+ /* Get the number of the records stored in a database.
378
+ `villa' specifies a database handle.
379
+ If successful, the return value is the number of the records stored in the database, else,
380
+ it is -1. */
381
+ int vlrnum(VILLA *villa);
382
+
383
+
384
+ /* Check whether a database handle is a writer or not.
385
+ `villa' specifies a database handle.
386
+ The return value is true if the handle is a writer, false if not. */
387
+ int vlwritable(VILLA *villa);
388
+
389
+
390
+ /* Check whether a database has a fatal error or not.
391
+ `villa' specifies a database handle.
392
+ The return value is true if the database has a fatal error, false if not. */
393
+ int vlfatalerror(VILLA *villa);
394
+
395
+
396
+ /* Get the inode number of a database file.
397
+ `villa' specifies a database handle.
398
+ The return value is the inode number of the database file. */
399
+ int vlinode(VILLA *villa);
400
+
401
+
402
+ /* Get the last modified time of a database.
403
+ `villa' specifies a database handle.
404
+ The return value is the last modified time of the database. */
405
+ int vlmtime(VILLA *villa);
406
+
407
+
408
+ /* Begin the transaction.
409
+ `villa' specifies a database handle connected as a writer.
410
+ If successful, the return value is true, else, it is false.
411
+ Because this function does not perform mutual exclusion control in multi-thread, the
412
+ application is responsible for it. Only one transaction can be activated with a database
413
+ handle at the same time. */
414
+ int vltranbegin(VILLA *villa);
415
+
416
+
417
+ /* Commit the transaction.
418
+ `villa' specifies a database handle connected as a writer.
419
+ If successful, the return value is true, else, it is false.
420
+ Updating a database in the transaction is fixed when it is committed successfully. */
421
+ int vltrancommit(VILLA *villa);
422
+
423
+
424
+ /* Abort the transaction.
425
+ `villa' specifies a database handle connected as a writer.
426
+ If successful, the return value is true, else, it is false.
427
+ Updating a database in the transaction is discarded when it is aborted. The state of the
428
+ database is rollbacked to before transaction. */
429
+ int vltranabort(VILLA *villa);
430
+
431
+
432
+ /* Remove a database file.
433
+ `name' specifies the name of a database file.
434
+ If successful, the return value is true, else, it is false. */
435
+ int vlremove(const char *name);
436
+
437
+
438
+ /* Repair a broken database file.
439
+ `name' specifies the name of a database file.
440
+ `cmp' specifies the comparing function of the database file.
441
+ If successful, the return value is true, else, it is false.
442
+ There is no guarantee that all records in a repaired database file correspond to the original
443
+ or expected state. */
444
+ int vlrepair(const char *name, VLCFUNC cmp);
445
+
446
+
447
+ /* Dump all records as endian independent data.
448
+ `villa' specifies a database handle.
449
+ `name' specifies the name of an output file.
450
+ If successful, the return value is true, else, it is false. */
451
+ int vlexportdb(VILLA *villa, const char *name);
452
+
453
+
454
+ /* Load all records from endian independent data.
455
+ `villa' specifies a database handle connected as a writer. The database of the handle must
456
+ be empty.
457
+ `name' specifies the name of an input file.
458
+ If successful, the return value is true, else, it is false. */
459
+ int vlimportdb(VILLA *villa, const char *name);
460
+
461
+
462
+
463
+ #if defined(__cplusplus) /* export for C++ */
464
+ }
465
+ #endif
466
+
467
+ #endif /* duplication check */
468
+
469
+
470
+ /* END OF FILE */