|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttokyocabinet.FDB
public class FDB
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. To avoid data missing or corruption, it is important to close every database file when it is no longer in use.
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 |
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 |
OWRITER
open mode: open as a writer |
Constructor Summary | |
---|---|
FDB()
Create a fixed-length 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. |
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 width,
long limsiz)
Optimize the database file. |
boolean |
out(byte[] key)
Remove a record. |
boolean |
out(java.lang.String key)
Remove a record. |
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 |
putkeep(byte[] key,
byte[] value)
Store a new record. |
boolean |
putkeep(java.lang.String key,
java.lang.String value)
Store a new record. |
java.util.List |
range(byte[] interval,
int max)
Get keys with an interval notation. |
java.util.List |
range(java.lang.String interval,
int max)
Get keys with an interval notation. |
long |
rnum()
Get the number of records. |
boolean |
sync()
Synchronize updated contents with the file and the device. |
boolean |
tune(int width,
long limsiz)
Set the tuning parameters. |
boolean |
vanish()
Remove all records. |
static java.lang.String |
version()
Get the string containing the version information. |
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 |
---|
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 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 OWRITER
Constructor Detail |
---|
public FDB()
Method Detail |
---|
public double adddouble(byte[] key, double num)
adddouble
in interface DBM
key
- the key. It should be more than 0. If it is "min", the minimum ID number of
existing records is specified. If it is "prev", the number less by one than the minimum ID
number of existing records is specified. If it is "max", the maximum ID number of existing
records is specified. If it is "next", the number greater by one than the maximum ID number
of existing records is specified.num
- the additional value.
public double adddouble(java.lang.String key, double num)
adddouble
in interface DBM
adddouble(byte[], double)
public int addint(byte[] key, int num)
addint
in interface DBM
key
- the key. It should be more than 0. If it is "min", the minimum ID number of
existing records is specified. If it is "prev", the number less by one than the minimum ID
number of existing records is specified. If it is "max", the maximum ID number of existing
records is specified. If it is "next", the number greater by one than the maximum ID number
of existing records is specified.num
- the additional value.
public int addint(java.lang.String key, int num)
addint
in interface DBM
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()
fsiz
in interface DBM
public java.util.List fwmkeys(byte[] prefix, int max)
fwmkeys
in interface DBM
prefix
- the prefix of the corresponding keys.max
- the maximum number of keys to be fetched. If it is negative, no limit is
specified.
range(byte[], int)
public java.util.List fwmkeys(java.lang.String prefix, int max)
fwmkeys
in interface DBM
range(String, int)
public byte[] get(byte[] key)
get
in interface DBM
key
- the key. It should be more than 0. If it is "min", the minimum ID number of
existing records is specified. If it is "max", the maximum ID number of existing records
is specified.
public java.lang.String get(java.lang.String key)
get
in interface DBM
get(byte[])
public boolean iterinit()
iterinit
in interface DBM
public byte[] iternext()
iternext
in interface DBM
public java.lang.String iternext2()
iternext2
in interface DBM
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: `FDB.OWRITER' as a writer, `FDB.OREADER' as a reader. If
the mode is `FDB.OWRITER', the following may be added by bitwise or: `FDB.OCREAT', which
means it creates a new database if not exist, `FDB.OTRUNC', which means it creates a new
database regardless if one exists. Both of `FDB.OREADER' and `FDB.OWRITER' can be added to
by bitwise or: `FDB.ONOLCK', which means it opens the database file without file locking, or
`FDB.OLCKNB', which means locking is performed without blocking.
public boolean optimize()
optimize(int, long)
public boolean optimize(int width, long limsiz)
width
- the width of the value of each record. If it is not more than 0, the current
setting is not changed.limsiz
- the limit size of the database file. If it is not more than 0, the current
setting is not changed.
public boolean out(byte[] key)
out
in interface DBM
key
- the key. It should be more than 0. If it is "min", the minimum ID number of
existing records is specified. If it is "max", the maximum ID number of existing records
is specified.
public boolean out(java.lang.String key)
out
in interface DBM
out(byte[])
public java.lang.String path()
public boolean put(byte[] key, byte[] value)
put
in interface DBM
key
- the key. It should be more than 0. If it is "min", the minimum ID number of
existing records is specified. If it is "prev", the number less by one than the minimum ID
number of existing records is specified. If it is "max", the maximum ID number of existing
records is specified. If it is "next", the number greater by one than the maximum ID number
of existing records is specified.value
- the value.
public boolean put(java.lang.String key, java.lang.String value)
put
in interface DBM
put(byte[], byte[])
public boolean putcat(byte[] key, byte[] value)
key
- the key. It should be more than 0. If it is "min", the minimum ID number of
existing records is specified. If it is "prev", the number less by one than the minimum ID
number of existing records is specified. If it is "max", the maximum ID number of existing
records is specified. If it is "next", the number greater by one than the maximum ID number
of existing records is specified.value
- the value.
public boolean putcat(java.lang.String key, java.lang.String value)
putcat(byte[], byte[])
public boolean putkeep(byte[] key, byte[] value)
putkeep
in interface DBM
key
- the key. It should be more than 0. If it is "min", the minimum ID number of
existing records is specified. If it is "prev", the number less by one than the minimum ID
number of existing records is specified. If it is "max", the maximum ID number of existing
records is specified. If it is "next", the number greater by one than the maximum ID number
of existing records is specified.value
- the value.
public boolean putkeep(java.lang.String key, java.lang.String value)
putkeep
in interface DBM
putkeep(byte[], byte[])
public java.util.List range(byte[] interval, int max)
interval
- the interval notation.max
- the maximum number of keys to be fetched. If it is negative, no limit is
specified.
public java.util.List range(java.lang.String interval, int max)
range(byte[], int)
public long rnum()
rnum
in interface DBM
public boolean sync()
public boolean tune(int width, long limsiz)
width
- the width of the value of each record. If it is not more than 0, the default
value is specified. The default value is 255.limsiz
- the limit size of the database file. If it is not more than 0, the default
value is specified. The default value is 268435456.
public boolean vanish()
public static java.lang.String version()
public int vsiz(byte[] key)
key
- the key. It should be more than 0. If it is "min", the minimum ID number of
existing records is specified. If it is "max", the maximum ID number of existing records
is specified.
public int vsiz(java.lang.String key)
vsiz(byte[])
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |