|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttokyocabinet.TDB
public class TDB
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. 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 |
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 |
ITDECIMAL
index type: decimal string |
static int |
ITKEEP
index type: keep existing index |
static int |
ITLEXICAL
index type: lexical string |
static int |
ITOPT
index type: optimize |
static int |
ITQGRAM
index type: q-gram inverted index |
static int |
ITTOKEN
index type: token inverted index |
static int |
ITVOID
index type: void |
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 | |
---|---|
TDB()
Create a hash database object. |
Method Summary | |
---|---|
double |
adddouble(byte[] pkey,
double num)
Add a real number to a record. |
double |
adddouble(java.lang.String pkey,
double num)
Add a real number to a record. |
int |
addint(byte[] pkey,
int num)
Add an integer to a record. |
int |
addint(java.lang.String pkey,
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 primary keys. |
java.util.List |
fwmkeys(java.lang.String prefix,
int max)
Get forward matching primary keys. |
long |
genuid()
Generate a unique ID number. |
java.util.Map |
get(byte[] pkey)
Retrieve a record. |
java.util.Map |
get(java.lang.String pkey)
Retrieve a record. |
boolean |
iterinit()
Initialize the iterator. |
byte[] |
iternext()
Get the next primary key of the iterator. |
java.lang.String |
iternext2()
Get the next primary 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(long bnum,
int apow,
int fpow,
int opts)
Optimize the database file. |
boolean |
out(byte[] pkey)
Remove a record. |
boolean |
out(java.lang.String pkey)
Remove a record. |
java.lang.String |
path()
Get the path of the database file. |
boolean |
put(byte[] pkey,
java.util.Map cols)
Store a record. |
boolean |
put(java.lang.String pkey,
java.util.Map cols)
Store a record. |
boolean |
putcat(byte[] pkey,
java.util.Map cols)
Concatenate columns of the existing record. |
boolean |
putcat(java.lang.String pkey,
java.util.Map cols)
Concatenate columns of the existing record. |
boolean |
putkeep(byte[] pkey,
java.util.Map cols)
Store a new record. |
boolean |
putkeep(java.lang.String pkey,
java.util.Map cols)
Store a new record. |
long |
rnum()
Get the number of records. |
boolean |
setcache(int rcnum,
int lcnum,
int ncnum)
Set the caching parameters. |
boolean |
setdfunit(int dfunit)
Set the unit step number of auto defragmentation. |
boolean |
setindex(java.lang.String name,
int type)
Set a column index. |
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(long bnum,
int apow,
int fpow,
int opts)
Set the tuning parameters. |
boolean |
vanish()
Remove all records. |
int |
vsiz(byte[] pkey)
Get the size of the value of a record. |
int |
vsiz(java.lang.String pkey)
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 |
---|
public static final int ECLOSE
public static final int EINVALID
public static final int EKEEP
public static final int ELOCK
public static final int EMETA
public static final int EMISC
public static final int EMKDIR
public static final int EMMAP
public static final int ENOFILE
public static final int ENOPERM
public static final int ENOREC
public static final int EOPEN
public static final int EREAD
public static final int ERENAME
public static final int ERHEAD
public static final int ERMDIR
public static final int ESEEK
public static final int ESTAT
public static final int ESUCCESS
public static final int ESYNC
public static final int ETHREAD
public static final int ETRUNC
public static final int EUNLINK
public static final int EWRITE
public static final int ITDECIMAL
public static final int ITKEEP
public static final int ITLEXICAL
public static final int ITOPT
public static final int ITQGRAM
public static final int ITTOKEN
public static final int ITVOID
public static final int OCREAT
public static final int OLCKNB
public static final int ONOLCK
public static final int OREADER
public static final int OTRUNC
public static final int OTSYNC
public static final int OWRITER
public static final int TBZIP
public static final int TDEFLATE
public static final int TLARGE
public static final int TTCBS
Constructor Detail |
---|
public TDB()
Method Detail |
---|
public double adddouble(byte[] pkey, double num)
pkey
- the primary key.num
- the additional value.
public double adddouble(java.lang.String pkey, double num)
adddouble(byte[], double)
public int addint(byte[] pkey, int num)
pkey
- the primary key.num
- the additional value.
public int addint(java.lang.String pkey, int num)
addint(byte[], int)
public boolean close()
public boolean copy(java.lang.String path)
path
- the path of the destination file. If it begins with `@', the trailing substring
is executed as a command line.
public int ecode()
public java.lang.String errmsg()
public static java.lang.String errmsg(int ecode)
ecode
- the error code.
protected void finalize()
finalize
in class java.lang.Object
public long fsiz()
public java.util.List fwmkeys(byte[] prefix, int max)
prefix
- the prefix of the corresponding keys.max
- the maximum number of keys to be fetched. If it is negative, no limit is
specified.
public java.util.List fwmkeys(java.lang.String prefix, int max)
fwmkeys(byte[], int)
public long genuid()
public java.util.Map get(byte[] pkey)
pkey
- the primary key.
public java.util.Map get(java.lang.String pkey)
get(byte[])
public boolean iterinit()
public byte[] iternext()
public java.lang.String iternext2()
iternext()
public boolean open(java.lang.String name)
open(String, int)
public boolean open(java.lang.String path, int omode)
path
- the path of the database file.omode
- the connection mode: `TDB.OWRITER' as a writer, `TDB.OREADER' as a reader. If
the mode is `TDB.OWRITER', the following may be added by bitwise-or: `TDB.OCREAT', which
means it creates a new database if not exist, `TDB.OTRUNC', which means it creates a new
database regardless if one exists, `TDB.OTSYNC', which means every transaction synchronizes
updated contents with the device. Both of `TDB.OREADER' and `TDB.OWRITER' can be added to
by bitwise-or: `TDB.ONOLCK', which means it opens the database file without file locking, or
`TDB.OLCKNB', which means locking is performed without blocking.
public boolean optimize()
optimize(long, int, int, int)
public boolean optimize(long bnum, int apow, int fpow, int opts)
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 records.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: `TDB.TLARGE' specifies that the size of the database can
be larger than 2GB by using 64-bit bucket array, `TDB.TDEFLATE' specifies that each record
is compressed with Deflate encoding, `TDB.TBZIP' specifies that each record is compressed
with BZIP2 encoding, `TDB.TTCBS' specifies that each record is compressed with TCBS
encoding. If it is 0xff, the current setting is not changed.
public boolean out(byte[] pkey)
pkey
- the primary key.
public boolean out(java.lang.String pkey)
out(byte[])
public java.lang.String path()
public boolean put(byte[] pkey, java.util.Map cols)
pkey
- the primary key.cols
- a map object containing columns. Type of each key is `String'. Type of each
value is `byte[]'.
public boolean put(java.lang.String pkey, java.util.Map cols)
put(byte[], Map)
public boolean putcat(byte[] pkey, java.util.Map cols)
pkey
- the primary key.cols
- a map object containing columns. Type of each key is `String'. Type of each
value is `byte[]'.
public boolean putcat(java.lang.String pkey, java.util.Map cols)
putcat(byte[], Map)
public boolean putkeep(byte[] pkey, java.util.Map cols)
pkey
- the primary key.cols
- a map object containing columns. Type of each key is `String'. Type of each
value is `byte[]'.
public boolean putkeep(java.lang.String pkey, java.util.Map cols)
putkeep(byte[], Map)
public long rnum()
public boolean setcache(int rcnum, int lcnum, int ncnum)
rcnum
- the maximum number of records to be cached. If it is not more than 0, the
record cache is disabled. It is disabled by default.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.
public boolean setdfunit(int dfunit)
dfunit
- the unit step number. If it is not more than 0, the auto defragmentation is
disabled. It is disabled by default.
public boolean setindex(java.lang.String name, int type)
name
- 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.type
- the index type: `TDB.ITLEXICAL' for lexical string, `TDB.ITDECIMAL' for decimal
string, `TDB.ITTOKEN' for token inverted index, `TDB.ITQGRAM' for q-gram inverted index.
If it is `TDB.ITOPT', the index is optimized. If it is `TDB.ITVOID', the index is removed.
If `TDB.ITKEEP' is added by bitwise-or and the index exists, this method merely returns
failure.
public boolean setxmsiz(long xmsiz)
xmsiz
- the size of the extra mapped memory. If it is not more than 0, the extra
mapped memory is disabled. The default size is 67108864.
public boolean sync()
public boolean tranabort()
public boolean tranbegin()
public boolean trancommit()
public boolean tune(long bnum, int apow, int fpow, int opts)
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 131071. Suggested size of the bucket
array is about from 0.5 to 4 times of the number of all records 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 4 standing for 2^4=16.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: `TDB.TLARGE' specifies that the size of the database can
be larger than 2GB by using 64-bit bucket array, `TDB.TDEFLATE' specifies that each record
is compressed with Deflate encoding, `TDB.TBZIP' specifies that each record is compressed
with BZIP2 encoding, `TDB.TTCBS' specifies that each record is compressed with TCBS
encoding.
public boolean vanish()
public int vsiz(byte[] pkey)
pkey
- the primary key.
public int vsiz(java.lang.String pkey)
vsiz(byte[])
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |