tokyocabinet
Class BDB

java.lang.Object
  extended by tokyocabinet.BDB
All Implemented Interfaces:
DBM

public class BDB
extends java.lang.Object
implements DBM

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. 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.


Field Summary
static int CMPDECIMAL
          comparison function: as decimal strings of real numbers
static int CMPINT32
          comparison function: as 32-bit integers in the native byte order
static int CMPINT64
          comparison function: as 64-bit integers in the native byte order
static int CMPLEXICAL
          comparison function: by lexical order
static int ECLOSE
          error code: close error
static int EINVALID
          error code: invalid operation
static int EKEEP
          error code: existing record
static int ELOCK
          error code: lock error
static int EMETA
          error code: invalid meta data
static int EMISC
          error code: miscellaneous error
static int EMKDIR
          error code: mkdir error
static int EMMAP
          error code: mmap error
static int ENOFILE
          error code: file not found
static int ENOPERM
          error code: no permission
static int ENOREC
          error code: no record found
static int EOPEN
          error code: open error
static int EREAD
          error code: read error
static int ERENAME
          error code: rename error
static int ERHEAD
          error code: invalid record header
static int ERMDIR
          error code: rmdir error
static int ESEEK
          error code: seek error
static int ESTAT
          error code: stat error
static int ESUCCESS
          error code: success
static int ESYNC
          error code: sync error
static int ETHREAD
          error code: threading error
static int ETRUNC
          error code: trunc error
static int EUNLINK
          error code: unlink error
static int EWRITE
          error code: write error
static int OCREAT
          open mode: writer creating
static int OLCKNB
          open mode: lock without blocking
static int ONOLCK
          open mode: open without locking
static int OREADER
          open mode: open as a reader
static int OTRUNC
          open mode: writer truncating
static int OTSYNC
          open mode: synchronize every transaction
static int OWRITER
          open mode: open as a writer
static int TBZIP
          tuning option: compress each record with BZIP2
static int TDEFLATE
          tuning option: compress each record with Deflate
static int TLARGE
          tuning option: use 64-bit bucket array
static int TTCBS
          tuning option: compress each record with TCBS
 
Constructor Summary
BDB()
          Create a B+ tree database object.
 
Method Summary
 double adddouble(byte[] key, double num)
          Add a real number to a record.
 double adddouble(java.lang.String key, double num)
          Add a real number to a record.
 int addint(byte[] key, int num)
          Add an integer to a record.
 int addint(java.lang.String key, int num)
          Add an integer to a record.
 boolean close()
          Close the database file.
 boolean copy(java.lang.String path)
          Copy the database file.
 int ecode()
          Get the last happened error code.
 java.lang.String errmsg()
          Get the message string corresponding to the last happened error code.
static java.lang.String errmsg(int ecode)
          Get the message string corresponding to an error code.
protected  void finalize()
          Release resources.
 long fsiz()
          Get the size of the database file.
 java.util.List fwmkeys(byte[] prefix, int max)
          Get forward matching keys.
 java.util.List fwmkeys(java.lang.String prefix, int max)
          Get forward matching keys.
 byte[] get(byte[] key)
          Retrieve a record.
 java.lang.String get(java.lang.String key)
          Retrieve a record.
 java.util.List getlist(byte[] key)
          Retrieve records.
 java.util.List getlist(java.lang.String key)
          Retrieve records.
 boolean iterinit()
          Initialize the iterator.
 byte[] iternext()
          Get the next key of the iterator.
 java.lang.String iternext2()
          Get the next key of the iterator.
 boolean open(java.lang.String name)
          Open a database file.
 boolean open(java.lang.String path, int omode)
          Open a database file.
 boolean optimize()
          Optimize the database file.
 boolean optimize(int lmemb, int nmemb, long bnum, int apow, int fpow, int opts)
          Optimize the database file.
 boolean out(byte[] key)
          Remove a record.
 boolean out(java.lang.String key)
          Remove a record.
 boolean outlist(byte[] key)
          Remove records.
 boolean outlist(java.lang.String key)
          Remove records.
 java.lang.String path()
          Get the path of the database file.
 boolean put(byte[] key, byte[] value)
          Store a record.
 boolean put(java.lang.String key, java.lang.String value)
          Store a record.
 boolean putcat(byte[] key, byte[] value)
          Concatenate a value at the end of the existing record.
 boolean putcat(java.lang.String key, java.lang.String value)
          Concatenate a value at the end of the existing record.
 boolean putdup(byte[] key, byte[] value)
          Store a record with allowing duplication of keys.
 boolean putdup(java.lang.String key, java.lang.String value)
          Store a record with allowing duplication of keys.
 boolean putkeep(byte[] key, byte[] value)
          Store a new record.
 boolean putkeep(java.lang.String key, java.lang.String value)
          Store a new record.
 boolean putlist(byte[] key, java.util.List values)
          Store records with allowing duplication of keys.
 boolean putlist(java.lang.String key, java.util.List values)
          Store records with allowing duplication of keys.
 java.util.List range(byte[] bkey, boolean binc, byte[] ekey, boolean einc, int max)
          Get keys of ranged records.
 java.util.List range(java.lang.String bkey, boolean binc, java.lang.String ekey, boolean einc, int max)
          Get keys of ranged records.
 long rnum()
          Get the number of records.
 boolean setcache(int lcnum, int ncnum)
          Set the caching parameters.
 boolean setcmpfunc(int cmp)
          Set the built-in comparison function.
 boolean setcomparator(BDBCMP cmp)
          Set the custom comparator object.
 boolean setdfunit(int dfunit)
          Set the unit step number of auto defragmentation.
 boolean setxmsiz(long xmsiz)
          Set the size of the extra mapped memory.
 boolean sync()
          Synchronize updated contents with the file and the device.
 boolean tranabort()
          Abort the transaction.
 boolean tranbegin()
          Begin the transaction.
 boolean trancommit()
          Commit the transaction.
 boolean tune(int lmemb, int nmemb, long bnum, int apow, int fpow, int opts)
          Set the tuning parameters.
 boolean vanish()
          Remove all records.
 int vnum(byte[] key)
          Get the number of records corresponding a key.
 int vnum(java.lang.String key)
          Get the number of records corresponding a key.
 int vsiz(byte[] key)
          Get the size of the value of a record.
 int vsiz(java.lang.String key)
          Get the size of the value of a record.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CMPDECIMAL

public static final int CMPDECIMAL
comparison function: as decimal strings of real numbers

See Also:
Constant Field Values

CMPINT32

public static final int CMPINT32
comparison function: as 32-bit integers in the native byte order

See Also:
Constant Field Values

CMPINT64

public static final int CMPINT64
comparison function: as 64-bit integers in the native byte order

See Also:
Constant Field Values

CMPLEXICAL

public static final int CMPLEXICAL
comparison function: by lexical order

See Also:
Constant Field Values

ECLOSE

public static final int ECLOSE
error code: close error

See Also:
Constant Field Values

EINVALID

public static final int EINVALID
error code: invalid operation

See Also:
Constant Field Values

EKEEP

public static final int EKEEP
error code: existing record

See Also:
Constant Field Values

ELOCK

public static final int ELOCK
error code: lock error

See Also:
Constant Field Values

EMETA

public static final int EMETA
error code: invalid meta data

See Also:
Constant Field Values

EMISC

public static final int EMISC
error code: miscellaneous error

See Also:
Constant Field Values

EMKDIR

public static final int EMKDIR
error code: mkdir error

See Also:
Constant Field Values

EMMAP

public static final int EMMAP
error code: mmap error

See Also:
Constant Field Values

ENOFILE

public static final int ENOFILE
error code: file not found

See Also:
Constant Field Values

ENOPERM

public static final int ENOPERM
error code: no permission

See Also:
Constant Field Values

ENOREC

public static final int ENOREC
error code: no record found

See Also:
Constant Field Values

EOPEN

public static final int EOPEN
error code: open error

See Also:
Constant Field Values

EREAD

public static final int EREAD
error code: read error

See Also:
Constant Field Values

ERENAME

public static final int ERENAME
error code: rename error

See Also:
Constant Field Values

ERHEAD

public static final int ERHEAD
error code: invalid record header

See Also:
Constant Field Values

ERMDIR

public static final int ERMDIR
error code: rmdir error

See Also:
Constant Field Values

ESEEK

public static final int ESEEK
error code: seek error

See Also:
Constant Field Values

ESTAT

public static final int ESTAT
error code: stat error

See Also:
Constant Field Values

ESUCCESS

public static final int ESUCCESS
error code: success

See Also:
Constant Field Values

ESYNC

public static final int ESYNC
error code: sync error

See Also:
Constant Field Values

ETHREAD

public static final int ETHREAD
error code: threading error

See Also:
Constant Field Values

ETRUNC

public static final int ETRUNC
error code: trunc error

See Also:
Constant Field Values

EUNLINK

public static final int EUNLINK
error code: unlink error

See Also:
Constant Field Values

EWRITE

public static final int EWRITE
error code: write error

See Also:
Constant Field Values

OCREAT

public static final int OCREAT
open mode: writer creating

See Also:
Constant Field Values

OLCKNB

public static final int OLCKNB
open mode: lock without blocking

See Also:
Constant Field Values

ONOLCK

public static final int ONOLCK
open mode: open without locking

See Also:
Constant Field Values

OREADER

public static final int OREADER
open mode: open as a reader

See Also:
Constant Field Values

OTRUNC

public static final int OTRUNC
open mode: writer truncating

See Also:
Constant Field Values

OTSYNC

public static final int OTSYNC
open mode: synchronize every transaction

See Also:
Constant Field Values

OWRITER

public static final int OWRITER
open mode: open as a writer

See Also:
Constant Field Values

TBZIP

public static final int TBZIP
tuning option: compress each record with BZIP2

See Also:
Constant Field Values

TDEFLATE

public static final int TDEFLATE
tuning option: compress each record with Deflate

See Also:
Constant Field Values

TLARGE

public static final int TLARGE
tuning option: use 64-bit bucket array

See Also:
Constant Field Values

TTCBS

public static final int TTCBS
tuning option: compress each record with TCBS

See Also:
Constant Field Values
Constructor Detail

BDB

public BDB()
Create a B+ tree database object.

Method Detail

adddouble

public double adddouble(byte[] key,
                        double num)
Add a real number to a record.

Specified by:
adddouble in interface DBM
Parameters:
key - the key.
num - the additional value.
Returns:
If successful, it is the summation value, else, it is `Double.NaN'.
Note:
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.

adddouble

public double adddouble(java.lang.String key,
                        double num)
Add a real number to a record. The same as `adddouble(key.getBytes(), num)'.

Specified by:
adddouble in interface DBM
See Also:
adddouble(byte[], double)

addint

public int addint(byte[] key,
                  int num)
Add an integer to a record.

Specified by:
addint in interface DBM
Parameters:
key - the key.
num - the additional value.
Returns:
If successful, it is the summation value, else, it is `Integer.MIN_VALUE'.
Note:
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.

addint

public int addint(java.lang.String key,
                  int num)
Add an integer to a record. The same as `addint(key.getBytes(), num)'.

Specified by:
addint in interface DBM
See Also:
addint(byte[], int)

close

public boolean close()
Close the database file.

Returns:
If successful, it is true, else, it is false.
Note:
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.

copy

public boolean copy(java.lang.String path)
Copy the database file.

Parameters:
path - the path of the destination file. If it begins with `@', the trailing substring is executed as a command line.
Returns:
If successful, it is true, else, it is false. False is returned if the executed command returns non-zero code.
Note:
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.

ecode

public int ecode()
Get the last happened error code.

Returns:
the last happened error code.

errmsg

public java.lang.String errmsg()
Get the message string corresponding to the last happened error code.

Returns:
the message string of the error code.

errmsg

public static java.lang.String errmsg(int ecode)
Get the message string corresponding to an error code.

Parameters:
ecode - the error code.
Returns:
the message string of the error code.

finalize

protected void finalize()
Release resources.

Overrides:
finalize in class java.lang.Object

fsiz

public long fsiz()
Get the size of the database file.

Specified by:
fsiz in interface DBM
Returns:
the size of the database file or 0 if the object does not connect to any database file.

fwmkeys

public java.util.List fwmkeys(byte[] prefix,
                              int max)
Get forward matching keys.

Specified by:
fwmkeys in interface DBM
Parameters:
prefix - the prefix of the corresponding keys.
max - the maximum number of keys to be fetched. If it is negative, no limit is specified.
Returns:
a list object of the keys of the corresponding records. This method does never fail. It returns an empty list even if no record corresponds.

fwmkeys

public java.util.List fwmkeys(java.lang.String prefix,
                              int max)
Get forward matching keys. The same as `fwmkeys(prefix.getBytes(), max)'. However, type of each element is `String'.

Specified by:
fwmkeys in interface DBM
See Also:
fwmkeys(byte[], int)

get

public byte[] get(byte[] key)
Retrieve a record.

Specified by:
get in interface DBM
Parameters:
key - the key.
Returns:
If successful, it is the value of the corresponding record. `null' is returned if no record corresponds.
Note:
If the key of duplicated records is specified, the first one is selected.

get

public java.lang.String get(java.lang.String key)
Retrieve a record. The same as `new String(get(key.getBytes()), "UTF-8")'.

Specified by:
get in interface DBM
See Also:
get(byte[])

getlist

public java.util.List getlist(byte[] key)
Retrieve records.

Parameters:
key - the key.
Returns:
If successful, it is a list of the values of the corresponding records. `null' is returned if no record corresponds. Type of each element is `byte[]'.

getlist

public java.util.List getlist(java.lang.String key)
Retrieve records. The same as `getlist(key.getBytes())'. However, type of each element is `String'.

See Also:
get(byte[])

iterinit

public boolean iterinit()
Initialize the iterator.

Specified by:
iterinit in interface DBM
Returns:
If successful, it is true, else, it is false.
Note:
The iterator is implemented with the cursor embedded in the database.

iternext

public byte[] iternext()
Get the next key of the iterator.

Specified by:
iternext in interface DBM
Returns:
If successful, it is the next key, else, it is `null'. `null' is returned when no record is to be get out of the iterator.

iternext2

public java.lang.String iternext2()
Get the next key of the iterator. The same as `new String(iternext(), "UTF-8")'.

Specified by:
iternext2 in interface DBM
See Also:
iternext()

open

public boolean open(java.lang.String name)
Open a database file. The same as `open(name, BDB.OREADER)'.

See Also:
open(String, int)

open

public boolean open(java.lang.String path,
                    int omode)
Open a database file.

Parameters:
path - the path of the database file.
omode - the connection mode: `BDB.OWRITER' as a writer, `BDB.OREADER' as a reader. If the mode is `BDB.OWRITER', the following may be added by bitwise-or: `BDB.OCREAT', which means it creates a new database if not exist, `BDB.OTRUNC', which means it creates a new database regardless if one exists, `BDB.OTSYNC', which means every transaction synchronizes updated contents with the device. Both of `BDB.OREADER' and `BDB.OWRITER' can be added to by bitwise-or: `BDB.ONOLCK', which means it opens the database file without file locking, or `BDB.OLCKNB', which means locking is performed without blocking.
Returns:
If successful, it is true, else, it is false.

optimize

public boolean optimize()
Optimize the database file. The same as `optimize(-1, -1, -1, -1, -1, 0xff)'.

See Also:
optimize(int, int, long, int, int, int)

optimize

public boolean optimize(int lmemb,
                        int nmemb,
                        long bnum,
                        int apow,
                        int fpow,
                        int opts)
Optimize the database file.

Parameters:
lmemb - the number of members in each leaf page. If it is not more than 0, the current setting is not changed.
nmemb - the number of members in each non-leaf page. If it is not more than 0, the current setting is not changed.
bnum - the number of elements of the bucket array. If it is not more than 0, the default value is specified. The default value is two times of the number of pages.
apow - the size of record alignment by power of 2. If it is negative, the current setting is not changed.
fpow - the maximum number of elements of the free block pool by power of 2. If it is negative, the current setting is not changed.
opts - options by bitwise-or: `BDB.TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `BDB.TDEFLATE' specifies that each record is compressed with Deflate encoding, `BDB.TBZIP' specifies that each record is compressed with BZIP2 encoding, `BDB.TTCBS' specifies that each record is compressed with TCBS encoding. If it is 0xff, the current setting is not changed.
Returns:
If successful, it is true, else, it is false.
Note:
This method is useful to reduce the size of the database file with data fragmentation by successive updating.

out

public boolean out(byte[] key)
Remove a record.

Specified by:
out in interface DBM
Parameters:
key - the key.
Returns:
If successful, it is true, else, it is false.
Note:
If the key of duplicated records is specified, the first one is selected.

out

public boolean out(java.lang.String key)
Remove a record. The same as `out(key.getBytes())'.

Specified by:
out in interface DBM
See Also:
out(byte[])

outlist

public boolean outlist(byte[] key)
Remove records.

Parameters:
key - the key.
Returns:
If successful, it is true, else, it is false.
Note:
If the key of duplicated records is specified, all of them are removed.

