tokyocabinet
Interface DBM

All Known Implementing Classes:
ADB, BDB, FDB, HDB

public interface DBM

Common interface of DBM.


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 The same as `adddouble(key.getBytes(), num)'.
 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 The same as `addint(key.getBytes(), num)'.
 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.
 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 out(byte[] key)
          Remove a record.
 boolean out(java.lang.String key)
          Remove a record.
 boolean put(byte[] key, byte[] value)
          Store a record.
 boolean put(java.lang.String key, java.lang.String value)
          Store a record.
 boolean putkeep(byte[] key, byte[] value)
          Store a new record.
 boolean putkeep(java.lang.String key, java.lang.String value)
          Store a new record.
 long rnum()
          Get the number of records.
 

Method Detail

adddouble

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

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

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

See Also:
adddouble(byte[], double)

addint

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

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

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

See Also:
addint(byte[], int)

fsiz

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

Returns:
the size of the database file or 0 if the object does not connect to any database file.

fwmkeys

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

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.
Note:
This function may be very slow because every key in the database is scanned.

fwmkeys

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

See Also:
fwmkeys(byte[], int)

get

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

Parameters:
key - the key.
Returns:
If successful, it is the value of the corresponding record. `null' is returned if no record corresponds.

get

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

See Also:
get(byte[])

iterinit

boolean iterinit()
Initialize the iterator.

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

iternext

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

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

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

See Also:
iternext()

out

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

Parameters:
key - the key.
Returns:
If successful, it is true, else, it is false.

out

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

See Also:
out(byte[])

put

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

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

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

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

putkeep

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

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

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

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

rnum

long rnum()
Get the number of records.

Returns:
the number of records or 0 if the object does not connect to any database file.