table of contents
TCFDB(3) | Tokyo Cabinet | TCFDB(3) |
NAME¶
tcfdb - the fixed-length database APIDESCRIPTION¶
Fixed-length database is a file containing an array of fixed-length elements and is handled with the fixed-length database API. To use the fixed-length database API, include ` tcutil.h', `tcfdb.h', and related standard header files. Usually, write the following description near the front of a source file.API¶
The function `tcfdberrmsg' is used in order to get the message string corresponding to an error code.`ecode' specifies the error code.
The return value is the message string of the
error code.
The return value is the new fixed-length
database object.
`fdb' specifies the fixed-length
database object.
If the database is not closed, it is closed
implicitly. Note that the deleted object and its derivatives can not be used
anymore.
`fdb' specifies the fixed-length
database object.
The return value is the last happened error
code.
The following error codes are defined:
`TCESUCCESS' for success, `TCETHREAD' for threading error, `TCEINVALID' for
invalid operation, `TCENOFILE' for file not found, `TCENOPERM' for no
permission, `TCEMETA' for invalid meta data, `TCERHEAD' for invalid record
header, `TCEOPEN' for open error, `TCECLOSE' for close error, `TCETRUNC' for
trunc error, `TCESYNC' for sync error, `TCESTAT' for stat error, `TCESEEK' for
seek error, `TCEREAD' for read error, `TCEWRITE' for write error, `TCEMMAP'
for mmap error, `TCELOCK' for lock error, `TCEUNLINK' for unlink error,
`TCERENAME' for rename error, `TCEMKDIR' for mkdir error, `TCERMDIR' for rmdir
error, `TCEKEEP' for existing record, `TCENOREC' for no record found, and
`TCEMISC' for miscellaneous error.
`fdb' specifies the fixed-length
database object which is not opened.
If successful, the return value is true, else,
it is false.
Note that the mutual exclusion control is
needed if the object is shared by plural threads and this function should be
called before the database is opened.
`fdb' specifies the fixed-length
database object which is not opened.
`width' specifies 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' specifies the limit size of
the database file. If it is not more than 0, the default value is specified.
The default value is 268435456.
If successful, the return value is true, else,
it is false.
Note that the tuning parameters should be set
before the database is opened.
`fdb' specifies the fixed-length
database object which is not opened.
`path' specifies the path of the
database file.
`omode' specifies the connection mode:
`FDBOWRITER' as a writer, `FDBOREADER' as a reader. If the mode is
`FDBOWRITER', the following may be added by bitwise-or: `FDBOCREAT', which
means it creates a new database if not exist, `FDBOTRUNC', which means it
creates a new database regardless if one exists, `FDBOTSYNC', which means
every transaction synchronizes updated contents with the device. Both of
`FDBOREADER' and `FDBOWRITER' can be added to by bitwise-or: `FDBONOLCK',
which means it opens the database file without file locking, or `FDBOLCKNB',
which means locking is performed without blocking.
If successful, the return value is true, else,
it is false.
`fdb' specifies the fixed-length
database object.
If successful, the return value is true, else,
it is false.
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.
`fdb' specifies the fixed-length
database object connected as a writer.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDPREV', the number less by one than the minimum ID
number of existing records is specified. If it is `FDBIDMAX', the maximum ID
number of existing records is specified. If it is `FDBIDNEXT', the number
greater by one than the maximum ID number of existing records is
specified.
`vbuf' specifies the pointer to the
region of the value.
`vsiz' specifies the size of the region
of the value. If the size of the value is greater than the width tuning
parameter of the database, the size is cut down to the width.
If successful, the return value is true, else,
it is false.
If a record with the same key exists in the
database, it is overwritten.
`fdb' specifies the fixed-length
database object connected as a writer.
`kbuf' specifies the pointer to the
region of the decimal 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.
`ksiz' specifies the size of the region
of the key.
`vbuf' specifies the pointer to the
region of the value.
`vsiz' specifies the size of the region
of the value. If the size of the value is greater than the width tuning
parameter of the database, the size is cut down to the width.
If successful, the return value is true, else,
it is false.
If a record with the same key exists in the
database, it is overwritten.
`fdb' specifies the fixed-length
database object connected as a writer.
`kstr' specifies the string of the
decimal 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.
`vstr' specifies the string of the
value.
If successful, the return value is true, else,
it is false.
If a record with the same key exists in the
database, it is overwritten.
`fdb' specifies the fixed-length
database object connected as a writer.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDPREV', the number less by one than the minimum ID
number of existing records is specified. If it is `FDBIDMAX', the maximum ID
number of existing records is specified. If it is `FDBIDNEXT', the number
greater by one than the maximum ID number of existing records is
specified.
`vbuf' specifies the pointer to the
region of the value.
`vsiz' specifies the size of the region
of the value. If the size of the value is greater than the width tuning
parameter of the database, the size is cut down to the width.
If successful, the return value is true, else,
it is false.
If a record with the same key exists in the
database, this function has no effect.
`fdb' specifies the fixed-length
database object connected as a writer.
`kbuf' specifies the pointer to the
region of the decimal 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.
`ksiz' specifies the size of the region
of the key.
`vbuf' specifies the pointer to the
region of the value.
`vsiz' specifies the size of the region
of the value. If the size of the value is greater than the width tuning
parameter of the database, the size is cut down to the width.
If successful, the return value is true, else,
it is false.
If a record with the same key exists in the
database, this function has no effect.
`fdb' specifies the fixed-length
database object connected as a writer.
`kstr' specifies the string of the
decimal 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.
`vstr' specifies the string of the
value.
If successful, the return value is true, else,
it is false.
If a record with the same key exists in the
database, this function has no effect.
`fdb' specifies the fixed-length
database object connected as a writer.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDPREV', the number less by one than the minimum ID
number of existing records is specified. If it is `FDBIDMAX', the maximum ID
number of existing records is specified. If it is `FDBIDNEXT', the number
greater by one than the maximum ID number of existing records is
specified.
`vbuf' specifies the pointer to the
region of the value.
`vsiz' specifies the size of the region
of the value. If the size of the value is greater than the width tuning
parameter of the database, the size is cut down to the width.
If successful, the return value is true, else,
it is false.
If there is no corresponding record, a new
record is created.
`fdb' specifies the fixed-length
database object connected as a writer.
`kbuf' specifies the pointer to the
region of the decimal 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.
`ksiz' specifies the size of the region
of the key.
`vbuf' specifies the pointer to the
region of the value.
`vsiz' specifies the size of the region
of the value. If the size of the value is greater than the width tuning
parameter of the database, the size is cut down to the width.
If successful, the return value is true, else,
it is false.
If there is no corresponding record, a new
record is created.
`fdb' specifies the fixed-length
database object connected as a writer.
`kstr' specifies the string of the
decimal 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.
`vstr' specifies the string of the
value.
If successful, the return value is true, else,
it is false.
If there is no corresponding record, a new
record is created.
`fdb' specifies the fixed-length
database object connected as a writer.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDMAX', the maximum ID number of existing records
is specified.
If successful, the return value is true, else,
it is false.
`fdb' specifies the fixed-length
database object connected as a writer.
`kbuf' specifies the pointer to the
region of the decimal 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.
`ksiz' specifies the size of the region
of the key.
If successful, the return value is true, else,
it is false.
`fdb' specifies the fixed-length
database object connected as a writer.
`kstr' specifies the string of the
decimal 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.
If successful, the return value is true, else,
it is false.
`fdb' specifies the fixed-length
database object.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDMAX', the maximum ID number of existing records
is specified.
`sp' specifies the pointer to the
variable into which the size of the region of the return value is
assigned.
If successful, the return value is the pointer
to the region of the value of the corresponding record. `NULL' is returned if
no record corresponds.
Because an additional zero code is appended at
the end of the region of the return value, the return value can be treated as
a character string. Because the region of the return value is allocated with
the `malloc' call, it should be released with the `free' call when it is no
longer in use.
`fdb' specifies the fixed-length
database object.
`kbuf' specifies the pointer to the
region of the decimal 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.
`ksiz' specifies the size of the region
of the key.
`sp' specifies the pointer to the
variable into which the size of the region of the return value is
assigned.
If successful, the return value is the pointer
to the region of the value of the corresponding record. `NULL' is returned if
no record corresponds.
Because an additional zero code is appended at
the end of the region of the return value, the return value can be treated as
a character string. Because the region of the return value is allocated with
the `malloc' call, it should be released with the `free' call when it is no
longer in use.
`fdb' specifies the fixed-length
database object.
`kstr' specifies the string of the
decimal 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.
If successful, the return value is the string
of the value of the corresponding record. `NULL' is returned if no record
corresponds.
Because an additional zero code is appended at
the end of the region of the return value, the return value can be treated as
a character string. Because the region of the return value is allocated with
the `malloc' call, it should be released with the `free' call when it is no
longer in use.
`fdb' specifies the fixed-length
database object.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDMAX', the maximum ID number of existing records
is specified.
`vbuf' specifies the pointer to the
buffer into which the value of the corresponding record is written.
`max' specifies the size of the
buffer.
If successful, the return value is the size of
the written data, else, it is -1. -1 is returned if no record corresponds to
the specified key.
Note that an additional zero code is not
appended at the end of the region of the writing buffer.
`fdb' specifies the fixed-length
database object.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDMAX', the maximum ID number of existing records
is specified.
If successful, the return value is the size of
the value of the corresponding record, else, it is -1.
`fdb' specifies the fixed-length
database object.
`kbuf' specifies the pointer to the
region of the decimal 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.
`ksiz' specifies the size of the region
of the key.
If successful, the return value is the size of
the value of the corresponding record, else, it is -1.
`fdb' specifies the fixed-length
database object.
`kstr' specifies the string of the
decimal 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.
If successful, the return value is the size of
the value of the corresponding record, else, it is -1.
`fdb' specifies the fixed-length
database object.
If successful, the return value is true, else,
it is false.
The iterator is used in order to access the
key of every record stored in a database.
`fdb' specifies the fixed-length
database object.
If successful, the return value is the next ID
number of the iterator, else, it is 0. 0 is returned when no record is to be
get out of the iterator.
It is possible to access every record by
iteration of calling this function. 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.
`fdb' specifies the fixed-length
database object.
`sp' specifies the pointer to the
variable into which the size of the region of the return value is
assigned.
If successful, the return value is the pointer
to the region of the next decimal key, else, it is `NULL'. `NULL' is returned
when no record is to be get out of the iterator.
Because an additional zero code is appended at
the end of the region of the return value, the return value can be treated as
a character string. Because the region of the return value is allocated with
the `malloc' call, it should be released with the `free' call when it is no
longer in use. It is possible to access every record by iteration of calling
this function. 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.
`fdb' specifies the fixed-length
database object.
If successful, the return value is the string
of the next decimal key, else, it is `NULL'. `NULL' is returned when no record
is to be get out of the iterator.
Because the region of the return value is
allocated with the `malloc' call, it should be released with the `free' call
when it is no longer in use. It is possible to access every record by
iteration of calling this function. 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.
`fdb' specifies the fixed-length
database object.
`lower' specifies the lower limit of
the range. If it is `FDBIDMIN', the minimum ID is specified.
`upper' specifies the upper limit of
the range. If it is `FDBIDMAX', the maximum ID is specified.
`max' specifies the maximum number of
keys to be fetched. If it is negative, no limit is specified.
`np' specifies the pointer to the
variable into which the number of elements of the return value is
assigned.
If successful, the return value is the pointer
to an array of ID numbers of the corresponding records. `NULL' is returned on
failure. This function does never fail. It returns an empty array even if no
key corresponds.
Because the region of the return value is
allocated with the `malloc' call, it should be released with the `free' call
when it is no longer in use.
`fdb' specifies the fixed-length
database object.
`lbuf' specifies the pointer to the
region of the lower key. If it is "min", the minimum ID number of
existing records is specified.
`lsiz' specifies the size of the region
of the lower key.
`ubuf' specifies the pointer to the
region of the upper key. If it is "max", the maximum ID number of
existing records is specified.
`usiz' specifies the size of the region
of the upper key.
`max' specifies the maximum number of
keys to be fetched. If it is negative, no limit is specified.
The return value is a list object of the
corresponding decimal keys. This function does never fail. It returns an empty
list even if no key corresponds.
Because the object of the return value is
created with the function `tclistnew', it should be deleted with the function
`tclistdel' when it is no longer in use. Note that this function may be very
slow because every key in the database is scanned.
`fdb' specifies the fixed-length
database object.
`lstr' specifies the string of the
lower key. If it is "min", the minimum ID number of existing records
is specified.
`ustr' specifies the string of the
upper key. If it is "max", the maximum ID number of existing records
is specified.
`max' specifies the maximum number of
keys to be fetched. If it is negative, no limit is specified.
The return value is a list object of the
corresponding decimal keys. This function does never fail. It returns an empty
list even if no key corresponds.
Because the object of the return value is
created with the function `tclistnew', it should be deleted with the function
`tclistdel' when it is no longer in use. Note that this function may be very
slow because every key in the database is scanned.
`fdb' specifies the fixed-length
database object.
`ibuf' specifies the pointer to the
region of the interval notation.
`isiz' specifies the size of the region
of the interval notation.
`max' specifies the maximum number of
keys to be fetched. If it is negative, no limit is specified.
The return value is a list object of the
corresponding decimal keys. This function does never fail. It returns an empty
list even if no key corresponds.
Because the object of the return value is
created with the function `tclistnew', it should be deleted with the function
`tclistdel' when it is no longer in use. Note that this function may be very
slow because every key in the database is scanned.
`fdb' specifies the fixed-length
database object.
`istr' specifies the pointer to the
region of the interval notation string.
`max' specifies the maximum number of
keys to be fetched. If it is negative, no limit is specified.
The return value is a list object of the
corresponding decimal keys. This function does never fail. It returns an empty
list even if no key corresponds.
Because the object of the return value is
created with the function `tclistnew', it should be deleted with the function
`tclistdel' when it is no longer in use. Note that this function may be very
slow because every key in the database is scanned.
`fdb' specifies the fixed-length
database object connected as a writer.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDPREV', the number less by one than the minimum ID
number of existing records is specified. If it is `FDBIDMAX', the maximum ID
number of existing records is specified. If it is `FDBIDNEXT', the number
greater by one than the maximum ID number of existing records is
specified.
`num' specifies the additional
value.
If successful, the return value is the
summation value, else, it is `INT_MIN'.
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.
`fdb' specifies the fixed-length
database object connected as a writer.
`id' specifies the ID number. It should
be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records
is specified. If it is `FDBIDPREV', the number less by one than the minimum ID
number of existing records is specified. If it is `FDBIDMAX', the maximum ID
number of existing records is specified. If it is `FDBIDNEXT', the number
greater by one than the maximum ID number of existing records is
specified.
`num' specifies the additional
value.
If successful, the return value is the
summation value, else, it is Not-a-Number.
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.
`fdb' specifies the fixed-length
database object connected as a writer.
If successful, the return value is true, else,
it is false.
This function is useful when another process
connects to the same database file.
`fdb' specifies the fixed-length
database object connected as a writer.
`width' specifies the width of the
value of each record. If it is not more than 0, the current setting is not
changed.
`limsiz' specifies the limit size of
the database file. If it is not more than 0, the current setting is not
changed.
If successful, the return value is true, else,
it is false.
`fdb' specifies the fixed-length
database object connected as a writer.
If successful, the return value is true, else,
it is false.
`fdb' specifies the fixed-length
database object.
`path' specifies the path of the
destination file. If it begins with `@', the trailing substring is executed as
a command line.
If successful, the return value is true, else,
it is false. False is returned if the executed command returns non-zero
code.
The database file is assured to be kept
synchronized and not modified while the copying or executing operation is in
progress. So, this function is useful to create a backup file of the database
file.
`fdb' specifies the fixed-length
database object connected as a writer.
If successful, the return value is true, else,
it is false.
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.
`fdb' specifies the fixed-length
database object connected as a writer.
If successful, the return value is true, else,
it is false.
Update in the transaction is fixed when it is
committed successfully.
`fdb' specifies the fixed-length
database object connected as a writer.
If successful, the return value is true, else,
it is false.
Update in the transaction is discarded when it
is aborted. The state of the database is rollbacked to before
transaction.
`fdb' specifies the fixed-length
database object.
The return value is the path of the database
file or `NULL' if the object does not connect to any database file.
`fdb' specifies the fixed-length
database object.
The return value is the number of records or 0
if the object does not connect to any database file.
`fdb' specifies the fixed-length
database object.
The return value is the size of the database
file or 0 if the object does not connect to any database file.
SEE ALSO¶
tcftest(1), tcfmttest(1), tcfmgr(1), tokyocabinet(3)2011-02-12 | Man Page |