outlist

public boolean outlist(java.lang.String key)
Remove records. The same as `outlist(key.getBytes())'.

See Also:
outlist(byte[])

path

public java.lang.String path()
Get the path of the database file.

Returns:
the path of the database file or `null' if the object does not connect to any database file.

put

public boolean put(byte[] key,
                   byte[] value)
Store a record.

Specified by:
put in interface DBM
Parameters:
key - the key.
value - the value.
Returns:
If successful, it is true, else, it is false.
Note:
If a record with the same key exists in the database, it is overwritten.

put

public boolean put(java.lang.String key,
                   java.lang.String value)
Store a record. The same as `put(key.getBytes(), value.getBytes())'.

Specified by:
put in interface DBM
See Also:
put(byte[], byte[])

putcat

public boolean putcat(byte[] key,
                      byte[] value)
Concatenate a value at the end of the existing record.

Parameters:
key - the key.
value - the value.
Returns:
If successful, it is true, else, it is false.
Note:
If there is no corresponding record, a new record is created.

putcat

public boolean putcat(java.lang.String key,
                      java.lang.String value)
Concatenate a value at the end of the existing record. The same as `putcat(key.getBytes(), value.getBytes())'.

See Also:
putcat(byte[], byte[])

putdup

public boolean putdup(byte[] key,
                      byte[] value)
Store a record with allowing duplication of keys.

Parameters:
key - the key.
value - the value.
Returns:
If successful, it is true, else, it is false.
Note:
If a record with the same key exists in the database, the new record is placed after the existing one.

putdup

public boolean putdup(java.lang.String key,
                      java.lang.String value)
Store a record with allowing duplication of keys. The same as `putdup(key.getBytes(), value.getBytes())'.

See Also:
putdup(byte[], byte[])

putkeep

public boolean putkeep(byte[] key,
                       byte[] value)
Store a new record.

Specified by:
putkeep in interface DBM
Parameters:
key - the key.
value - the value.
Returns:
If successful, it is true, else, it is false.
Note:
If a record with the same key exists in the database, this method has no effect.

putkeep

public boolean putkeep(java.lang.String key,
                       java.lang.String value)
Store a new record. The same as `putkeep(key.getBytes(), value.getBytes())'.

Specified by:
putkeep in interface DBM
See Also:
putkeep(byte[], byte[])

putlist

public boolean putlist(byte[] key,
                       java.util.List values)
Store records with allowing duplication of keys.

Parameters:
key - the key.
values - a list of the values. Type of each element should be `byte[]'.
Returns:
If successful, it is true, else, it is false.
Note:
If a record with the same key exists in the database, the new records are placed after the existing one.

putlist

public boolean putlist(java.lang.String key,
                       java.util.List values)
Store records with allowing duplication of keys. The same as `putlist(key.getBytes(), value)'. Type of each element should be `String'.

See Also:
putlist(byte[], List)

range

public java.util.List range(byte[] bkey,
                            boolean binc,
                            byte[] ekey,
                            boolean einc,
                            int max)
Get keys of ranged records.

Parameters:
bkey - the key of the beginning border. If it is `null', the first record is specified.
binc - whether the beginning border is inclusive or not.
ekey - the key of the ending border. If it is `null', the last record is specified.
einc - whether the ending border is inclusive or not.
max - the maximum number of keys to be fetched. If it is negative, no limit is specified.
Returns:
a list object of the keys of the corresponding records. This method does never fail. It returns an empty list even if no record corresponds.

range

public java.util.List range(java.lang.String bkey,
                            boolean binc,
                            java.lang.String ekey,
                            boolean einc,
                            int max)
Get keys of ranged records. The same as `range(bkey.getBytes(), binc, ekey.getBytes(), einc, max)'. However, type of each element is `String'.

See Also:
range(byte[], boolean, byte[], boolean, int)

rnum

public long rnum()
Get the number of records.

Specified by:
rnum in interface DBM
Returns:
the number of records or 0 if the object does not connect to any database file.

setcache

public boolean setcache(int lcnum,
                        int ncnum)
Set the caching parameters.

Parameters:
lcnum - the maximum number of leaf nodes to be cached. If it is not more than 0, the default value is specified. The default value is 1024.
ncnum - the maximum number of non-leaf nodes to be cached. If it is not more than 0, the default value is specified. The default value is 512.
Returns:
If successful, it is true, else, it is false.
Note:
The tuning parameters of the database should be set before the database is opened.

