⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tctdb.3

📁 Tokyo Cabinet的Tokyo Cabinet 是一个DBM的实现。这里的数据库由一系列key-value对的记录构成。key和value都可以是任意长度的字节序列,既可以是二进制也可以是字符
💻 3
📖 第 1 页 / 共 3 页
字号:
.TH "TCTDB" 3 "2009-02-13" "Man Page" "Tokyo Cabinet".SH NAMEtctdb \- the table database API.SH DESCRIPTION.PPTable database is a file containing records composed of the primary keys and arbitrary columns and is handled with the table database API..PPTo use the table database API, include `\fBtcutil.h\fR', `\fBtctdb.h\fR', and related standard header files.  Usually, write the following description near the front of a source file..PP.RS.br\fB#include <tcutil.h>\fR.br\fB#include <tctdb.h>\fR.br\fB#include <stdlib.h>\fR.br\fB#include <stdbool.h>\fR.br\fB#include <stdint.h>\fR.RE.PPObjects whose type is pointer to `\fBTCTDB\fR' are used to handle table databases.  A table database object is created with the function `\fBtctdbnew\fR' and is deleted with the function `\fBtctdbdel\fR'.  To avoid memory leak, it is important to delete every object when it is no longer in use..PPBefore operations to store or retrieve records, it is necessary to open a database file and connect the table database object to it.  The function `\fBtctdbopen\fR' is used to open a database file and the function `\fBtctdbclose\fR' is used to close the database file.  To avoid data missing or corruption, it is important to close every database file when it is no longer in use..SH API.PPThe function `tctdberrmsg' is used in order to get the message string corresponding to an error code..PP.RS.br\fBconst char *tctdberrmsg(int \fIecode\fB);\fR.RS`\fIecode\fR' specifies the error code..RE.RSThe return value is the message string of the error code..RE.RE.PPThe function `tctdbnew' is used in order to create a table database object..PP.RS.br\fBTCTDB *tctdbnew(void);\fR.RSThe return value is the new table database object..RE.RE.PPThe function `tctdbdel' is used in order to delete a table database object..PP.RS.br\fBvoid tctdbdel(TCTDB *\fItdb\fB);\fR.RS`\fItdb\fR' specifies the table database object..RE.RSIf the database is not closed, it is closed implicitly.  Note that the deleted object and its derivatives can not be used anymore..RE.RE.PPThe function `tctdbecode' is used in order to get the last happened error code of a table database object..PP.RS.br\fBint tctdbecode(TCTDB *\fItdb\fB);\fR.RS`\fItdb\fR' specifies the table database object..RE.RSThe return value is the last happened error code..RE.RSThe 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..RE.RE.PPThe function `tctdbsetmutex' is used in order to set mutual exclusion control of a table database object for threading..PP.RS.br\fBbool tctdbsetmutex(TCTDB *\fItdb\fB);\fR.RS`\fItdb\fR' specifies the table database object which is not opened..RE.RSIf successful, the return value is true, else, it is false..RE.RSNote that the mutual exclusion control is needed if the object is shared by plural threads and this function should should be called before the database is opened..RE.RE.PPThe function `tctdbtune' is used in order to set the tuning parameters of a table database object..PP.RS.br\fBbool tctdbtune(TCTDB *\fItdb\fB, int64_t \fIbnum\fB, int8_t \fIapow\fB, int8_t \fIfpow\fB, uint8_t \fIopts\fB);\fR.RS`\fItdb\fR' specifies the table database object which is not opened..RE.RS`\fIbnum\fR' specifies 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..RE.RS`\fIapow\fR' specifies 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..RE.RS`\fIfpow\fR' specifies 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..RE.RS`\fIopts\fR' specifies options by bitwise-or: `TDBTLARGE' specifies that the size of the database can be larger than 2GB by using 64\-bit bucket array, `TDBTDEFLATE' specifies that each record is compressed with Deflate encoding, `TDBTBZIP' specifies that each record is compressed with BZIP2 encoding, `TDBTTCBS' specifies that each record is compressed with TCBS encoding..RE.RSIf successful, the return value is true, else, it is false..RE.RSNote that the tuning parameters should be set before the database is opened..RE.RE.PPThe function `tctdbsetcache' is set the caching parameters of a table database object..PP.RS.br\fBbool tctdbsetcache(TCTDB *\fItdb\fB, int32_t \fIrcnum\fB, int32_t \fIlcnum\fB, int32_t \fIncnum\fB);\fR.RS`\fItdb\fR' specifies the table database object which is not opened..RE.RS`\fIrcnum\fR' specifies 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..RE.RS`\fIlcnum\fR' specifies 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 4096..RE.RS`\fIncnum\fR' specifies 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..RE.RSIf successful, the return value is true, else, it is false..RE.RSNote that the caching parameters should be set before the database is opened.  Leaf nodes and non\-leaf nodes are used in column indices..RE.RE.PPThe function `tctdbsetxmsiz' is used in order to set the size of the extra mapped memory of a table database object..PP.RS.br\fBbool tctdbsetxmsiz(TCTDB *\fItdb\fB, int64_t \fIxmsiz\fB);\fR.RS`\fItdb\fR' specifies the table database object which is not opened..RE.RS`\fIxmsiz\fR' specifies 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..RE.RSIf successful, the return value is true, else, it is false..RE.RSNote that the mapping parameters should be set before the database is opened..RE.RE.PPThe function `tctdbopen' is used in order to open a database file and connect a table database object..PP.RS.br\fBbool tctdbopen(TCTDB *\fItdb\fB, const char *\fIpath\fB, int \fIomode\fB);\fR.RS`\fItdb\fR' specifies the table database object which is not opened..RE.RS`\fIpath\fR' specifies the path of the database file..RE.RS`\fIomode\fR' specifies the connection mode: `TDBOWRITER' as a writer, `TDBOREADER' as a reader.  If the mode is `TDBOWRITER', the following may be added by bitwise-or: `TDBOCREAT', which means it creates a new database if not exist, `TDBOTRUNC', which means it creates a new database regardless if one exists, `TDBOTSYNC', which means every transaction synchronizes updated contents with the device.  Both of `TDBOREADER' and `TDBOWRITER' can be added to by bitwise-or: `TDBONOLCK', which means it opens the database file without file locking, or `TDBOLCKNB', which means locking is performed without blocking..RE.RSIf successful, the return value is true, else, it is false..RE.RE.PPThe function `tctdbclose' is used in order to close a table database object..PP.RS.br\fBbool tctdbclose(TCTDB *\fItdb\fB);\fR.RS`\fItdb\fR' specifies the table database object..RE.RSIf successful, the return value is true, else, it is false..RE.RSUpdate 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..RE.RE.PPThe function `tctdbput' is used in order to store a record into a table database object..PP.RS.br\fBbool tctdbput(TCTDB *\fItdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB, TCMAP *\fIcols\fB);\fR.RS`\fItdb\fR' specifies the table database object connected as a writer..RE.RS`\fIpkbuf\fR' specifies the pointer to the region of the primary key..RE.RS`\fIpksiz\fR' specifies the size of the region of the primary key..RE.RS`\fIcols\fR' specifies a map object containing columns..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, it is overwritten..RE.RE.PPThe function `tctdbput2' is used in order to store a string record into a table database object with a zero separated column string..PP.RS.br\fBbool tctdbput2(TCTDB *\fItdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB, const void *\fIcbuf\fB, int \fIcsiz\fB);\fR.RS`\fItdb\fR' specifies the table database object connected as a writer..RE.RS`\fIpkbuf\fR' specifies the pointer to the region of the primary key..RE.RS`\fIpksiz\fR' specifies the size of the region of the primary key..RE.RS`\fIcbuf\fR' specifies the pointer to the region of the zero separated column string where the name and the value of each column are situated one after the other..RE.RS`\fIcsiz\fR' specifies the size of the region of the column string..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, it is overwritten..RE.RE.PPThe function `tctdbput3' is used in order to store a string record into a table database object with a tab separated column string..PP.RS.br\fBbool tctdbput3(TCTDB *\fItdb\fB, const char *\fIpkstr\fB, const char *\fIcstr\fB);\fR.RS`\fItdb\fR' specifies the table database object connected as a writer..RE.RS`\fIpkstr\fR' specifies the string of the primary key..RE.RS`\fIcstr\fR' specifies the string of the the tab separated column string where the name and the value of each column are situated one after the other..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, it is overwritten..RE.RE.PPThe function `tctdbputkeep' is used in order to store a new record into a table database object..PP.RS.br\fBbool tctdbputkeep(TCTDB *\fItdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB, TCMAP *\fIcols\fB);\fR.RS`\fItdb\fR' specifies the table database object connected as a writer..RE.RS`\fIpkbuf\fR' specifies the pointer to the region of the primary key..RE.RS`\fIpksiz\fR' specifies the size of the region of the primary key..RE.RS`\fIcols\fR' specifies a map object containing columns..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, this function has no effect..RE.RE.PPThe function `tctdbputkeep2' is used in order to store a new string record into a table database object with a zero separated column string..PP.RS.br\fBbool tctdbputkeep2(TCTDB *\fItdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB, const void *\fIcbuf\fB, int \fIcsiz\fB);\fR.RS`\fItdb\fR' specifies the table database object connected as a writer..RE.RS`\fIpkbuf\fR' specifies the pointer to the region of the primary key..RE.RS`\fIpksiz\fR' specifies the size of the region of the primary key..RE.RS`\fIcbuf\fR' specifies the pointer to the region of the zero separated column string where the name and the value of each column are situated one after the other..RE.RS`\fIcsiz\fR' specifies the size of the region of the column string..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, this function has no effect..RE.RE.PPThe function `tctdbputkeep3' is used in order to store a new string record into a table database object with a tab separated column string..PP.RS.br\fBbool tctdbputkeep3(TCTDB *\fItdb\fB, const char *\fIpkstr\fB, const char *\fIcstr\fB);\fR.RS`\fItdb\fR' specifies the table database object connected as a writer..RE.RS`\fIpkstr\fR' specifies the string of the primary key..RE.RS`\fIcstr\fR' specifies the string of the the tab separated column string where the name and the value of each column are situated one after the other..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, this function has no effect.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -