File: index.html

package info (click to toggle)
libtokyocabinet-perl 1.34-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, stretch
  • size: 560 kB
  • ctags: 394
  • sloc: perl: 5,439; sh: 47; makefile: 2
file content (2128 lines) | stat: -rw-r--r-- 126,324 bytes parent folder | download | duplicates (3)
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
<?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">
<head>
<title>Tokyo Cabinet</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:info@fallabs.com" />
<meta http-equiv="content-style-type" content="text/css" />
<style type="text/css">body {
  padding: 1em 2em;
  background: #eeeeee none;
  color: #111111;
}
pre {
  padding: 0.2em 0em;
  background: #ddddee none;
  border: 1px solid #cccccc;
  font-size: 90%;
}
dd p {
  margin: 0.4em 0em 1.0em 0em;
  padding: 0em;
}
</style>
</head>

<body>


<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsys">SYNOPSYS</a></li>
	<li><a href="#introduction">INTRODUCTION</a></li>
	<li><ul>

		<li><a href="#setting">Setting</a></li>
	</ul></li>

	<li><a href="#example">EXAMPLE</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><ul>

		<li><a href="#class_tokyocabinet">Class TokyoCabinet</a></li>
		<li><a href="#class_tokyocabinet__hdb">Class TokyoCabinet::HDB</a></li>
		<li><a href="#tying_functions_of_tokyocabinet__hdb">Tying functions of TokyoCabinet::HDB</a></li>
		<li><a href="#class_tokyocabinet__bdb">Class TokyoCabinet::BDB</a></li>
		<li><a href="#class_tokyocabinet__bdbcur">Class TokyoCabinet::BDBCUR</a></li>
		<li><a href="#tying_functions_of_tokyocabinet__bdb">Tying functions of TokyoCabinet::BDB</a></li>
		<li><a href="#class_tokyocabinet__fdb">Class TokyoCabinet::FDB</a></li>
		<li><a href="#tying_functions_of_tokyocabinet__fdb">Tying functions of TokyoCabinet::FDB</a></li>
		<li><a href="#class_tokyocabinet__tdb">Class TokyoCabinet::TDB</a></li>
		<li><a href="#class_tokyocabinet__tdbqry">Class TokyoCabinet::TDBQRY</a></li>
		<li><a href="#tying_functions_of_tokyocabinet__tdb">Tying functions of TokyoCabinet::TDB</a></li>
		<li><a href="#class_tokyocabinet__adb">Class TokyoCabinet::ADB</a></li>
		<li><a href="#tying_functions_of_tokyocabinet__adb">Tying functions of TokyoCabinet::ADB</a></li>
	</ul></li>

	<li><a href="#license">LICENSE</a></li>
</ul>

<hr name="index" />
</div>
<!-- INDEX END -->

<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>TokyoCabinet - Perl Binding of Tokyo Cabinet</p>
<p>
</p>
<hr />
<h1><a name="synopsys">SYNOPSYS</a></h1>
<pre>
 use TokyoCabinet;</pre>
<p>
</p>
<hr />
<h1><a name="introduction">INTRODUCTION</a></h1>
<p>Tokyo Cabinet is a library of routines for managing a database.  The database is a simple data file containing records, each is a pair of a key and a value.  Every key and value is serial bytes with variable length.  Both binary data and character string can be used as a key and a value.  There is neither concept of data tables nor data types.  Records are organized in hash table, B+ tree, or fixed-length array.</p>
<p>As for database of hash table, each key must be unique within a database, so it is impossible to store two or more records with a key overlaps.  The following access methods are provided to the database: storing a record with a key and a value, deleting a record by a key, retrieving a record by a key.  Moreover, traversal access to every key are provided, although the order is arbitrary.  These access methods are similar to ones of DBM (or its followers: NDBM and GDBM) library defined in the UNIX standard.  Tokyo Cabinet is an alternative for DBM because of its higher performance.</p>
<p>As for database of B+ tree, records whose keys are duplicated can be stored.  Access methods of storing, deleting, and retrieving are provided as with the database of hash table.  Records are stored in order by a comparison function assigned by a user.  It is possible to access each record with the cursor in ascending or descending order.  According to this mechanism, forward matching search for strings and range search for integers are realized.</p>
<p>As for database of fixed-length array, records are stored with unique natural numbers.  It is impossible to store two or more records with a key overlaps.  Moreover, the length of each record is limited by the specified length.  Provided operations are the same as ones of hash database.</p>
<p>Table database is also provided as a variant of hash database.  Each record is identified by the primary key and has a set of named columns.  Although there is no concept of data schema, it is possible to search for records with complex conditions efficiently by using indices of arbitrary columns.</p>
<p>
</p>
<h2><a name="setting">Setting</a></h2>
<p>Install the latest version of Tokyo Cabinet beforehand and get the package of the Perl binding of Tokyo Cabinet.</p>
<p>Enter the directory of the extracted package then perform installation.</p>
<pre>
 perl Makefile.PL
 make
 make test
 su
 make install</pre>
<p>The package `TokyoCabinet' should be loaded in each source file of application programs.</p>
<pre>
 use TokyoCabinet;</pre>
<p>If you want to enable runtime assertion, set the variable `$TokyoCabinet::DEBUG' to be true.</p>
<pre>
 $TokyoCabinet::DEBUG = 1;</pre>
<p>
</p>
<hr />
<h1><a name="example">EXAMPLE</a></h1>
<p>The following code is an example to use a hash database.</p>
<pre>
 use TokyoCabinet;
 use strict;
 use warnings;
 
 # create the object
 my $hdb = TokyoCabinet::HDB-&gt;new();
 
 # open the database
 if(!$hdb-&gt;open(&quot;casket.tch&quot;, $hdb-&gt;OWRITER | $hdb-&gt;OCREAT)){
     my $ecode = $hdb-&gt;ecode();
     printf STDERR (&quot;open error: %s\n&quot;, $hdb-&gt;errmsg($ecode));
 }
 
 # store records
 if(!$hdb-&gt;put(&quot;foo&quot;, &quot;hop&quot;) ||
    !$hdb-&gt;put(&quot;bar&quot;, &quot;step&quot;) ||
    !$hdb-&gt;put(&quot;baz&quot;, &quot;jump&quot;)){
     my $ecode = $hdb-&gt;ecode();
     printf STDERR (&quot;put error: %s\n&quot;, $hdb-&gt;errmsg($ecode));
 }
 
 # retrieve records
 my $value = $hdb-&gt;get(&quot;foo&quot;);
 if(defined($value)){
     printf(&quot;%s\n&quot;, $value);
 } else {
     my $ecode = $hdb-&gt;ecode();
     printf STDERR (&quot;get error: %s\n&quot;, $hdb-&gt;errmsg($ecode));
 }
 
 # traverse records
 $hdb-&gt;iterinit();
 while(defined(my $key = $hdb-&gt;iternext())){
     my $value = $hdb-&gt;get($key);
     if(defined($value)){
         printf(&quot;%s:%s\n&quot;, $key, $value);
     }
 }
 
 # close the database
 if(!$hdb-&gt;close()){
     my $ecode = $hdb-&gt;ecode();
     printf STDERR (&quot;close error: %s\n&quot;, $hdb-&gt;errmsg($ecode));
 }
 
 # tying usage
 my %hash;
 if(!tie(%hash, &quot;TokyoCabinet::HDB&quot;, &quot;casket.tch&quot;, TokyoCabinet::HDB::OWRITER)){
     printf STDERR (&quot;tie error\n&quot;);
 }
 $hash{&quot;quux&quot;} = &quot;touchdown&quot;;
 printf(&quot;%s\n&quot;, $hash{&quot;quux&quot;});
 while(my ($key, $value) = each(%hash)){
     printf(&quot;%s:%s\n&quot;, $key, $value);
 }
 untie(%hash);</pre>
<p>The following code is an example to use a B+ tree database.</p>
<pre>
 use TokyoCabinet;
 use strict;
 use warnings;
 
 # create the object
 my $bdb = TokyoCabinet::BDB-&gt;new();
 
 # open the database
 if(!$bdb-&gt;open(&quot;casket.tcb&quot;, $bdb-&gt;OWRITER | $bdb-&gt;OCREAT)){
     my $ecode = $bdb-&gt;ecode();
     printf STDERR (&quot;open error: %s\n&quot;, $bdb-&gt;errmsg($ecode));
 }
 
 # store records
 if(!$bdb-&gt;put(&quot;foo&quot;, &quot;hop&quot;) ||
    !$bdb-&gt;put(&quot;bar&quot;, &quot;step&quot;) ||
    !$bdb-&gt;put(&quot;baz&quot;, &quot;jump&quot;)){
     my $ecode = $bdb-&gt;ecode();
     printf STDERR (&quot;put error: %s\n&quot;, $bdb-&gt;errmsg($ecode));
 }
 
 # retrieve records
 my $value = $bdb-&gt;get(&quot;foo&quot;);
 if(defined($value)){
     printf(&quot;%s\n&quot;, $value);
 } else {
     my $ecode = $bdb-&gt;ecode();
     printf STDERR (&quot;get error: %s\n&quot;, $bdb-&gt;errmsg($ecode));
 }
 
 # traverse records
 my $cur = TokyoCabinet::BDBCUR-&gt;new($bdb);
 $cur-&gt;first();
 while(defined(my $key = $cur-&gt;key())){
     my $value = $cur-&gt;val();
     if(defined($value)){
         printf(&quot;%s:%s\n&quot;, $key, $value);
     }
     $cur-&gt;next();
 }
 
 # close the database
 if(!$bdb-&gt;close()){
     my $ecode = $bdb-&gt;ecode();
     printf STDERR (&quot;close error: %s\n&quot;, $bdb-&gt;errmsg($ecode));
 }
 
 # tying usage
 my %hash;
 if(!tie(%hash, &quot;TokyoCabinet::BDB&quot;, &quot;casket.tcb&quot;, TokyoCabinet::BDB::OWRITER)){
     printf STDERR (&quot;tie error\n&quot;);
 }
 $hash{&quot;quux&quot;} = &quot;touchdown&quot;;
 printf(&quot;%s\n&quot;, $hash{&quot;quux&quot;});
 while(my ($key, $value) = each(%hash)){
     printf(&quot;%s:%s\n&quot;, $key, $value);
 }
 untie(%hash);</pre>
<p>The following code is an example to use a fixed-length database.</p>
<pre>
 use TokyoCabinet;
 use strict;
 use warnings;
 
 # create the object
 my $fdb = TokyoCabinet::FDB-&gt;new();
 
 # open the database
 if(!$fdb-&gt;open(&quot;casket.tcf&quot;, $fdb-&gt;OWRITER | $fdb-&gt;OCREAT)){
     my $ecode = $fdb-&gt;ecode();
     printf STDERR (&quot;open error: %s\n&quot;, $fdb-&gt;errmsg($ecode));
 }
 
 # store records
 if(!$fdb-&gt;put(1, &quot;one&quot;) ||
    !$fdb-&gt;put(12, &quot;twelve&quot;) ||
    !$fdb-&gt;put(144, &quot;one forty four&quot;)){
     my $ecode = $fdb-&gt;ecode();
     printf STDERR (&quot;put error: %s\n&quot;, $fdb-&gt;errmsg($ecode));
 }
 
 # retrieve records
 my $value = $fdb-&gt;get(1);
 if(defined($value)){
     printf(&quot;%s\n&quot;, $value);
 } else {
     my $ecode = $fdb-&gt;ecode();
     printf STDERR (&quot;get error: %s\n&quot;, $fdb-&gt;errmsg($ecode));
 }
 
 # traverse records
 $fdb-&gt;iterinit();
 while(defined(my $key = $fdb-&gt;iternext())){
     my $value = $fdb-&gt;get($key);
     if(defined($value)){
         printf(&quot;%s:%s\n&quot;, $key, $value);
     }
 }
 
 # close the database
 if(!$fdb-&gt;close()){
     my $ecode = $fdb-&gt;ecode();
     printf STDERR (&quot;close error: %s\n&quot;, $fdb-&gt;errmsg($ecode));
 }
 
 # tying usage
 my %hash;
 if(!tie(%hash, &quot;TokyoCabinet::FDB&quot;, &quot;casket.tcf&quot;, TokyoCabinet::FDB::OWRITER)){
     printf STDERR (&quot;tie error\n&quot;);
 }
 $hash{1728} = &quot;seventeen twenty eight&quot;;
 printf(&quot;%s\n&quot;, $hash{1728});
 while(my ($key, $value) = each(%hash)){
     printf(&quot;%s:%s\n&quot;, $key, $value);
 }
 untie(%hash);</pre>
<p>The following code is an example to use a table database.</p>
<pre>
 use TokyoCabinet;
 use strict;
 use warnings;
 
 # create the object
 my $tdb = TokyoCabinet::TDB-&gt;new();
 
 # open the database
 if(!$tdb-&gt;open(&quot;casket.tct&quot;, $tdb-&gt;OWRITER | $tdb-&gt;OCREAT)){
     my $ecode = $tdb-&gt;ecode();
     printf STDERR (&quot;open error: %s\n&quot;, $tdb-&gt;errmsg($ecode));
 }
 
 # store a record
 my $pkey = $tdb-&gt;genuid();
 my $cols = { &quot;name&quot; =&gt; &quot;mikio&quot;, &quot;age&quot; =&gt; &quot;30&quot;, &quot;lang&quot; =&gt; &quot;ja,en,c&quot; };
 if(!$tdb-&gt;put($pkey, $cols)){
     my $ecode = $tdb-&gt;ecode();
     printf STDERR (&quot;put error: %s\n&quot;, $tdb-&gt;errmsg($ecode));
 }
 
 # store another record
 $cols = { &quot;name&quot; =&gt; &quot;falcon&quot;, &quot;age&quot; =&gt; &quot;31&quot;, &quot;lang&quot; =&gt; &quot;ja&quot;, &quot;skill&quot; =&gt; &quot;cook,blog&quot; };
 if(!$tdb-&gt;put(&quot;x12345&quot;, $cols)){
     my $ecode = $tdb-&gt;ecode();
     printf STDERR (&quot;put error: %s\n&quot;, $tdb-&gt;errmsg($ecode));
 }
 
 # search for records
 my $qry = TokyoCabinet::TDBQRY-&gt;new($tdb);
 $qry-&gt;addcond(&quot;age&quot;, $qry-&gt;QCNUMGE, &quot;20&quot;);
 $qry-&gt;addcond(&quot;lang&quot;, $qry-&gt;QCSTROR, &quot;ja,en&quot;);
 $qry-&gt;setorder(&quot;name&quot;, $qry-&gt;QOSTRASC);
 $qry-&gt;setlimit(10);
 my $res = $qry-&gt;search();
 foreach my $rkey (@$res){
     my $rcols = $tdb-&gt;get($rkey);
     printf(&quot;name:%s\n&quot;, $rcols-&gt;{name});
 }
 
 # close the database
 if(!$tdb-&gt;close()){
     my $ecode = $tdb-&gt;ecode();
     printf STDERR (&quot;close error: %s\n&quot;, $tdb-&gt;errmsg($ecode));
 }
 
 # tying usage
 my %hash;
 if(!tie(%hash, &quot;TokyoCabinet::TDB&quot;, &quot;casket.tct&quot;, TokyoCabinet::TDB::OWRITER)){
     printf STDERR (&quot;tie error\n&quot;);
 }
 $hash{&quot;joker&quot;} = { &quot;name&quot; =&gt; &quot;ozma&quot;, &quot;lang&quot; =&gt; &quot;en&quot;, &quot;skill&quot; =&gt; &quot;song,dance&quot; };
 printf(&quot;%s\n&quot;, $hash{joker}-&gt;{name});
 while(my ($key, $value) = each(%hash)){
     printf(&quot;%s:%s\n&quot;, $key, $value-&gt;{name});
 }
 untie(%hash);</pre>
<p>The following code is an example to use an abstract database.</p>
<pre>
 use TokyoCabinet;
 use strict;
 use warnings;
 
 # create the object
 my $adb = TokyoCabinet::ADB-&gt;new();
 
 # open the database
 if(!$adb-&gt;open(&quot;casket.tch&quot;)){
     printf STDERR (&quot;open error\n&quot;);
 }
 
 # store records
 if(!$adb-&gt;put(&quot;foo&quot;, &quot;hop&quot;) ||
    !$adb-&gt;put(&quot;bar&quot;, &quot;step&quot;) ||
    !$adb-&gt;put(&quot;baz&quot;, &quot;jump&quot;)){
     printf STDERR (&quot;put error\n&quot;);
 }
 
 # retrieve records
 my $value = $adb-&gt;get(&quot;foo&quot;);
 if(defined($value)){
     printf(&quot;%s\n&quot;, $value);
 } else {
     printf STDERR (&quot;get error\n&quot;);
 }
 
 # traverse records
 $adb-&gt;iterinit();
 while(defined(my $key = $adb-&gt;iternext())){
     my $value = $adb-&gt;get($key);
     if(defined($value)){
         printf(&quot;%s:%s\n&quot;, $key, $value);
     }
 }
 
 # close the database
 if(!$adb-&gt;close()){
     printf STDERR (&quot;close error\n&quot;);
 }
 
 # tying usage
 my %hash;
 if(!tie(%hash, &quot;TokyoCabinet::ADB&quot;, &quot;casket.tch&quot;)){
     printf STDERR (&quot;tie error\n&quot;);
 }
 $hash{&quot;quux&quot;} = &quot;touchdown&quot;;
 printf(&quot;%s\n&quot;, $hash{&quot;quux&quot;});
 while(my ($key, $value) = each(%hash)){
     printf(&quot;%s:%s\n&quot;, $key, $value);
 }
 untie(%hash);</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>
</p>
<h2><a name="class_tokyocabinet">Class TokyoCabinet</a></h2>
<p>The following functions are utilities to handle records by applications.</p>
<dl>
<dt><strong><a name="version" class="item">TokyoCabinet::VERSION()</a></strong></dt>

<dd>
<p>Get the version information of Tokyo Cabinet.
<br />The return value is the version information.</p>
</dd>
<dt><strong><a name="atoi" class="item">TokyoCabinet::atoi(<em>str</em>)</a></strong></dt>

<dd>
<p>Convert a string to an integer.
<br />The return value is the integer value.</p>
</dd>
<dt><strong><a name="atof" class="item">TokyoCabinet::atof(<em>str</em>)</a></strong></dt>

<dd>
<p>Convert a string to a real number.
<br />The return value is the real number value.</p>
</dd>
<dt><strong><a name="bercompress" class="item">TokyoCabinet::bercompress(<em>aryref</em>)</a></strong></dt>

<dd>
<p>Serialize an array of nonnegative integers with BER encoding.
<br />`<em>aryref</em>' specifies the reference to an array of nonnegative integers.
<br />The return value is the reference to the serialized scalar.</p>
</dd>
<dt><strong><a name="beruncompress" class="item">TokyoCabinet::beruncompress(<em>selref</em>)</a></strong></dt>

<dd>
<p>Deserialize a BER encoded scalar to an array.
<br />`<em>selref</em>' specifies the reference to the BER encoded scalar.
<br />The return value is the reference to the array of nonnegative integers.</p>
</dd>
<dt><strong><a name="diffcompress" class="item">TokyoCabinet::diffcompress(<em>aryref</em>)</a></strong></dt>

<dd>
<p>Serialize an array of sorted nonnegative integers with difference BER encoding.
<br />`<em>aryref</em>' specifies the reference to an array of sorted nonnegative integers.
<br />The return value is the reference to the serialized scalar.</p>
</dd>
<dt><strong><a name="diffuncompress" class="item">TokyoCabinet::diffuncompress(<em>selref</em>)</a></strong></dt>

<dd>
<p>Deserialize a difference BER encoded scalar to an array.
<br />`<em>selref</em>' specifies the reference to the BER encoded scalar.
<br />The return value is the reference to the array of sorted nonnegative integers.</p>
</dd>
<dt><strong><a name="strdistance" class="item">TokyoCabinet::strdistance(<em>aref</em>, <em>bref</em>, <em>isutf</em>)</a></strong></dt>

<dd>
<p>Calculate the edit distance of two strings.
<br />`<em>aref</em>' specifies the reference to a string.
<br />`<em>bref</em>' specifies the reference to the other string.
<br />`<em>isutf</em>' specifies whether the cost is calculated by Unicode character of UTF-8 strings.
<br />The return value is the edit distance which is known as the Levenshtein distance.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="class_tokyocabinet__hdb">Class TokyoCabinet::HDB</a></h2>
<p>Hash database is a file containing a hash table and is handled with the hash database API.  Before operations to store or retrieve records, it is necessary to open a database file and connect the hash database object to it.  The method `open' is used to open a database file and the method `close' is used to close the database file.  To avoid data missing or corruption, it is important to close every database file when it is no longer in use.  It is forbidden for multible database objects in a process to open the same database at the same time.</p>
<dl>
<dt><strong><a name="new" class="item">$hdb = TokyoCabinet::HDB-&gt;new()</a></strong></dt>

<dd>
<p>Create a hash database object.
<br />The return value is the new hash database object.</p>
</dd>
<dt><strong><a name="errmsg" class="item">$hdb-&gt;errmsg(<em>ecode</em>)</a></strong></dt>

<dd>
<p>Get the message string corresponding to an error code.
<br />`<em>ecode</em>' specifies the error code.  If it is not defined or negative, the last happened error code is specified.
<br />The return value is the message string of the error code.</p>
</dd>
<dt><strong><a name="ecode" class="item">$hdb-&gt;ecode()</a></strong></dt>

<dd>
<p>Get the last happened error code.
<br />The return value is the last happened error code.
<br />The following error codes are defined: `$hdb-&gt;ESUCCESS' for success, `$hdb-&gt;ETHREAD' for threading error, `$hdb-&gt;EINVALID' for invalid operation, `$hdb-&gt;ENOFILE' for file not found, `$hdb-&gt;ENOPERM' for no permission, `$hdb-&gt;EMETA' for invalid meta data, `$hdb-&gt;ERHEAD' for invalid record header, `$hdb-&gt;EOPEN' for open error, `$hdb-&gt;ECLOSE' for close error, `$hdb-&gt;ETRUNC' for trunc error, `$hdb-&gt;ESYNC' for sync error, `$hdb-&gt;ESTAT' for stat error, `$hdb-&gt;ESEEK' for seek error, `$hdb-&gt;EREAD' for read error, `$hdb-&gt;EWRITE' for write error, `$hdb-&gt;EMMAP' for mmap error, `$hdb-&gt;ELOCK' for lock error, `$hdb-&gt;EUNLINK' for unlink error, `$hdb-&gt;ERENAME' for rename error, `$hdb-&gt;EMKDIR' for mkdir error, `$hdb-&gt;ERMDIR' for rmdir error, `$hdb-&gt;EKEEP' for existing record, `$hdb-&gt;ENOREC' for no record found, and `$hdb-&gt;EMISC' for miscellaneous error.</p>
</dd>
<dt><strong><a name="tune" class="item">$hdb-&gt;tune(<em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>)</a></strong></dt>

<dd>
<p>Set the tuning parameters.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is 131071.  Suggested size of the bucket array is about from 0.5 to 4 times of the number of all records to be stored.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 4 standing for 2^4=16.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 10 standing for 2^10=1024.
<br />`<em>opts</em>' specifies options by bitwise-or: `$hdb-&gt;TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `$hdb-&gt;TDEFLATE' specifies that each record is compressed with Deflate encoding, `$hdb-&gt;TBZIP' specifies that each record is compressed with BZIP2 encoding, `$hdb-&gt;TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined, no option is specified.
<br />If successful, the return value is true, else, it is false.  Note that the tuning parameters of the database should be set before the database is opened.</p>
</dd>
<dt><strong><a name="setcache" class="item">$hdb-&gt;setcache(<em>rcnum</em>)</a></strong></dt>

<dd>
<p>Set the caching parameters.
<br />`<em>rcnum</em>' specifies the maximum number of records to be cached.  If it is not defined or not more than 0, the record cache is disabled. It is disabled by default.
<br />If successful, the return value is true, else, it is false.
<br />Note that the caching parameters of the database should be set before the database is opened.</p>
</dd>
<dt><strong><a name="setxmsiz" class="item">$hdb-&gt;setxmsiz(<em>xmsiz</em>)</a></strong></dt>

<dd>
<p>Set the size of the extra mapped memory.
<br />`<em>xmsiz</em>' specifies the size of the extra mapped memory.  If it is not defined or not more than 0, the extra mapped memory is disabled.  The default size is 67108864.
<br />If successful, the return value is true, else, it is false.
<br />Note that the mapping parameters should be set before the database is opened.</p>
</dd>
<dt><strong><a name="setdfunit" class="item">$hdb-&gt;setdfunit(<em>dfunit</em>)</a></strong></dt>

<dd>
<p>Set the unit step number of auto defragmentation.
<br />`<em>dfunit</em>' specifie the unit step number.  If it is not more than 0, the auto defragmentation is disabled.  It is disabled by default.
<br />If successful, the return value is true, else, it is false.
<br />Note that the defragmentation parameters should be set before the database is opened.</p>
</dd>
<dt><strong><a name="open" class="item">$hdb-&gt;open(<em>path</em>, <em>omode</em>)</a></strong></dt>

<dd>
<p>Open a database file.
<br />`<em>path</em>' specifies the path of the database file.
<br />`<em>omode</em>' specifies the connection mode: `$hdb-&gt;OWRITER' as a writer, `$hdb-&gt;OREADER' as a reader.  If the mode is `$hdb-&gt;OWRITER', the following may be added by bitwise-or: `$hdb-&gt;OCREAT', which means it creates a new database if not exist, `$hdb-&gt;OTRUNC', which means it creates a new database regardless if one exists, `$hdb-&gt;OTSYNC', which means every transaction synchronizes updated contents with the device.  Both of `$hdb-&gt;OREADER' and `$hdb-&gt;OWRITER' can be added to by bitwise-or: `$hdb-&gt;ONOLCK', which means it opens the database file without file locking, or `$hdb-&gt;OLCKNB', which means locking is performed without blocking.  If it is not defined, `$hdb-&gt;OREADER' is specified.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong><a name="close" class="item">$hdb-&gt;close()</a></strong></dt>

<dd>
<p>Close the database file.
<br />If successful, the return value is true, else, it is false.
<br />Update of a database is assured to be written when the database is closed.  If a writer opens a database but does not close it appropriately, the database will be broken.</p>
</dd>
<dt><strong><a name="put" class="item">$hdb-&gt;put(<em>key</em>, <em>value</em>)</a></strong></dt>

<dd>
<p>Store a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong><a name="putkeep" class="item">$hdb-&gt;putkeep(<em>key</em>, <em>value</em>)</a></strong></dt>

<dd>
<p>Store a new record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, this method has no effect.</p>
</dd>
<dt><strong><a name="putcat" class="item">$hdb-&gt;putcat(<em>key</em>, <em>value</em>)</a></strong></dt>

<dd>
<p>Concatenate a value at the end of the existing record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If there is no corresponding record, a new record is created.</p>
</dd>
<dt><strong><a name="putasync" class="item">$hdb-&gt;putasync(<em>key</em>, <em>value</em>)</a></strong></dt>

<dd>
<p>Store a record in asynchronous fashion.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.  Records passed to this method are accumulated into the inner buffer and wrote into the file at a blast.</p>
</dd>
<dt><strong><a name="out" class="item">$hdb-&gt;out(<em>key</em>)</a></strong></dt>

<dd>
<p>Remove a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong><a name="get" class="item">$hdb-&gt;get(<em>key</em>)</a></strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the value of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong><a name="vsiz" class="item">$hdb-&gt;vsiz(<em>key</em>)</a></strong></dt>

<dd>
<p>Get the size of the value of a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the size of the value of the corresponding record, else, it is -1.</p>
</dd>
<dt><strong><a name="iterinit" class="item">$hdb-&gt;iterinit()</a></strong></dt>

<dd>
<p>Initialize the iterator.
<br />If successful, the return value is true, else, it is false.
<br />The iterator is used in order to access the key of every record stored in a database.</p>
</dd>
<dt><strong><a name="iternext" class="item">$hdb-&gt;iternext()</a></strong></dt>

<dd>
<p>Get the next key of the iterator.
<br />If successful, the return value is the next key, else, it is `undef'.  `undef' is returned when no record is to be get out of the iterator.
<br />It is possible to access every record by iteration of calling this method.  It is allowed to update or remove records whose keys are fetched while the iteration.  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.</p>
</dd>
<dt><strong><a name="fwmkeys" class="item">$hdb-&gt;fwmkeys(<em>prefix</em>, <em>max</em>)</a></strong></dt>

<dd>
<p>Get forward matching keys.
<br />`<em>prefix</em>' specifies the prefix of the corresponding keys.
<br />`<em>max</em>' specifies the maximum number of keys to be fetched.  If it is not defined or negative, no limit is specified.
<br />The return value is the reference to an array of the keys of the corresponding records.  This method does never fail.  It returns an empty array even if no record corresponds.
<br />Note that this method may be very slow because every key in the database is scanned.</p>
</dd>
<dt><strong><a name="addint" class="item">$hdb-&gt;addint(<em>key</em>, <em>num</em>)</a></strong></dt>

<dd>
<p>Add an integer to a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />If the corresponding record exists, the value is treated as an integer and is added to.  If no record corresponds, a new record of the additional value is stored.  Because records are stored in binary format, they should be processed with the `unpack' function with the `i' operator after retrieval.</p>
</dd>
<dt><strong><a name="adddouble" class="item">$hdb-&gt;adddouble(<em>key</em>, <em>num</em>)</a></strong></dt>

<dd>
<p>Add a real number to a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />If the corresponding record exists, the value is treated as a real number and is added to.  If no record corresponds, a new record of the additional value is stored.  Because records are stored in binary format, they should be processed with the `unpack' function with the `d' operator after retrieval.</p>
</dd>
<dt><strong><a name="sync" class="item">$hdb-&gt;sync()</a></strong></dt>

<dd>
<p>Synchronize updated contents with the file and the device.
<br />If successful, the return value is true, else, it is false.
<br />This method is useful when another process connects the same database file.</p>
</dd>
<dt><strong><a name="optimize" class="item">$hdb-&gt;optimize(<em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>)</a></strong></dt>

<dd>
<p>Optimize the database file.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is two times of the number of records.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the current setting is not changed.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the current setting is not changed.
<br />`<em>opts</em>' specifies options by bitwise-or: `$hdb-&gt;TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `$hdb-&gt;TDEFLATE' specifies that each record is compressed with Deflate encoding, `$hdb-&gt;TBZIP' specifies that each record is compressed with BZIP2 encoding, `$hdb-&gt;TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined or 0xff, the current setting is not changed.
<br />If successful, the return value is true, else, it is false.
<br />This method is useful to reduce the size of the database file with data fragmentation by successive updating.</p>
</dd>
<dt><strong><a name="vanish" class="item">$hdb-&gt;vanish()</a></strong></dt>

<dd>
<p>Remove all records.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong><a name="copy" class="item">$hdb-&gt;copy(<em>path</em>)</a></strong></dt>

<dd>
<p>Copy the database file.
<br />`<em>path</em>' specifies the path of the destination file.  If it begins with `@', the trailing substring is executed as a command line.
<br />If successful, the return value is true, else, it is false.  False is returned if the executed command returns non-zero code.
<br />The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress.  So, this method is useful to create a backup file of the database file.</p>
</dd>
<dt><strong><a name="tranbegin" class="item">$hdb-&gt;tranbegin()</a></strong></dt>

<dd>
<p>Begin the transaction.
<br />If successful, the return value is true, else, it is false.
<br />The database is locked by the thread while the transaction so that only one transaction can be activated with a database object at the same time.  Thus, the serializable isolation level is assumed if every database operation is performed in the transaction.  All updated regions are kept track of by write ahead logging while the transaction.  If the database is closed during transaction, the transaction is aborted implicitly.</p>
</dd>
<dt><strong><a name="trancommit" class="item">$hdb-&gt;trancommit()</a></strong></dt>

<dd>
<p>Commit the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is fixed when it is committed successfully.</p>
</dd>
<dt><strong><a name="tranabort" class="item">$hdb-&gt;tranabort()</a></strong></dt>

<dd>
<p>Abort the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is discarded when it is aborted.  The state of the database is rollbacked to before transaction.</p>
</dd>
<dt><strong><a name="path" class="item">$hdb-&gt;path()</a></strong></dt>

<dd>
<p>Get the path of the database file.
<br />The return value is the path of the database file or `undef' if the object does not connect to any database file.</p>
</dd>
<dt><strong><a name="rnum" class="item">$hdb-&gt;rnum()</a></strong></dt>

<dd>
<p>Get the number of records.
<br />The return value is the number of records or 0 if the object does not connect to any database file.</p>
</dd>
<dt><strong><a name="fsiz" class="item">$hdb-&gt;fsiz()</a></strong></dt>

<dd>
<p>Get the size of the database file.
<br />The return value is the size of the database file or 0 if the object does not connect to any database file.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="tying_functions_of_tokyocabinet__hdb">Tying functions of TokyoCabinet::HDB</a></h2>
<dl>
<dt><strong><a name="tie" class="item">tie(%hash, &quot;TokyoCabinet::HDB&quot;, <em>path</em>, <em>omode</em>, <em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>, <em>rcnum</em>)</a></strong></dt>

<dd>
<p>Tie a hash variable to a hash database file.
<br />`<em>path</em>' specifies the path of the database file.
<br />`<em>omode</em>' specifies the connection mode: `TokyoCabinet::HDB::OWRITER' as a writer, `TokyoCabinet::HDB::OREADER' as a reader.  If the mode is `TokyoCabinet::HDB::OWRITER', the following may be added by bitwise-or: `TokyoCabinet::HDB::OCREAT', which means it creates a new database if not exist, `TokyoCabinet::HDB::OTRUNC', which means it creates a new database regardless if one exists, `TokyoCabinet::HDB::OTSYNC', which means every transaction synchronizes updated contents with the device.  Both of `TokyoCabinet::HDB::OREADER' and `TokyoCabinet::HDB::OWRITER' can be added to by bitwise-or: `TokyoCabinet::HDB::ONOLCK', which means it opens the database file without file locking, or `TokyoCabinet::HDB::OLCKNB', which means locking is performed without blocking.  If it is not defined, `TokyoCabinet::HDB::OREADER' is specified.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is 131071.  Suggested size of the bucket array is about from 0.5 to 4 times of the number of all records to be stored.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 4 standing for 2^4=16.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 10 standing for 2^10=1024.
<br />`<em>opts</em>' specifies options by bitwise-or: `TokyoCabinet::HDB::TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `TokyoCabinet::HDB::TDEFLATE' specifies that each record is compressed with Deflate encoding, `TokyoCabinet::HDB::TBZIP' specifies that each record is compressed with BZIP2 encoding, `TokyoCabinet::HDB::TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined, no option is specified.
<br />`<em>rcnum</em>' specifies the maximum number of records to be cached.  If it is not defined or not more than 0, the record cache is disabled. It is disabled by default.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong><a name="untie" class="item">untie(%hash)</a></strong></dt>

<dd>
<p>Untie a hash variable from the database file.
<br />The return value is always true.</p>
</dd>
<dt><strong><a name="_hash_key_" class="item">$hash{<em>key</em>} = <em>value</em></a></strong></dt>

<dd>
<p>Store a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong><a name="delete" class="item">delete($hash{<em>key</em>})</a></strong></dt>

<dd>
<p>Remove a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$hash{<em>key</em>}</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the value of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong><a name="exists" class="item">exists($hash{<em>key</em>})</a></strong></dt>

<dd>
<p>Check whether a record corrsponding a key exists.
<br />`<em>key</em>' specifies the key.
<br />The return value is true if the record exists, else it is false.</p>
</dd>
<dt><strong><a name="_hash" class="item">$hash = ()</a></strong></dt>

<dd>
<p>Remove all records.
<br />The return value is always `undef'.</p>
</dd>
<dt><strong><a name="the_iterator" class="item">(the iterator)</a></strong></dt>

<dd>
<p>The inner methods `FIRSTKEY' and `NEXTKEY' are also implemented so that you can use the tying functions `each', `keys', and so on.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="class_tokyocabinet__bdb">Class TokyoCabinet::BDB</a></h2>
<p>B+ tree database is a file containing a B+ tree and is handled with the B+ tree database API.  Before operations to store or retrieve records, it is necessary to open a database file and connect the B+ tree database object to it.  The method `open' is used to open a database file and the method `close' is used to close the database file.  To avoid data missing or corruption, it is important to close every database file when it is no longer in use.  It is forbidden for multible database objects in a process to open the same database at the same time.</p>
<dl>
<dt><strong>$bdb = TokyoCabinet::BDB-&gt;new()</strong></dt>

<dd>
<p>Create a B+ tree database object.
<br />The return value is the new B+ tree database object.</p>
</dd>
<dt><strong>$bdb-&gt;errmsg(<em>ecode</em>)</strong></dt>

<dd>
<p>Get the message string corresponding to an error code.
<br />`<em>ecode</em>' specifies the error code.  If it is not defined or negative, the last happened error code is specified.
<br />The return value is the message string of the error code.</p>
</dd>
<dt><strong>$bdb-&gt;ecode()</strong></dt>

<dd>
<p>Get the last happened error code.
<br />The return value is the last happened error code.
<br />The following error codes are defined: `$bdb-&gt;ESUCCESS' for success, `$bdb-&gt;ETHREAD' for threading error, `$bdb-&gt;EINVALID' for invalid operation, `$bdb-&gt;ENOFILE' for file not found, `$bdb-&gt;ENOPERM' for no permission, `$bdb-&gt;EMETA' for invalid meta data, `$bdb-&gt;ERHEAD' for invalid record header, `$bdb-&gt;EOPEN' for open error, `$bdb-&gt;ECLOSE' for close error, `$bdb-&gt;ETRUNC' for trunc error, `$bdb-&gt;ESYNC' for sync error, `$bdb-&gt;ESTAT' for stat error, `$bdb-&gt;ESEEK' for seek error, `$bdb-&gt;EREAD' for read error, `$bdb-&gt;EWRITE' for write error, `$bdb-&gt;EMMAP' for mmap error, `$bdb-&gt;ELOCK' for lock error, `$bdb-&gt;EUNLINK' for unlink error, `$bdb-&gt;ERENAME' for rename error, `$bdb-&gt;EMKDIR' for mkdir error, `$bdb-&gt;ERMDIR' for rmdir error, `$bdb-&gt;EKEEP' for existing record, `$bdb-&gt;ENOREC' for no record found, and `$bdb-&gt;EMISC' for miscellaneous error.</p>
</dd>
<dt><strong><a name="setcmpfunc" class="item">$bdb-&gt;setcmpfunc(<em>cmp</em>)</a></strong></dt>

<dd>
<p>Set the custom comparison function.
<br />`<em>cmp</em>' specifies the custom comparison function.  It can be either the reference of a block or the name of a function.
<br />If successful, the return value is true, else, it is false.
<br />The default comparison function compares keys of two records by lexical order.  The constants `$bdb-&gt;CMPLEXICAL' (dafault), `$bdb-&gt;CMPDECIMAL', `$bdb-&gt;CMPINT32', and `$bdb-&gt;CMPINT64' are built-in.  Note that the comparison function should be set before the database is opened.  Moreover, user-defined comparison functions should be set every time the database is being opened.</p>
</dd>
<dt><strong>$bdb-&gt;tune(<em>lmemb</em>, <em>nmemb</em>, <em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>)</strong></dt>

<dd>
<p>Set the tuning parameters.
<br />`<em>lmemb</em>' specifies the number of members in each leaf page.  If it is not defined or not more than 0, the default value is specified.  The default value is 128.
<br />`<em>nmemb</em>' specifies the number of members in each non-leaf page.  If it is not defined or not more than 0, the default value is specified.  The default value is 256.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is 32749.  Suggested size of the bucket array is about from 1 to 4 times of the number of all pages to be stored.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 4 standing for 2^8=256.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 10 standing for 2^10=1024.
<br />`<em>opts</em>' specifies options by bitwise-or: `$bdb-&gt;TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `$bdb-&gt;TDEFLATE' specifies that each record is compressed with Deflate encoding, `$bdb-&gt;TBZIP' specifies that each record is compressed with BZIP2 encoding, `$bdb-&gt;TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined, no option is specified.
<br />If successful, the return value is true, else, it is false.  Note that the tuning parameters of the database should be set before the database is opened.</p>
</dd>
<dt><strong>$bdb-&gt;setcache(<em>lcnum</em>, <em>ncnum</em>)</strong></dt>

<dd>
<p>Set the caching parameters.
<br />`<em>lcnum</em>' specifies the maximum number of leaf nodes to be cached.  If it is not defined or not more than 0, the default value is specified.  The default value is 1024.
<br />`<em>ncnum</em>' specifies the maximum number of non-leaf nodes to be cached.  If it is not defined or not more than 0, the default value is specified.  The default value is 512.
<br />If successful, the return value is true, else, it is false.
<br />Note that the caching parameters of the database should be set before the database is opened.</p>
</dd>
<dt><strong>$bdb-&gt;setxmsiz(<em>xmsiz</em>)</strong></dt>

<dd>
<p>Set the size of the extra mapped memory.
<br />`<em>xmsiz</em>' specifies the size of the extra mapped memory.  If it is not defined or not more than 0, the extra mapped memory is disabled.  It is disabled by default.
<br />If successful, the return value is true, else, it is false.
<br />Note that the mapping parameters should be set before the database is opened.</p>
</dd>
<dt><strong>$bdb-&gt;setdfunit(<em>dfunit</em>)</strong></dt>

<dd>
<p>Set the unit step number of auto defragmentation.
<br />`<em>dfunit</em>' specifie the unit step number.  If it is not more than 0, the auto defragmentation is disabled.  It is disabled by default.
<br />If successful, the return value is true, else, it is false.
<br />Note that the defragmentation parameters should be set before the database is opened.</p>
</dd>
<dt><strong>$bdb-&gt;open(<em>path</em>, <em>omode</em>)</strong></dt>

<dd>
<p>Open a database file.
<br />`<em>path</em>' specifies the path of the database file.
<br />`<em>omode</em>' specifies the connection mode: `$bdb-&gt;OWRITER' as a writer, `$bdb-&gt;OREADER' as a reader.  If the mode is `$bdb-&gt;OWRITER', the following may be added by bitwise-or: `$bdb-&gt;OCREAT', which means it creates a new database if not exist, `$bdb-&gt;OTRUNC', which means it creates a new database regardless if one exists, `$bdb-&gt;OTSYNC', which means every transaction synchronizes updated contents with the device.  Both of `$bdb-&gt;OREADER' and `$bdb-&gt;OWRITER' can be added to by bitwise-or: `$bdb-&gt;ONOLCK', which means it opens the database file without file locking, or `$bdb-&gt;OLCKNB', which means locking is performed without blocking.  If it is not defined, `$bdb-&gt;OREADER' is specified.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$bdb-&gt;close()</strong></dt>

<dd>
<p>Close the database file.
<br />If successful, the return value is true, else, it is false.
<br />Update of a database is assured to be written when the database is closed.  If a writer opens a database but does not close it appropriately, the database will be broken.</p>
</dd>
<dt><strong>$bdb-&gt;put(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Store a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong>$bdb-&gt;putkeep(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Store a new record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, this method has no effect.</p>
</dd>
<dt><strong>$bdb-&gt;putcat(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Concatenate a value at the end of the existing record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If there is no corresponding record, a new record is created.</p>
</dd>
<dt><strong><a name="putdup" class="item">$bdb-&gt;putdup(<em>key</em>, <em>value</em>)</a></strong></dt>

<dd>
<p>Store a record with allowing duplication of keys.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, the new record is placed after the existing one.</p>
</dd>
<dt><strong><a name="putlist" class="item">$bdb-&gt;putlist(<em>key</em>, <em>values</em>)</a></strong></dt>

<dd>
<p>Store records with allowing duplication of keys.
<br />`<em>key</em>' specifies the key.
<br />`<em>values</em>' specifies the reference to an array of the values.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, the new records are placed after the existing one.</p>
</dd>
<dt><strong>$bdb-&gt;out(<em>key</em>)</strong></dt>

<dd>
<p>Remove a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is true, else, it is false.
<br />If the key of duplicated records is specified, the first one is selected.</p>
</dd>
<dt><strong><a name="outlist" class="item">$bdb-&gt;outlist(<em>key</em>)</a></strong></dt>

<dd>
<p>Remove records.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is true, else, it is false.
<br />If the key of duplicated records is specified, all of them are removed.</p>
</dd>
<dt><strong>$bdb-&gt;get(<em>key</em>)</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the value of the corresponding record.  `undef' is returned if no record corresponds.
<br />If the key of duplicated records is specified, the first one is selected.</p>
</dd>
<dt><strong><a name="getlist" class="item">$bdb-&gt;getlist(<em>key</em>)</a></strong></dt>

<dd>
<p>Retrieve records.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the reference to an array of the values of the corresponding records.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong><a name="vnum" class="item">$bdb-&gt;vnum(<em>key</em>)</a></strong></dt>

<dd>
<p>Get the number of records corresponding a key.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the number of the corresponding records, else, it is 0.</p>
</dd>
<dt><strong>$bdb-&gt;vsiz(<em>key</em>)</strong></dt>

<dd>
<p>Get the size of the value of a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the size of the value of the corresponding record, else, it is -1.
<br />If the key of duplicated records is specified, the first one is selected.</p>
</dd>
<dt><strong><a name="range" class="item">$bdb-&gt;range(<em>bkey</em>, <em>binc</em>, <em>ekey</em>, <em>einc</em>, <em>max</em>)</a></strong></dt>

<dd>
<p>Get keys of ranged records.
<br />`<em>bkey</em>' specifies the key of the beginning border. If it is not defined, the first record is specified.
<br />`<em>binc</em>' specifies whether the beginning border is inclusive or not.  If it is not defined, false is specified.
<br />`<em>ekey</em>' specifies the key of the ending border. If it is not defined, the last record is specified.
<br />`<em>einc</em>' specifies whether the ending border is inclusive or not.  If it is not defined, false is specified.
<br />`<em>max</em>' specifies the maximum number of keys to be fetched.  If it is not defined or negative, no limit is specified.
<br />The return value is the reference to an array of the keys of the corresponding records.  This method does never fail.  It returns an empty array even if no record corresponds.</p>
</dd>
<dt><strong>$bdb-&gt;fwmkeys(<em>prefix</em>, <em>max</em>)</strong></dt>

<dd>
<p>Get forward matching keys.
<br />`<em>prefix</em>' specifies the prefix of the corresponding keys.
<br />`<em>max</em>' specifies the maximum number of keys to be fetched.  If it is not defined or negative, no limit is specified.
<br />The return value is the reference to an array of the keys of the corresponding records.  This method does never fail.  It returns an empty array even if no record corresponds.</p>
</dd>
<dt><strong>$bdb-&gt;addint(<em>key</em>, <em>num</em>)</strong></dt>

<dd>
<p>Add an integer to a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />If the corresponding record exists, the value is treated as an integer and is added to.  If no record corresponds, a new record of the additional value is stored.  Because records are stored in binary format, they should be processed with the `unpack' function with the `i' operator after retrieval.</p>
</dd>
<dt><strong>$bdb-&gt;adddouble(<em>key</em>, <em>num</em>)</strong></dt>

<dd>
<p>Add a real number to a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />If the corresponding record exists, the value is treated as a real number and is added to.  If no record corresponds, a new record of the additional value is stored.  Because records are stored in binary format, they should be processed with the `unpack' function with the `d' operator after retrieval.</p>
</dd>
<dt><strong>$bdb-&gt;sync()</strong></dt>

<dd>
<p>Synchronize updated contents with the file and the device.
<br />If successful, the return value is true, else, it is false.
<br />This method is useful when another process connects the same database file.</p>
</dd>
<dt><strong>$bdb-&gt;optimize(<em>lmemb</em>, <em>nmemb</em>, <em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>)</strong></dt>

<dd>
<p>Optimize the database file.
<br />`<em>lmemb</em>' specifies the number of members in each leaf page.  If it is not defined or not more than 0, the current setting is not changed.
<br />`<em>nmemb</em>' specifies the number of members in each non-leaf page.  If it is not defined or not more than 0, the current setting is not changed.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is two times of the number of pages.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the current setting is not changed.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the current setting is not changed.
<br />`<em>opts</em>' specifies options by bitwise-or: `$bdb-&gt;TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `$bdb-&gt;TDEFLATE' specifies that each record is compressed with Deflate encoding, `$bdb-&gt;TBZIP' specifies that each record is compressed with BZIP2 encoding, `$bdb-&gt;TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined or 0xff, the current setting is not changed.
<br />If successful, the return value is true, else, it is false.
<br />This method is useful to reduce the size of the database file with data fragmentation by successive updating.</p>
</dd>
<dt><strong>$bdb-&gt;vanish()</strong></dt>

<dd>
<p>Remove all records.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$bdb-&gt;copy(<em>path</em>)</strong></dt>

<dd>
<p>Copy the database file.
<br />`<em>path</em>' specifies the path of the destination file.  If it begins with `@', the trailing substring is executed as a command line.
<br />If successful, the return value is true, else, it is false.  False is returned if the executed command returns non-zero code.
<br />The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress.  So, this method is useful to create a backup file of the database file.</p>
</dd>
<dt><strong>$bdb-&gt;tranbegin()</strong></dt>

<dd>
<p>Begin the transaction.
<br />If successful, the return value is true, else, it is false.
<br />The database is locked by the thread while the transaction so that only one transaction can be activated with a database object at the same time.  Thus, the serializable isolation level is assumed if every database operation is performed in the transaction.  Because all pages are cached on memory while the transaction, the amount of referred records is limited by the memory capacity.  If the database is closed during transaction, the transaction is aborted implicitly.</p>
</dd>
<dt><strong>$bdb-&gt;trancommit()</strong></dt>

<dd>
<p>Commit the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is fixed when it is committed successfully.</p>
</dd>
<dt><strong>$bdb-&gt;tranabort()</strong></dt>

<dd>
<p>Abort the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is discarded when it is aborted.  The state of the database is rollbacked to before transaction.</p>
</dd>
<dt><strong>$bdb-&gt;path()</strong></dt>

<dd>
<p>Get the path of the database file.
<br />The return value is the path of the database file or `undef' if the object does not connect to any database file.</p>
</dd>
<dt><strong>$bdb-&gt;rnum()</strong></dt>

<dd>
<p>Get the number of records.
<br />The return value is the number of records or 0 if the object does not connect to any database file.</p>
</dd>
<dt><strong>$bdb-&gt;fsiz()</strong></dt>

<dd>
<p>Get the size of the database file.
<br />The return value is the size of the database file or 0 if the object does not connect to any database file.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="class_tokyocabinet__bdbcur">Class TokyoCabinet::BDBCUR</a></h2>
<dl>
<dt><strong>$cur = TokyoCabinet::BDBCUR-&gt;new(<em>bdb</em>)</strong></dt>

<dd>
<p>Create a cursor object.
<br />`<em>bdb</em>' specifies the B+ tree database object.
<br />The return value is the new cursor object.
<br />Note that the cursor is available only after initialization with the `first' or the `jump' methods and so on.  Moreover, the position of the cursor will be indefinite when the database is updated after the initialization of the cursor.</p>
</dd>
<dt><strong><a name="first" class="item">$cur-&gt;first()</a></strong></dt>

<dd>
<p>Move the cursor to the first record.
<br />If successful, the return value is true, else, it is false.  False is returned if there is no record in the database.</p>
</dd>
<dt><strong><a name="last" class="item">$cur-&gt;last()</a></strong></dt>

<dd>
<p>Move the cursor to the last record.
<br />If successful, the return value is true, else, it is false.  False is returned if there is no record in the database.</p>
</dd>
<dt><strong><a name="jump" class="item">$cur-&gt;jump(<em>key</em>)</a></strong></dt>

<dd>
<p>Move the cursor to the front of records corresponding a key.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is true, else, it is false.  False is returned if there is no record corresponding the condition.
<br />The cursor is set to the first record corresponding the key or the next substitute if completely matching record does not exist.</p>
</dd>
<dt><strong><a name="prev" class="item">$cur-&gt;prev()</a></strong></dt>

<dd>
<p>Move the cursor to the previous record.
<br />If successful, the return value is true, else, it is false.  False is returned if there is no previous record.</p>
</dd>
<dt><strong><a name="next" class="item">$cur-&gt;next()</a></strong></dt>

<dd>
<p>Move the cursor to the next record.
<br />If successful, the return value is true, else, it is false.  False is returned if there is no next record.</p>
</dd>
<dt><strong>$cur-&gt;put(<em>value</em>, <em>cpmode</em>)</strong></dt>

<dd>
<p>Insert a record around the cursor.
<br />`<em>value</em>' specifies the value.
<br />`<em>cpmode</em>' specifies detail adjustment: `$cur-&gt;CPCURRENT', which means that the value of the current record is overwritten, `$cur-&gt;CPBEFORE', which means that the new record is inserted before the current record, `$cur-&gt;CPAFTER', which means that the new record is inserted after the current record.
<br />If successful, the return value is true, else, it is false.  False is returned when the cursor is at invalid position.
<br />After insertion, the cursor is moved to the inserted record.</p>
</dd>
<dt><strong>$cur-&gt;out()</strong></dt>

<dd>
<p>Remove the record where the cursor is.
<br />If successful, the return value is true, else, it is false.  False is returned when the cursor is at invalid position.
<br />After deletion, the cursor is moved to the next record if possible.</p>
</dd>
<dt><strong><a name="key" class="item">$cur-&gt;key()</a></strong></dt>

<dd>
<p>Get the key of the record where the cursor is.
<br />If successful, the return value is the key, else, it is `undef'.  'undef' is returned when the cursor is at invalid position.</p>
</dd>
<dt><strong><a name="val" class="item">$cur-&gt;val()</a></strong></dt>

<dd>
<p>Get the value of the record where the cursor is.
<br />If successful, the return value is the value, else, it is `undef'.  'undef' is returned when the cursor is at invalid position.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="tying_functions_of_tokyocabinet__bdb">Tying functions of TokyoCabinet::BDB</a></h2>
<dl>
<dt><strong>tie(%hash, &quot;TokyoCabinet::BDB&quot;, <em>path</em>, <em>omode</em>, <em>lmemb</em>, <em>nmemb</em>, <em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>, <em>lcnum</em>, <em>ncnum</em>)</strong></dt>

<dd>
<p>Tie a hash variable to a B+ tree database file.
<br />`<em>path</em>' specifies the path of the database file.
<br />`<em>omode</em>' specifies the connection mode: `TokyoCabinet::BDB::OWRITER' as a writer, `TokyoCabinet::BDB::OREADER' as a reader.  If the mode is `TokyoCabinet::BDB::OWRITER', the following may be added by bitwise-or: `TokyoCabinet::BDB::OCREAT', which means it creates a new database if not exist, `TokyoCabinet::BDB::OTRUNC', which means it creates a new database regardless if one exists, `TokyoCabinet::BDB::OTSYNC', which means every transaction synchronizes updated contents with the device.  Both of `TokyoCabinet::BDB::OREADER' and `TokyoCabinet::BDB::OWRITER' can be added to by bitwise-or: `TokyoCabinet::BDB::ONOLCK', which means it opens the database file without file locking, or `TokyoCabinet::BDB::OLCKNB', which means locking is performed without blocking.  If it is not defined, `TokyoCabinet::BDB::OREADER' is specified.
<br />`<em>lmemb</em>' specifies the number of members in each leaf page.  If it is not defined or not more than 0, the default value is specified.  The default value is 128.
<br />`<em>nmemb</em>' specifies the number of members in each non-leaf page.  If it is not defined or not more than 0, the default value is specified.  The default value is 256.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is 32749.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 4 standing for 2^8=256.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 10 standing for 2^10=1024.
<br />`<em>opts</em>' specifies options by bitwise-or: `TokyoCabinet::BDB::TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `TokyoCabinet::BDB::TDEFLATE' specifies that each record is compressed with Deflate encoding, `TokyoCabinet::BDB::TBZIP' specifies that each record is compressed with BZIP2 encoding, `TokyoCabinet::BDB::TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined, no option is specified.
<br />`<em>lcnum</em>' specifies the maximum number of leaf nodes to be cached.  If it is not defined or not more than 0, the default value is specified.
<br />`<em>ncnum</em>' specifies the maximum number of non-leaf nodes to be cached.  If it is not defined or not more than 0, the default value is specified.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>untie(%hash)</strong></dt>

<dd>
<p>Untie a hash variable from the database file.
<br />The return value is always true.</p>
</dd>
<dt><strong>$hash{<em>key</em>} = <em>value</em></strong></dt>

<dd>
<p>Store a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong>delete($hash{<em>key</em>})</strong></dt>

<dd>
<p>Remove a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$hash{<em>key</em>}</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the value of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong>exists($hash{<em>key</em>})</strong></dt>

<dd>
<p>Check whether a record corrsponding a key exists.
<br />`<em>key</em>' specifies the key.
<br />The return value is true if the record exists, else it is false.</p>
</dd>
<dt><strong>$hash = ()</strong></dt>

<dd>
<p>Remove all records.
<br />The return value is always `undef'.</p>
</dd>
<dt><strong><a name="the_iterator2" class="item">(the iterator)</a></strong></dt>

<dd>
<p>The inner methods `FIRSTKEY' and `NEXTKEY' are also implemented so that you can use the tying functions `each', `keys', and so on.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="class_tokyocabinet__fdb">Class TokyoCabinet::FDB</a></h2>
<p>Fixed-length database is a file containing an array of fixed-length elements and is handled with the fixed-length database API.  Before operations to store or retrieve records, it is necessary to open a database file and connect the fixed-length database object to it.  The method `open' is used to open a database file and the method `close' is used to close the database file.  To avoid data missing or corruption, it is important to close every database file when it is no longer in use.  It is forbidden for multible database objects in a process to open the same database at the same time.</p>
<dl>
<dt><strong>$fdb = TokyoCabinet::FDB-&gt;new()</strong></dt>

<dd>
<p>Create a fixed-length database object.
<br />The return value is the new fixed-length database object.</p>
</dd>
<dt><strong>$fdb-&gt;errmsg(<em>ecode</em>)</strong></dt>

<dd>
<p>Get the message string corresponding to an error code.
<br />`<em>ecode</em>' specifies the error code.  If it is not defined or negative, the last happened error code is specified.
<br />The return value is the message string of the error code.</p>
</dd>
<dt><strong>$fdb-&gt;ecode()</strong></dt>

<dd>
<p>Get the last happened error code.
<br />The return value is the last happened error code.
<br />The following error codes are defined: `$fdb-&gt;ESUCCESS' for success, `$fdb-&gt;ETHREAD' for threading error, `$fdb-&gt;EINVALID' for invalid operation, `$fdb-&gt;ENOFILE' for file not found, `$fdb-&gt;ENOPERM' for no permission, `$fdb-&gt;EMETA' for invalid meta data, `$fdb-&gt;ERHEAD' for invalid record header, `$fdb-&gt;EOPEN' for open error, `$fdb-&gt;ECLOSE' for close error, `$fdb-&gt;ETRUNC' for trunc error, `$fdb-&gt;ESYNC' for sync error, `$fdb-&gt;ESTAT' for stat error, `$fdb-&gt;ESEEK' for seek error, `$fdb-&gt;EREAD' for read error, `$fdb-&gt;EWRITE' for write error, `$fdb-&gt;EMMAP' for mmap error, `$fdb-&gt;ELOCK' for lock error, `$fdb-&gt;EUNLINK' for unlink error, `$fdb-&gt;ERENAME' for rename error, `$fdb-&gt;EMKDIR' for mkdir error, `$fdb-&gt;ERMDIR' for rmdir error, `$fdb-&gt;EKEEP' for existing record, `$fdb-&gt;ENOREC' for no record found, and `$fdb-&gt;EMISC' for miscellaneous error.</p>
</dd>
<dt><strong>$fdb-&gt;tune(<em>width</em>, <em>limsiz</em>);</strong></dt>

<dd>
<p>Set the tuning parameters.
<br />`<em>width</em>' specifies the width of the value of each record.  If it is not defined or not more than 0, the default value is specified.  The default value is 255.
<br />`<em>limsiz</em>' specifies the limit size of the database file.  If it is not defined or not more than 0, the default value is specified.  The default value is 268435456.
<br />If successful, the return value is true, else, it is false.  Note that the tuning parameters of the database should be set before the database is opened.</p>
</dd>
<dt><strong>$fdb-&gt;open(<em>path</em>, <em>omode</em>)</strong></dt>

<dd>
<p>Open a database file.
<br />`<em>path</em>' specifies the path of the database file.
<br />`<em>omode</em>' specifies the connection mode: `$fdb-&gt;OWRITER' as a writer, `$fdb-&gt;OREADER' as a reader.  If the mode is `$fdb-&gt;OWRITER', the following may be added by bitwise-or: `$fdb-&gt;OCREAT', which means it creates a new database if not exist, `$fdb-&gt;OTRUNC', which means it creates a new database regardless if one exists.  Both of `$fdb-&gt;OREADER' and `$fdb-&gt;OWRITER' can be added to by bitwise-or: `$fdb-&gt;ONOLCK', which means it opens the database file without file locking, or `$fdb-&gt;OLCKNB', which means locking is performed without blocking.  If it is not defined, `$fdb-&gt;OREADER' is specified.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$fdb-&gt;close()</strong></dt>

<dd>
<p>Close the database file.
<br />If successful, the return value is true, else, it is false.
<br />Update of a database is assured to be written when the database is closed.  If a writer opens a database but does not close it appropriately, the database will be broken.</p>
</dd>
<dt><strong>$fdb-&gt;put(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Store a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;prev&quot;, the number less by one than the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.  If it is &quot;next&quot;, the number greater by one than the maximum ID number of existing records is specified.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong>$fdb-&gt;putkeep(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Store a new record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;prev&quot;, the number less by one than the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.  If it is &quot;next&quot;, the number greater by one than the maximum ID number of existing records is specified.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, this method has no effect.</p>
</dd>
<dt><strong>$fdb-&gt;putcat(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Concatenate a value at the end of the existing record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;prev&quot;, the number less by one than the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.  If it is &quot;next&quot;, the number greater by one than the maximum ID number of existing records is specified.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If there is no corresponding record, a new record is created.</p>
</dd>
<dt><strong>$fdb-&gt;out(<em>key</em>)</strong></dt>

<dd>
<p>Remove a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$fdb-&gt;get(<em>key</em>)</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.
<br />If successful, the return value is the value of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong>$fdb-&gt;vsiz(<em>key</em>)</strong></dt>

<dd>
<p>Get the size of the value of a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.
<br />If successful, the return value is the size of the value of the corresponding record, else, it is -1.</p>
</dd>
<dt><strong>$fdb-&gt;iterinit()</strong></dt>

<dd>
<p>Initialize the iterator.
<br />If successful, the return value is true, else, it is false.
<br />The iterator is used in order to access the key of every record stored in a database.</p>
</dd>
<dt><strong>$fdb-&gt;iternext()</strong></dt>

<dd>
<p>Get the next key of the iterator.
<br />If successful, the return value is the next key, else, it is `undef'.  `undef' is returned when no record is to be get out of the iterator.
<br />It is possible to access every record by iteration of calling this method.  It is allowed to update or remove records whose keys are fetched while the iteration.  The order of this traversal access method is ascending of the ID number.</p>
</dd>
<dt><strong>$fdb-&gt;range(<em>interval</em>, <em>max</em>)</strong></dt>

<dd>
<p>Get keys with an interval notation.
<br />`<em>interval</em>' specifies the interval notation.
<br />`<em>max</em>' specifies the maximum number of keys to be fetched.  If it is not defined or negative, no limit is specified.
<br />The return value is the reference to an array of the keys of the corresponding records.  This method does never fail.  It returns an empty array even if no record corresponds.</p>
</dd>
<dt><strong>$fdb-&gt;addint(<em>key</em>, <em>num</em>)</strong></dt>

<dd>
<p>Add an integer to a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;prev&quot;, the number less by one than the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.  If it is &quot;next&quot;, the number greater by one than the maximum ID number of existing records is specified.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />If the corresponding record exists, the value is treated as an integer and is added to.  If no record corresponds, a new record of the additional value is stored.  Because records are stored in binary format, they should be processed with the `unpack' function with the `i' operator after retrieval.</p>
</dd>
<dt><strong>$fdb-&gt;adddouble(<em>key</em>, <em>num</em>)</strong></dt>

<dd>
<p>Add a real number to a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;prev&quot;, the number less by one than the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.  If it is &quot;next&quot;, the number greater by one than the maximum ID number of existing records is specified.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />If the corresponding record exists, the value is treated as a real number and is added to.  If no record corresponds, a new record of the additional value is stored.  Because records are stored in binary format, they should be processed with the `unpack' function with the `d' operator after retrieval.</p>
</dd>
<dt><strong>$fdb-&gt;sync()</strong></dt>

<dd>
<p>Synchronize updated contents with the file and the device.
<br />If successful, the return value is true, else, it is false.
<br />This method is useful when another process connects the same database file.</p>
</dd>
<dt><strong>$fdb-&gt;optimize(<em>width</em>, <em>limsiz</em>)</strong></dt>

<dd>
<p>Optimize the database file.
<br />`<em>width</em>' specifies the width of the value of each record.  If it is not defined or not more than 0, the current setting is not changed.
<br />`<em>limsiz</em>' specifies the limit size of the database file.  If it is not defined or not more than 0, the current setting is not changed.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$fdb-&gt;vanish()</strong></dt>

<dd>
<p>Remove all records.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$fdb-&gt;copy(<em>path</em>)</strong></dt>

<dd>
<p>Copy the database file.
<br />`<em>path</em>' specifies the path of the destination file.  If it begins with `@', the trailing substring is executed as a command line.
<br />If successful, the return value is true, else, it is false.  False is returned if the executed command returns non-zero code.
<br />The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress.  So, this method is useful to create a backup file of the database file.</p>
</dd>
<dt><strong>$fdb-&gt;tranbegin()</strong></dt>

<dd>
<p>Begin the transaction.
<br />If successful, the return value is true, else, it is false.
<br />The database is locked by the thread while the transaction so that only one transaction can be activated with a database object at the same time.  Thus, the serializable isolation level is assumed if every database operation is performed in the transaction.  All updated regions are kept track of by write ahead logging while the transaction.  If the database is closed during transaction, the transaction is aborted implicitly.</p>
</dd>
<dt><strong>$fdb-&gt;trancommit()</strong></dt>

<dd>
<p>Commit the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is fixed when it is committed successfully.</p>
</dd>
<dt><strong>$fdb-&gt;tranabort()</strong></dt>

<dd>
<p>Abort the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is discarded when it is aborted.  The state of the database is rollbacked to before transaction.</p>
</dd>
<dt><strong>$fdb-&gt;path()</strong></dt>

<dd>
<p>Get the path of the database file.
<br />The return value is the path of the database file or `undef' if the object does not connect to any database file.</p>
</dd>
<dt><strong>$fdb-&gt;rnum()</strong></dt>

<dd>
<p>Get the number of records.
<br />The return value is the number of records or 0 if the object does not connect to any database file.</p>
</dd>
<dt><strong>$fdb-&gt;fsiz()</strong></dt>

<dd>
<p>Get the size of the database file.
<br />The return value is the size of the database file or 0 if the object does not connect to any database file.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="tying_functions_of_tokyocabinet__fdb">Tying functions of TokyoCabinet::FDB</a></h2>
<dl>
<dt><strong>tie(%hash, &quot;TokyoCabinet::FDB&quot;, <em>path</em>, <em>omode</em>, <em>width</em>, <em>limsiz</em>)</strong></dt>

<dd>
<p>Tie a hash variable to a hash database file.
<br />`<em>path</em>' specifies the path of the database file.
<br />`<em>omode</em>' specifies the connection mode: `TokyoCabinet::FDB::OWRITER' as a writer, `TokyoCabinet::FDB::OREADER' as a reader.  If the mode is `TokyoCabinet::FDB::OWRITER', the following may be added by bitwise-or: `TokyoCabinet::FDB::OCREAT', which means it creates a new database if not exist, `TokyoCabinet::FDB::OTRUNC', which means it creates a new database regardless if one exists.  Both of `TokyoCabinet::FDB::OREADER' and `TokyoCabinet::FDB::OWRITER' can be added to by bitwise-or: `TokyoCabinet::FDB::ONOLCK', which means it opens the database file without file locking, or `TokyoCabinet::FDB::OLCKNB', which means locking is performed without blocking.  If it is not defined, `TokyoCabinet::FDB::OREADER' is specified.
<br />`<em>width</em>' specifies the width of the value of each record.  If it is not defined or not more than 0, the default value is specified.  The default value is 255.
<br />`<em>limsiz</em>' specifies the limit size of the database file.  If it is not defined or not more than 0, the default value is specified.  The default value is 268435456.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>untie(%hash)</strong></dt>

<dd>
<p>Untie a hash variable from the database file.
<br />The return value is always true.</p>
</dd>
<dt><strong>$hash{<em>key</em>} = <em>value</em></strong></dt>

<dd>
<p>Store a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;prev&quot;, the number less by one than the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.  If it is &quot;next&quot;, the number greater by one than the maximum ID number of existing records is specified.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong>delete($hash{<em>key</em>})</strong></dt>

<dd>
<p>Remove a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$hash{<em>key</em>}</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.
<br />If successful, the return value is the value of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong>exists($hash{<em>key</em>})</strong></dt>

<dd>
<p>Check whether a record corrsponding a key exists.
<br />`<em>key</em>' specifies the key.  It should be more than 0.  If it is &quot;min&quot;, the minimum ID number of existing records is specified.  If it is &quot;max&quot;, the maximum ID number of existing records is specified.
<br />The return value is true if the record exists, else it is false.</p>
</dd>
<dt><strong>$hash = ()</strong></dt>

<dd>
<p>Remove all records.
<br />The return value is always `undef'.</p>
</dd>
<dt><strong><a name="the_iterator3" class="item">(the iterator)</a></strong></dt>

<dd>
<p>The inner methods `FIRSTKEY' and `NEXTKEY' are also implemented so that you can use the tying functions `each', `keys', and so on.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="class_tokyocabinet__tdb">Class TokyoCabinet::TDB</a></h2>
<p>Table database is a file containing records composed of the primary keys and arbitrary columns and is handled with the table database API.  Before operations to store or retrieve records, it is necessary to open a database file and connect the table database object to it.  The method `open' is used to open a database file and the method `close' is used to close the database file.  To avoid data missing or corruption, it is important to close every database file when it is no longer in use.  It is forbidden for multible database objects in a process to open the same database at the same time.</p>
<dl>
<dt><strong>$tdb = TokyoCabinet::TDB-&gt;new()</strong></dt>

<dd>
<p>Create a table database object.
<br />The return value is the new table database object.</p>
</dd>
<dt><strong>$tdb-&gt;errmsg(<em>ecode</em>)</strong></dt>

<dd>
<p>Get the message string corresponding to an error code.
<br />`<em>ecode</em>' specifies the error code.  If it is not defined or negative, the last happened error code is specified.
<br />The return value is the message string of the error code.</p>
</dd>
<dt><strong>$tdb-&gt;ecode()</strong></dt>

<dd>
<p>Get the last happened error code.
<br />The return value is the last happened error code.
<br />The following error codes are defined: `$tdb-&gt;ESUCCESS' for success, `$tdb-&gt;ETHREAD' for threading error, `$tdb-&gt;EINVALID' for invalid operation, `$tdb-&gt;ENOFILE' for file not found, `$tdb-&gt;ENOPERM' for no permission, `$tdb-&gt;EMETA' for invalid meta data, `$tdb-&gt;ERHEAD' for invalid record header, `$tdb-&gt;EOPEN' for open error, `$tdb-&gt;ECLOSE' for close error, `$tdb-&gt;ETRUNC' for trunc error, `$tdb-&gt;ESYNC' for sync error, `$tdb-&gt;ESTAT' for stat error, `$tdb-&gt;ESEEK' for seek error, `$tdb-&gt;EREAD' for read error, `$tdb-&gt;EWRITE' for write error, `$tdb-&gt;EMMAP' for mmap error, `$tdb-&gt;ELOCK' for lock error, `$tdb-&gt;EUNLINK' for unlink error, `$tdb-&gt;ERENAME' for rename error, `$tdb-&gt;EMKDIR' for mkdir error, `$tdb-&gt;ERMDIR' for rmdir error, `$tdb-&gt;EKEEP' for existing record, `$tdb-&gt;ENOREC' for no record found, and `$tdb-&gt;EMISC' for miscellaneous error.</p>
</dd>
<dt><strong>$tdb-&gt;tune(<em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>)</strong></dt>

<dd>
<p>Set the tuning parameters.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is 131071.  Suggested size of the bucket array is about from 0.5 to 4 times of the number of all records to be stored.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 4 standing for 2^4=16.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 10 standing for 2^10=1024.
<br />`<em>opts</em>' specifies options by bitwise-or: `$tdb-&gt;TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `$tdb-&gt;TDEFLATE' specifies that each record is compressed with Deflate encoding, `$tdb-&gt;TBZIP' specifies that each record is compressed with BZIP2 encoding, `$tdb-&gt;TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined, no option is specified.
<br />If successful, the return value is true, else, it is false.  Note that the tuning parameters of the database should be set before the database is opened.</p>
</dd>
<dt><strong>$tdb-&gt;setcache(<em>rcnum</em>, <em>lcnum</em>, <em>ncnum</em>)</strong></dt>

<dd>
<p>Set the caching parameters.
<br />`<em>rcnum</em>' specifies the maximum number of records to be cached.  If it is not defined or not more than 0, the record cache is disabled. It is disabled by default.
<br />`<em>lcnum</em>' specifies the maximum number of leaf nodes to be cached.  If it is not defined or not more than 0, the default value is specified.  The default value is 4096.
<br />`<em>ncnum</em>' specifies the maximum number of non-leaf nodes to be cached.  If it is not defined or not more than 0, the default value is specified.  The default value is 512.
<br />If successful, the return value is true, else, it is false.
<br />Note that the caching parameters of the database should be set before the database is opened.</p>
</dd>
<dt><strong>$tdb-&gt;setxmsiz(<em>xmsiz</em>)</strong></dt>

<dd>
<p>Set the size of the extra mapped memory.
<br />`<em>xmsiz</em>' specifies the size of the extra mapped memory.  If it is not defined or not more than 0, the extra mapped memory is disabled.  The default size is 67108864.
<br />If successful, the return value is true, else, it is false.
<br />Note that the mapping parameters should be set before the database is opened.</p>
</dd>
<dt><strong>$tdb-&gt;setdfunit(<em>dfunit</em>)</strong></dt>

<dd>
<p>Set the unit step number of auto defragmentation.
<br />`<em>dfunit</em>' specifie the unit step number.  If it is not more than 0, the auto defragmentation is disabled.  It is disabled by default.
<br />If successful, the return value is true, else, it is false.
<br />Note that the defragmentation parameters should be set before the database is opened.</p>
</dd>
<dt><strong>$tdb-&gt;open(<em>path</em>, <em>omode</em>)</strong></dt>

<dd>
<p>Open a database file.
<br />`<em>path</em>' specifies the path of the database file.
<br />`<em>omode</em>' specifies the connection mode: `$tdb-&gt;OWRITER' as a writer, `$tdb-&gt;OREADER' as a reader.  If the mode is `$tdb-&gt;OWRITER', the following may be added by bitwise-or: `$tdb-&gt;OCREAT', which means it creates a new database if not exist, `$tdb-&gt;OTRUNC', which means it creates a new database regardless if one exists, `$tdb-&gt;OTSYNC', which means every transaction synchronizes updated contents with the device.  Both of `$tdb-&gt;OREADER' and `$tdb-&gt;OWRITER' can be added to by bitwise-or: `$tdb-&gt;ONOLCK', which means it opens the database file without file locking, or `$tdb-&gt;OLCKNB', which means locking is performed without blocking.  If it is not defined, `$tdb-&gt;OREADER' is specified.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$tdb-&gt;close()</strong></dt>

<dd>
<p>Close the database file.
<br />If successful, the return value is true, else, it is false.
<br />Update of a database is assured to be written when the database is closed.  If a writer opens a database but does not close it appropriately, the database will be broken.</p>
</dd>
<dt><strong>$tdb-&gt;put(<em>pkey</em>, <em>cols</em>)</strong></dt>

<dd>
<p>Store a record.
<br />`<em>pkey</em>' specifies the primary key.
<br />`<em>cols</em>' specifies the reference to a hash containing columns.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong>$tdb-&gt;putkeep(<em>pkey</em>, <em>cols</em>)</strong></dt>

<dd>
<p>Store a new record.
<br />`<em>pkey</em>' specifies the primary key.
<br />`<em>cols</em>' specifies the reference to a hash containing columns.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, this method has no effect.</p>
</dd>
<dt><strong>$tdb-&gt;putcat(<em>pkey</em>, <em>cols</em>)</strong></dt>

<dd>
<p>Concatenate columns of the existing record.
<br />`<em>pkey</em>' specifies the primary key.
<br />`<em>cols</em>' specifies the reference to a hash containing columns.
<br />If successful, the return value is true, else, it is false.
<br />If there is no corresponding record, a new record is created.</p>
</dd>
<dt><strong>$tdb-&gt;out(<em>pkey</em>)</strong></dt>

<dd>
<p>Remove a record.
<br />`<em>pkey</em>' specifies the primary key.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$tdb-&gt;get(<em>pkey</em>)</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>pkey</em>' specifies the primary key.
<br />If successful, the return value is the reference to a hash of the columns of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong>$tdb-&gt;vsiz(<em>pkey</em>)</strong></dt>

<dd>
<p>Get the size of the value of a record.
<br />`<em>pkey</em>' specifies the primary key.
<br />If successful, the return value is the size of the value of the corresponding record, else, it is -1.</p>
</dd>
<dt><strong>$tdb-&gt;iterinit()</strong></dt>

<dd>
<p>Initialize the iterator.
<br />If successful, the return value is true, else, it is false.
<br />The iterator is used in order to access the primary key of every record stored in a database.</p>
</dd>
<dt><strong>$tdb-&gt;iternext()</strong></dt>

<dd>
<p>Get the next primary key of the iterator.
<br />If successful, the return value is the next primary key, else, it is `undef'.  `undef' is returned when no record is to be get out of the iterator.
<br />It is possible to access every record by iteration of calling this method.  It is allowed to update or remove records whose keys are fetched while the iteration.  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.</p>
</dd>
<dt><strong>$tdb-&gt;fwmkeys(<em>prefix</em>, <em>max</em>)</strong></dt>

<dd>
<p>Get forward matching primary keys.
<br />`<em>prefix</em>' specifies the prefix of the corresponding keys.
<br />`<em>max</em>' specifies the maximum number of keys to be fetched.  If it is not defined or negative, no limit is specified.
<br />The return value is the reference to an array of the keys of the corresponding records.  This method does never fail.  It returns an empty array even if no record corresponds.
<br />Note that this method may be very slow because every key in the database is scanned.</p>
</dd>
<dt><strong>$tdb-&gt;addint(<em>pkey</em>, <em>num</em>)</strong></dt>

<dd>
<p>Add an integer to a record.
<br />`<em>pkey</em>' specifies primary key.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />The additional value is stored as a decimal string value of a column whose name is &quot;_num&quot;.  If no record corresponds, a new record with the additional value is stored.</p>
</dd>
<dt><strong>$tdb-&gt;adddouble(<em>pkey</em>, <em>num</em>)</strong></dt>

<dd>
<p>Add a real number to a record.
<br />`<em>pkey</em>' specifies primary key.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />The additional value is stored as a decimal string value of a column whose name is &quot;_num&quot;.  If no record corresponds, a new record with the additional value is stored.</p>
</dd>
<dt><strong>$tdb-&gt;sync()</strong></dt>

<dd>
<p>Synchronize updated contents with the file and the device.
<br />If successful, the return value is true, else, it is false.
<br />This method is useful when another process connects the same database file.</p>
</dd>
<dt><strong>$tdb-&gt;optimize(<em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>)</strong></dt>

<dd>
<p>Optimize the database file.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is two times of the number of records.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the current setting is not changed.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the current setting is not changed.
<br />`<em>opts</em>' specifies options by bitwise-or: `$tdb-&gt;TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `$tdb-&gt;TDEFLATE' specifies that each record is compressed with Deflate encoding, `$tdb-&gt;TBZIP' specifies that each record is compressed with BZIP2 encoding, `$tdb-&gt;TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined or 0xff, the current setting is not changed.
<br />If successful, the return value is true, else, it is false.
<br />This method is useful to reduce the size of the database file with data fragmentation by successive updating.</p>
</dd>
<dt><strong>$tdb-&gt;vanish()</strong></dt>

<dd>
<p>Remove all records.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$tdb-&gt;copy(<em>path</em>)</strong></dt>

<dd>
<p>Copy the database file.
<br />`<em>path</em>' specifies the path of the destination file.  If it begins with `@', the trailing substring is executed as a command line.
<br />If successful, the return value is true, else, it is false.  False is returned if the executed command returns non-zero code.
<br />The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress.  So, this method is useful to create a backup file of the database file.</p>
</dd>
<dt><strong>$tdb-&gt;tranbegin()</strong></dt>

<dd>
<p>Begin the transaction.
<br />If successful, the return value is true, else, it is false.
<br />The database is locked by the thread while the transaction so that only one transaction can be activated with a database object at the same time.  Thus, the serializable isolation level is assumed if every database operation is performed in the transaction.  All updated regions are kept track of by write ahead logging while the transaction.  If the database is closed during transaction, the transaction is aborted implicitly.</p>
</dd>
<dt><strong>$tdb-&gt;trancommit()</strong></dt>

<dd>
<p>Commit the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is fixed when it is committed successfully.</p>
</dd>
<dt><strong>$tdb-&gt;tranabort()</strong></dt>

<dd>
<p>Abort the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is discarded when it is aborted.  The state of the database is rollbacked to before transaction.</p>
</dd>
<dt><strong>$tdb-&gt;path()</strong></dt>

<dd>
<p>Get the path of the database file.
<br />The return value is the path of the database file or `undef' if the object does not connect to any database file.</p>
</dd>
<dt><strong>$tdb-&gt;rnum()</strong></dt>

<dd>
<p>Get the number of records.
<br />The return value is the number of records or 0 if the object does not connect to any database file.</p>
</dd>
<dt><strong>$tdb-&gt;fsiz()</strong></dt>

<dd>
<p>Get the size of the database file.
<br />The return value is the size of the database file or 0 if the object does not connect to any database file.</p>
</dd>
<dt><strong><a name="setindex" class="item">$tdb-&gt;setindex(<em>name</em>, <em>type</em>)</a></strong></dt>

<dd>
<p>Set a column index.
<br />`<em>name</em>' specifies the name of a column.  If the name of an existing index is specified, the index is rebuilt.  An empty string means the primary key.
<br />`<em>type</em>' specifies the index type: `$tdb-&gt;ITLEXICAL' for lexical string, `$tdb-&gt;ITDECIMAL' for decimal string, `$tdb-&gt;ITTOKEN' for token inverted index, `$tdb-&gt;ITQGRAM' for q-gram inverted index.  If it is `$tdb-&gt;ITOPT', the index is optimized.  If it is `$tdb-&gt;ITVOID', the index is removed.  If `$tdb-&gt;ITKEEP' is added by bitwise-or and the index exists, this method merely returns failure.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong><a name="genuid" class="item">$tdb-&gt;genuid()</a></strong></dt>

<dd>
<p>Generate a unique ID number.
<br />The return value is the new unique ID number or -1 on failure.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="class_tokyocabinet__tdbqry">Class TokyoCabinet::TDBQRY</a></h2>
<dl>
<dt><strong>$qry = TokyoCabinet::TDBQRY-&gt;new(<em>tdb</em>)</strong></dt>

<dd>
<p>Create a query object.
<br />`<em>tdb</em>' specifies the table database object.
<br />The return value is the new query object.</p>
</dd>
<dt><strong><a name="addcond" class="item">$qry-&gt;addcond(<em>name</em>, <em>op</em>, <em>expr</em>)</a></strong></dt>

<dd>
<p>Add a narrowing condition.
<br />`<em>name</em>' specifies the name of a column.  An empty string means the primary key.
<br />`<em>op</em>' specifies an operation type: `$qry-&gt;QCSTREQ' for string which is equal to the expression, `$qry-&gt;QCSTRINC' for string which is included in the expression, `$qry-&gt;QCSTRBW' for string which begins with the expression, `$qry-&gt;QCSTREW' for string which ends with the expression, `$qry-&gt;QCSTRAND' for string which includes all tokens in the expression, `$qry-&gt;QCSTROR' for string which includes at least one token in the expression, `$qry-&gt;QCSTROREQ' for string which is equal to at least one token in the expression, `$qry-&gt;QCSTRRX' for string which matches regular expressions of the expression, `$qry-&gt;QCNUMEQ' for number which is equal to the expression, `$qry-&gt;QCNUMGT' for number which is greater than the expression, `$qry-&gt;QCNUMGE' for number which is greater than or equal to the expression, `$qry-&gt;QCNUMLT' for number which is less than the expression, `$qry-&gt;QCNUMLE' for number which is less than or equal to the expression, `$qry-&gt;QCNUMBT' for number which is between two tokens of the expression, `$qry-&gt;QCNUMOREQ' for number which is equal to at least one token in the expression, `$qry-&gt;QCFTSPH' for full-text search with the phrase of the expression, `$qry-&gt;QCFTSAND' for full-text search with all tokens in the expression, `$qry-&gt;QCFTSOR' for full-text search with at least one token in the expression, `$qry-&gt;QCFTSEX' for full-text search with the compound expression.  All operations can be flagged by bitwise-or: `$qry-&gt;QCNEGATE' for negation, `$qry-&gt;QCNOIDX' for using no index.
<br />`<em>expr</em>' specifies an operand exression.
<br />The return value is always `undef'.</p>
</dd>
<dt><strong><a name="setorder" class="item">$qry-&gt;setorder(<em>name</em>, <em>type</em>)</a></strong></dt>

<dd>
<p>Set the order of the result.
<br />`<em>name</em>' specifies the name of a column.  An empty string means the primary key.
<br />`<em>type</em>' specifies the order type: `$qry-&gt;QOSTRASC' for string ascending, `$qry-&gt;QOSTRDESC' for string descending, `$qry-&gt;QONUMASC' for number ascending, `$qry-&gt;QONUMDESC' for number descending.  If it is not defined, `$qry-&gt;QOSTRASC' is specified.
<br />The return value is always `undef'.</p>
</dd>
<dt><strong><a name="setlimit" class="item">$qry-&gt;setlimit(<em>max</em>, <em>skip</em>)</a></strong></dt>

<dd>
<p>Set the maximum number of records of the result.
<br />`<em>max</em>' specifies the maximum number of records of the result.  If it is not defined or negative, no limit is specified.
<br />`<em>skip</em>' specifies the number of skipped records of the result.  If it is not defined or not more than 0, no record is skipped.
<br />The return value is always `undef'.</p>
</dd>
<dt><strong><a name="search" class="item">$qry-&gt;search()</a></strong></dt>

<dd>
<p>Execute the search.
<br />The return value is the reference to an array of the primary keys of the corresponding records.  This method does never fail.  It returns an empty array even if no record corresponds.</p>
</dd>
<dt><strong><a name="searchout" class="item">$qry-&gt;searchout()</a></strong></dt>

<dd>
<p>Remove each corresponding record.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong><a name="proc" class="item">$qry-&gt;proc(<em>proc</em>)</a></strong></dt>

<dd>
<p>Process each corresponding record.
<br />`<em>proc</em>' specifies the iterator function called for each record.  It can be either the reference of a block or the name of a function.  The function receives two parameters.  The first parameter is the primary key.  The second parameter is the reference to a hash containing columns.  It returns flags of the post treatment by bitwise-or: `$qry-&gt;QPPUT' to modify the record, `$qry-&gt;QPOUT' to remove the record, `$qry-&gt;QPSTOP' to stop the iteration.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong><a name="hint" class="item">$qry-&gt;hint()</a></strong></dt>

<dd>
<p>Get the hint string.
<br />The return value is the hint string.</p>
</dd>
<dt><strong><a name="metasearch" class="item">$qry-&gt;metasearch(<em>others</em>, <em>type</em>)</a></strong></dt>

<dd>
<p>Retrieve records with multiple query objects and get the set of the result.
<br />`<em>others</em>' specifies the reference to an array of the query objects except for the self object.
<br />`<em>type</em>' specifies a set operation type: `$qry-&gt;MSUNION' for the union set, `$qry-&gt;MSISECT' for the intersection set, `$qry-&gt;MSDIFF' for the difference set.  If it is not defined, `$qry-&gt;MSUNION' is specified.
<br />The return value is the reference to an array of the primary keys of the corresponding records.  This method does never fail.  It returns an empty array even if no record corresponds.
<br />If the first query object has the order setting, the result array is sorted by the order.</p>
</dd>
<dt><strong><a name="kwic" class="item">$qry-&gt;kwic(<em>cols</em>, <em>name</em>, <em>width</em>, <em>opts</em>)</a></strong></dt>

<dd>
<p>Generate keyword-in-context strings.
<br />`<em>cols</em>' specifies the reference to a hash containing columns.
<br />`<em>name</em>' specifies the name of a column.  If it is not defined, the first column of the query is specified.
<br />`<em>width</em>' specifies the width of strings picked up around each keyword.  If it is not defined or negative, the whole text is picked up.
<br />`<em>opts</em>' specifies options by bitwise-or: `$qry-&gt;KWMUTAB' specifies that each keyword is marked up between two tab characters, `$qry-&gt;KWMUCTRL' specifies that each keyword is marked up by the STX (0x02) code and the ETX (0x03) code, `$qry-&gt;KWMUBRCT' specifies that each keyword is marked up by the two square brackets, `$qry-&gt;KWNOOVER' specifies that each context does not overlap, `$qry-&gt;KWPULEAD' specifies that the lead string is picked up forcibly.  If it is not defined, no option is specified.
<br />The return value is the reference to an array of strings around keywords.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="tying_functions_of_tokyocabinet__tdb">Tying functions of TokyoCabinet::TDB</a></h2>
<dl>
<dt><strong>tie(%hash, &quot;TokyoCabinet::TDB&quot;, <em>path</em>, <em>omode</em>, <em>bnum</em>, <em>apow</em>, <em>fpow</em>, <em>opts</em>, <em>rcnum</em>, <em>lcnum</em>, <em>ncnum</em>)</strong></dt>

<dd>
<p>Tie a hash variable to a table database file.
<br />`<em>path</em>' specifies the path of the database file.
<br />`<em>omode</em>' specifies the connection mode: `TokyoCabinet::TDB::OWRITER' as a writer, `TokyoCabinet::TDB::OREADER' as a reader.  If the mode is `TokyoCabinet::TDB::OWRITER', the following may be added by bitwise-or: `TokyoCabinet::TDB::OCREAT', which means it creates a new database if not exist, `TokyoCabinet::TDB::OTRUNC', which means it creates a new database regardless if one exists, `TokyoCabinet::TDB::OTSYNC', which means every transaction synchronizes updated contents with the device.  Both of `TokyoCabinet::TDB::OREADER' and `TokyoCabinet::TDB::OWRITER' can be added to by bitwise-or: `TokyoCabinet::TDB::ONOLCK', which means it opens the database file without file locking, or `TokyoCabinet::TDB::OLCKNB', which means locking is performed without blocking.  If it is not defined, `TokyoCabinet::TDB::OREADER' is specified.
<br />`<em>bnum</em>' specifies the number of elements of the bucket array.  If it is not defined or not more than 0, the default value is specified.  The default value is 131071.  Suggested size of the bucket array is about from 0.5 to 4 times of the number of all records to be stored.
<br />`<em>apow</em>' specifies the size of record alignment by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 4 standing for 2^4=16.
<br />`<em>fpow</em>' specifies the maximum number of elements of the free block pool by power of 2.  If it is not defined or negative, the default value is specified.  The default value is 10 standing for 2^10=1024.
<br />`<em>opts</em>' specifies options by bitwise-or: `TokyoCabinet::TDB::TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `TokyoCabinet::TDB::TDEFLATE' specifies that each record is compressed with Deflate encoding, `TokyoCabinet::TDB::TBZIP' specifies that each record is compressed with BZIP2 encoding, `TokyoCabinet::TDB::TTCBS' specifies that each record is compressed with TCBS encoding.  If it is not defined, no option is specified.
<br />`<em>rcnum</em>' specifies the maximum number of records to be cached.  If it is not defined or not more than 0, the record cache is disabled. It is disabled by default.
<br />`<em>lcnum</em>' specifies the maximum number of leaf nodes to be cached.  If it is not defined or not more than 0, the default value is specified.  The default value is 2048.
<br />`<em>ncnum</em>' specifies the maximum number of non-leaf nodes to be cached.  If it is not defined or not more than 0, the default value is specified.  The default value is 512.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>untie(%hash)</strong></dt>

<dd>
<p>Untie a hash variable from the database file.
<br />The return value is always true.</p>
</dd>
<dt><strong><a name="_hash_pkey_" class="item">$hash{<em>pkey</em>} = <em>cols</em></a></strong></dt>

<dd>
<p>Store a record.
<br />`<em>pkey</em>' specifies primary key.
<br />`<em>cols</em>' specifies the reference to a hash containing columns.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong>delete($hash{<em>pkey</em>})</strong></dt>

<dd>
<p>Remove a record.
<br />`<em>pkey</em>' specifies primary key.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$hash{<em>pkey</em>}</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>pkey</em>' specifies primary key.
<br />If successful, the return value is the reference to a hash of the columns of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong>exists($hash{<em>pkey</em>})</strong></dt>

<dd>
<p>Check whether a record corrsponding a key exists.
<br />`<em>pkey</em>' specifies primary key.
<br />The return value is true if the record exists, else it is false.</p>
</dd>
<dt><strong>$hash = ()</strong></dt>

<dd>
<p>Remove all records.
<br />The return value is always `undef'.</p>
</dd>
<dt><strong><a name="the_iterator4" class="item">(the iterator)</a></strong></dt>

<dd>
<p>The inner methods `FIRSTKEY' and `NEXTKEY' are also implemented so that you can use the tying functions `each', `keys', and so on.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="class_tokyocabinet__adb">Class TokyoCabinet::ADB</a></h2>
<p>Abstract database is a set of interfaces to use on-memory hash database, on-memory tree database, hash database, B+ tree database, fixed-length database, and table database with the same API.  Before operations to store or retrieve records, it is necessary to connect the abstract database object to the concrete one.  The method `open' is used to open a concrete database and the method `close' is used to close the database.  To avoid data missing or corruption, it is important to close every database instance when it is no longer in use.  It is forbidden for multible database objects in a process to open the same database at the same time.</p>
<dl>
<dt><strong>$adb = TokyoCabinet::ADB-&gt;new()</strong></dt>

<dd>
<p>Create an abstract database object.
<br />The return value is the new abstract database object.</p>
</dd>
<dt><strong>$adb-&gt;open(<em>name</em>)</strong></dt>

<dd>
<p>Open a database.
<br />`<em>name</em>' specifies the name of the database.  If it is &quot;*&quot;, the database will be an on-memory hash database.  If it is &quot;+&quot;, the database will be an on-memory tree database.  If its suffix is &quot;.tch&quot;, the database will be a hash database.  If its suffix is &quot;.tcb&quot;, the database will be a B+ tree database.  If its suffix is &quot;.tcf&quot;, the database will be a fixed-length database.  If its suffix is &quot;.tct&quot;, the database will be a table database.  Otherwise, this method fails.  Tuning parameters can trail the name, separated by &quot;#&quot;.  Each parameter is composed of the name and the value, separated by &quot;=&quot;.  On-memory hash database supports &quot;bnum&quot;, &quot;capnum&quot;, and &quot;capsiz&quot;.  On-memory tree database supports &quot;capnum&quot; and &quot;capsiz&quot;.  Hash database supports &quot;mode&quot;, &quot;bnum&quot;, &quot;apow&quot;, &quot;fpow&quot;, &quot;opts&quot;, &quot;rcnum&quot;, and &quot;xmsiz&quot;.  B+ tree database supports &quot;mode&quot;, &quot;lmemb&quot;, &quot;nmemb&quot;, &quot;bnum&quot;, &quot;apow&quot;, &quot;fpow&quot;, &quot;opts&quot;, &quot;lcnum&quot;, &quot;ncnum&quot;, and &quot;xmsiz&quot;.  Fixed-length database supports &quot;mode&quot;, &quot;width&quot;, and &quot;limsiz&quot;.  Table database supports &quot;mode&quot;, &quot;bnum&quot;, &quot;apow&quot;, &quot;fpow&quot;, &quot;opts&quot;, &quot;rcnum&quot;, &quot;lcnum&quot;, &quot;ncnum&quot;, &quot;xmsiz&quot;, and &quot;idx&quot;.
<br />If successful, the return value is true, else, it is false.
<br />The tuning parameter &quot;capnum&quot; specifies the capacity number of records.  &quot;capsiz&quot; specifies the capacity size of using memory.  Records spilled the capacity are removed by the storing order.  &quot;mode&quot; can contain &quot;w&quot; of writer, &quot;r&quot; of reader, &quot;c&quot; of creating, &quot;t&quot; of truncating, &quot;e&quot; of no locking, and &quot;f&quot; of non-blocking lock.  The default mode is relevant to &quot;wc&quot;.  &quot;opts&quot; can contains &quot;l&quot; of large option, &quot;d&quot; of Deflate option, &quot;b&quot; of BZIP2 option, and &quot;t&quot; of TCBS option.  &quot;idx&quot; specifies the column name of an index and its type separated by &quot;:&quot;.  For example, &quot;casket.tch#bnum=1000000#opts=ld&quot; means that the name of the database file is &quot;casket.tch&quot;, and the bucket number is 1000000, and the options are large and Deflate.</p>
</dd>
<dt><strong>$adb-&gt;close()</strong></dt>

<dd>
<p>Close the database.
<br />If successful, the return value is true, else, it is false.
<br />Update of a database is assured to be written when the database is closed.  If a writer opens a database but does not close it appropriately, the database will be broken.</p>
</dd>
<dt><strong>$adb-&gt;put(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Store a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong>$adb-&gt;putkeep(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Store a new record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, this method has no effect.</p>
</dd>
<dt><strong>$adb-&gt;putcat(<em>key</em>, <em>value</em>)</strong></dt>

<dd>
<p>Concatenate a value at the end of the existing record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If there is no corresponding record, a new record is created.</p>
</dd>
<dt><strong>$adb-&gt;out(<em>key</em>)</strong></dt>

<dd>
<p>Remove a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$adb-&gt;get(<em>key</em>)</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the value of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong>$adb-&gt;vsiz(<em>key</em>)</strong></dt>

<dd>
<p>Get the size of the value of a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the size of the value of the corresponding record, else, it is -1.</p>
</dd>
<dt><strong>$adb-&gt;iterinit()</strong></dt>

<dd>
<p>Initialize the iterator.
<br />If successful, the return value is true, else, it is false.
<br />The iterator is used in order to access the key of every record stored in a database.</p>
</dd>
<dt><strong>$adb-&gt;iternext()</strong></dt>

<dd>
<p>Get the next key of the iterator.
<br />If successful, the return value is the next key, else, it is `undef'.  `undef' is returned when no record is to be get out of the iterator.
<br />It is possible to access every record by iteration of calling this method.  It is allowed to update or remove records whose keys are fetched while the iteration.  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.</p>
</dd>
<dt><strong>$adb-&gt;fwmkeys(<em>prefix</em>, <em>max</em>)</strong></dt>

<dd>
<p>Get forward matching keys.
<br />`<em>prefix</em>' specifies the prefix of the corresponding keys.
<br />`<em>max</em>' specifies the maximum number of keys to be fetched.  If it is not defined or negative, no limit is specified.
<br />The return value is the reference to an array of the keys of the corresponding records.  This method does never fail.  It returns an empty array even if no record corresponds.
<br />Note that this method may be very slow because every key in the database is scanned.</p>
</dd>
<dt><strong>$adb-&gt;addint(<em>key</em>, <em>num</em>)</strong></dt>

<dd>
<p>Add an integer to a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />If the corresponding record exists, the value is treated as an integer and is added to.  If no record corresponds, a new record of the additional value is stored.  Because records are stored in binary format, they should be processed with the `unpack' function with the `i' operator after retrieval.</p>
</dd>
<dt><strong>$adb-&gt;adddouble(<em>key</em>, <em>num</em>)</strong></dt>

<dd>
<p>Add a real number to a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>num</em>' specifies the additional value.
<br />If successful, the return value is the summation value, else, it is `undef'.
<br />If the corresponding record exists, the value is treated as a real number and is added to.  If no record corresponds, a new record of the additional value is stored.  Because records are stored in binary format, they should be processed with the `unpack' function with the `d' operator after retrieval.</p>
</dd>
<dt><strong>$adb-&gt;sync()</strong></dt>

<dd>
<p>Synchronize updated contents with the file and the device.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$adb-&gt;optimize(<em>params</em>)</strong></dt>

<dd>
<p>Optimize the storage.
<br />`<em>params</em>' specifies the string of the tuning parameters, which works as with the tuning of parameters the method `open'.  If it is not defined, it is not used.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$adb-&gt;vanish()</strong></dt>

<dd>
<p>Remove all records.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$adb-&gt;copy(<em>path</em>)</strong></dt>

<dd>
<p>Copy the database file.
<br />`<em>path</em>' specifies the path of the destination file.  If it begins with `@', the trailing substring is executed as a command line.
<br />If successful, the return value is true, else, it is false.  False is returned if the executed command returns non-zero code.
<br />The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress.  So, this method is useful to create a backup file of the database file.</p>
</dd>
<dt><strong>$adb-&gt;tranbegin()</strong></dt>

<dd>
<p>Begin the transaction.
<br />If successful, the return value is true, else, it is false.
<br />The database is locked by the thread while the transaction so that only one transaction can be activated with a database object at the same time.  Thus, the serializable isolation level is assumed if every database operation is performed in the transaction.  All updated regions are kept track of by write ahead logging while the transaction.  If the database is closed during transaction, the transaction is aborted implicitly.</p>
</dd>
<dt><strong>$adb-&gt;trancommit()</strong></dt>

<dd>
<p>Commit the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is fixed when it is committed successfully.</p>
</dd>
<dt><strong>$adb-&gt;tranabort()</strong></dt>

<dd>
<p>Abort the transaction.
<br />If successful, the return value is true, else, it is false.
<br />Update in the transaction is discarded when it is aborted.  The state of the database is rollbacked to before transaction.</p>
</dd>
<dt><strong>$adb-&gt;path()</strong></dt>

<dd>
<p>Get the path of the database file.
<br />The return value is the path of the database file or `undef' if the object does not connect to any database instance.  &quot;*&quot; stands for on-memory hash database.  &quot;+&quot; stands for on-memory tree database.</p>
</dd>
<dt><strong>$adb-&gt;rnum()</strong></dt>

<dd>
<p>Get the number of records.
<br />The return value is the number of records or 0 if the object does not connect to any database instance.</p>
</dd>
<dt><strong><a name="size" class="item">$adb-&gt;size()</a></strong></dt>

<dd>
<p>Get the size of the database.
<br />The return value is the size of the database file or 0 if the object does not connect to any database instance.</p>
</dd>
<dt><strong><a name="misc" class="item">$adb-&gt;misc(<em>name</em>, <em>args</em>)</a></strong></dt>

<dd>
<p>Call a versatile function for miscellaneous operations.
<br />`<em>name</em>' specifies the name of the function.
<br />`<em>args</em>' specifies the reference to an array of arguments.  If it is not defined, no argument is specified.
<br />If successful, the return value is the reference to an array of the result.  `undef' is returned on failure.</p>
</dd>
</dl>
<p>
</p>
<h2><a name="tying_functions_of_tokyocabinet__adb">Tying functions of TokyoCabinet::ADB</a></h2>
<dl>
<dt><strong>tie(%hash, &quot;TokyoCabinet::ADB&quot;, <em>name</em>)</strong></dt>

<dd>
<p>Tie a hash variable to an abstract database instance.
<br />`<em>name</em>' specifies the name of the database.  If it is &quot;*&quot;, the database will be an on-memory hash database.  If it is &quot;+&quot;, the database will be an on-memory tree database.  If its suffix is &quot;.tch&quot;, the database will be a hash database.  If its suffix is &quot;.tcb&quot;, the database will be a B+ tree database.  If its suffix is &quot;.tcf&quot;, the database will be a fixed-length database.  If its suffix is &quot;.tct&quot;, the database will be a table database.  Otherwise, this method fails.  Tuning parameters can trail the name, separated by &quot;#&quot;.  Each parameter is composed of the name and the value, separated by &quot;=&quot;.  On-memory hash database supports &quot;bnum&quot;, &quot;capnum&quot;, and &quot;capsiz&quot;.  On-memory tree database supports &quot;capnum&quot; and &quot;capsiz&quot;.  Hash database supports &quot;mode&quot;, &quot;bnum&quot;, &quot;apow&quot;, &quot;fpow&quot;, &quot;opts&quot;, &quot;rcnum&quot;, and &quot;xmsiz&quot;.  B+ tree database supports &quot;mode&quot;, &quot;lmemb&quot;, &quot;nmemb&quot;, &quot;bnum&quot;, &quot;apow&quot;, &quot;fpow&quot;, &quot;opts&quot;, &quot;lcnum&quot;, &quot;ncnum&quot;, and &quot;xmsiz&quot;.  Fixed-length database supports &quot;mode&quot;, &quot;width&quot;, and &quot;limsiz&quot;.  Table database supports &quot;mode&quot;, &quot;bnum&quot;, &quot;apow&quot;, &quot;fpow&quot;, &quot;opts&quot;, &quot;rcnum&quot;, &quot;lcnum&quot;, &quot;ncnum&quot;, &quot;xmsiz&quot;, and &quot;idx&quot;.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>untie(%hash)</strong></dt>

<dd>
<p>Untie a hash variable from the database.
<br />The return value is always true.</p>
</dd>
<dt><strong>$hash{<em>key</em>} = <em>value</em></strong></dt>

<dd>
<p>Store a record.
<br />`<em>key</em>' specifies the key.
<br />`<em>value</em>' specifies the value.
<br />If successful, the return value is true, else, it is false.
<br />If a record with the same key exists in the database, it is overwritten.</p>
</dd>
<dt><strong>delete($hash{<em>key</em>})</strong></dt>

<dd>
<p>Remove a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is true, else, it is false.</p>
</dd>
<dt><strong>$hash{<em>key</em>}</strong></dt>

<dd>
<p>Retrieve a record.
<br />`<em>key</em>' specifies the key.
<br />If successful, the return value is the value of the corresponding record.  `undef' is returned if no record corresponds.</p>
</dd>
<dt><strong>exists($hash{<em>key</em>})</strong></dt>

<dd>
<p>Check whether a record corrsponding a key exists.
<br />`<em>key</em>' specifies the key.
<br />The return value is true if the record exists, else it is false.</p>
</dd>
<dt><strong>$hash = ()</strong></dt>

<dd>
<p>Remove all records.
<br />The return value is always `undef'.</p>
</dd>
<dt><strong><a name="the_iterator5" class="item">(the iterator)</a></strong></dt>

<dd>
<p>The inner methods `FIRSTKEY' and `NEXTKEY' are also implemented so that you can use the tying functions `each', `keys', and so on.</p>
</dd>
</dl>
<p>
</p>
<hr />
<h1><a name="license">LICENSE</a></h1>
<pre>
 Copyright (C) 2006-2010 FAL Labs
 All rights reserved.</pre>
<p>Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License or any later version.  Tokyo Cabinet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License along with Tokyo Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.</p>

</body>

</html>