setcmpfunc

public boolean setcmpfunc(int cmp)
Set the built-in comparison function.

Parameters:
cmp - the constant of a built-in comparison function.
Returns:
If successful, it is true, else, it is false.
Note:
The default comparison function compares keys of two records by lexical order. The constants `BDB.CMPLEXICAL' (dafault), `BDB.CMPDECIMAL', `BDB.CMPINT32', and `BDB.CMPINT64' are supported. The comparison function should be set before the database is opened.

setcomparator

public boolean setcomparator(BDBCMP cmp)
Set the custom comparator object.

Parameters:
cmp - the custom comparator object.
Returns:
If successful, it is true, else, it is false.
Note:
The default comparison function compares keys of two records by lexical order. The comparison function should be set before the database is opened. Moreover, User-defined comparators should be set every time the database is being opened.

setdfunit

public boolean setdfunit(int dfunit)
Set the unit step number of auto defragmentation.

Parameters:
dfunit - the unit step number. If it is not more than 0, the auto defragmentation is disabled. It is disabled by default.
Returns:
If successful, it is true, else, it is false.
Note:
The defragmentation parameters should be set before the database is opened.

setxmsiz

public boolean setxmsiz(long xmsiz)
Set the size of the extra mapped memory.

Parameters:
xmsiz - the size of the extra mapped memory. If it is not more than 0, the extra mapped memory is disabled. It is disabled by default.
Returns:
If successful, it is true, else, it is false.
Note:
The mapping parameters should be set before the database is opened.

sync

public boolean sync()
Synchronize updated contents with the file and the device.

Returns:
If successful, it is true, else, it is false.
Note:
This method is useful when another process connects the same database file.

tranabort

public boolean tranabort()
Abort the transaction.

Returns:
If successful, it is true, else, it is false.
Note:
Update in the transaction is discarded when it is aborted. The state of the database is rollbacked to before transaction.

tranbegin

public boolean tranbegin()
Begin the transaction.

Returns:
If successful, it is true, else, it is false.
Note:
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.

trancommit

public boolean trancommit()
Commit the transaction.

Returns:
If successful, it is true, else, it is false.
Note:
Update in the transaction is fixed when it is committed successfully.

tune

public boolean tune(int lmemb,
                    int nmemb,
                    long bnum,
                    int apow,
                    int fpow,
                    int opts)
Set the tuning parameters.

Parameters:
lmemb - the number of members in each leaf page. If it is not more than 0, the default value is specified. The default value is 128.
nmemb - the number of members in each non-leaf page. If it is not more than 0, the default value is specified. The default value is 256.
bnum - the number of elements of the bucket array. If it is 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.
apow - the size of record alignment by power of 2. If it is negative, the default value is specified. The default value is 8 standing for 2^8=256.
fpow - the maximum number of elements of the free block pool by power of 2. If it is negative, the default value is specified. The default value is 10 standing for 2^10=1024.
opts - options by bitwise-or: `BDB.TLARGE' specifies that the size of the database can be larger than 2GB by using 64-bit bucket array, `BDB.TDEFLATE' specifies that each record is compressed with Deflate encoding, `BDB.TBZIP' specifies that each record is compressed with BZIP2 encoding, `BDB.TTCBS' specifies that each record is compressed with TCBS encoding.
Returns:
If successful, it is true, else, it is false.
Note:
The tuning parameters of the database should be set before the database is opened.

vanish

public boolean vanish()
Remove all records.

Returns:
If successful, it is true, else, it is false.

vnum

public int vnum(byte[] key)
Get the number of records corresponding a key.

Parameters:
key - the key.
Returns:
If successful, it is the number of the corresponding records, else, it is 0.

vnum

public int vnum(java.lang.String key)
Get the number of records corresponding a key. The same as `vnum(key.getBytes())'.

See Also:
vnum(byte[])

vsiz

public int vsiz(byte[] key)
Get the size of the value of a record.

Parameters:
key - the key.
Returns:
If successful, it is the size of the value of the corresponding record, else, it is -1.
Note:
If the key of duplicated records is specified, the first one is selected.

vsiz

public int vsiz(java.lang.String key)
Get the size of the value of a record. The same as `vsiz(key.getBytes())'.

See Also:
vsiz(byte[])