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

📄 tchdb.h

📁 Tokyo Cabinet的Tokyo Cabinet 是一个DBM的实现。这里的数据库由一系列key-value对的记录构成。key和value都可以是任意长度的字节序列,既可以是二进制也可以是字符
💻 H
📖 第 1 页 / 共 3 页
字号:
   `hdb' specifies the hash database object connected as a writer.   `kbuf' specifies the pointer to the region of the key.   `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 successful, the return value is true, else, it is false.   If there is no corresponding record, a new record is created. */bool tchdbputcat(TCHDB *hdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Concatenate a string value at the end of the existing record in a hash database object.   `hdb' specifies the hash database object connected as a writer.   `kstr' specifies the string of the key.   `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. */bool tchdbputcat2(TCHDB *hdb, const char *kstr, const char *vstr);/* Store a record into a hash database object in asynchronous fashion.   `hdb' specifies the hash database object connected as a writer.   `kbuf' specifies the pointer to the region of the key.   `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 successful, the return value is true, else, it is false.   If a record with the same key exists in the database, it is overwritten.  Records passed to   this function are accumulated into the inner buffer and wrote into the file at a blast. */bool tchdbputasync(TCHDB *hdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a string record into a hash database object in asynchronous fashion.   `hdb' specifies the hash database object connected as a writer.   `kstr' specifies the string of the key.   `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.  Records passed to   this function are accumulated into the inner buffer and wrote into the file at a blast. */bool tchdbputasync2(TCHDB *hdb, const char *kstr, const char *vstr);/* Remove a record of a hash database object.   `hdb' specifies the hash database object connected as a writer.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   If successful, the return value is true, else, it is false. */bool tchdbout(TCHDB *hdb, const void *kbuf, int ksiz);/* Remove a string record of a hash database object.   `hdb' specifies the hash database object connected as a writer.   `kstr' specifies the string of the key.   If successful, the return value is true, else, it is false. */bool tchdbout2(TCHDB *hdb, const char *kstr);/* Retrieve a record in a hash database object.   `hdb' specifies the hash database object.   `kbuf' specifies the pointer to the region of the key.   `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. */void *tchdbget(TCHDB *hdb, const void *kbuf, int ksiz, int *sp);/* Retrieve a string record in a hash database object.   `hdb' specifies the hash database object.   `kstr' specifies the string of the key.   If successful, the return value is the string of the value of the corresponding record.   `NULL' is returned if no record 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. */char *tchdbget2(TCHDB *hdb, const char *kstr);/* Retrieve a record in a hash database object and write the value into a buffer.   `hdb' specifies the hash database object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `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. */int tchdbget3(TCHDB *hdb, const void *kbuf, int ksiz, void *vbuf, int max);/* Get the size of the value of a record in a hash database object.   `hdb' specifies the hash database object.   `kbuf' specifies the pointer to the region of the key.   `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. */int tchdbvsiz(TCHDB *hdb, const void *kbuf, int ksiz);/* Get the size of the value of a string record in a hash database object.   `hdb' specifies the hash database object.   `kstr' specifies the string of the key.   If successful, the return value is the size of the value of the corresponding record, else,   it is -1. */int tchdbvsiz2(TCHDB *hdb, const char *kstr);/* Initialize the iterator of a hash database object.   `hdb' specifies the hash 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. */bool tchdbiterinit(TCHDB *hdb);/* Get the next key of the iterator of a hash database object.   `hdb' specifies the hash 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 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.   However, it is not assured if updating the database is occurred while the iteration.  Besides,   the order of this traversal access method is arbitrary, so it is not assured that the order of   storing matches the one of the traversal access. */void *tchdbiternext(TCHDB *hdb, int *sp);/* Get the next key string of the iterator of a hash database object.   `hdb' specifies the hash database object.   If successful, the return value is the string of the next 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.  However, it is not assured if updating the   database is occurred while the iteration.  Besides, the order of this traversal access method   is arbitrary, so it is not assured that the order of storing matches the one of the traversal   access. */char *tchdbiternext2(TCHDB *hdb);/* Get the next extensible objects of the iterator of a hash database object.   `hdb' specifies the hash database object.   `kxstr' specifies the object into which the next key is wrote down.   `vxstr' specifies the object into which the next value is wrote down.   If successful, the return value is true, else, it is false.  False is returned when no record   is to be get out of the iterator. */bool tchdbiternext3(TCHDB *hdb, TCXSTR *kxstr, TCXSTR *vxstr);/* Get forward matching keys in a hash database object.   `hdb' specifies the hash database object.   `pbuf' specifies the pointer to the region of the prefix.   `psiz' specifies the size of the region of the prefix.   `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 keys.  This function does never fail   and return 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. */TCLIST *tchdbfwmkeys(TCHDB *hdb, const void *pbuf, int psiz, int max);/* Get forward matching string keys in a hash database object.   `hdb' specifies the hash database object.   `pstr' specifies the string of the prefix.   `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 keys.  This function does never fail   and return 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. */TCLIST *tchdbfwmkeys2(TCHDB *hdb, const char *pstr, int max);/* Add an integer to a record in a hash database object.   `hdb' specifies the hash database object connected as a writer.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `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. */int tchdbaddint(TCHDB *hdb, const void *kbuf, int ksiz, int num);/* Add a real number to a record in a hash database object.   `hdb' specifies the hash database object connected as a writer.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `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. */double tchdbadddouble(TCHDB *hdb, const void *kbuf, int ksiz, double num);/* Synchronize updated contents of a hash database object with the file and the device.   `hdb' specifies the hash 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. */bool tchdbsync(TCHDB *hdb);/* Optimize the file of a hash database object.   `hdb' specifies the hash database object connected as a writer.   `bnum' 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 two times of the number of records.   `apow' specifies the size of record alignment by power of 2.  If it is negative, the current   setting is not changed.   `fpow' specifies 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' specifies options by bitwise-or: `HDBTLARGE' specifies that the size of the database   can be larger than 2GB by using 64-bit bucket array, `HDBTDEFLATE' specifies that each record   is compressed with Deflate encoding, `HDBTBZIP' specifies that each record is compressed with   BZIP2 encoding, `HDBTTCBS' specifies that each record is compressed with TCBS encoding.  If it   is `UINT8_MAX', the current setting is not changed.   If successful, the return value is true, else, it is false.   This function is useful to reduce the size of the database file with data fragmentation by   successive updating. */bool tchdboptimize(TCHDB *hdb, int64_t bnum, int8_t apow, int8_t fpow, uint8_t opts);/* Remove all records of a hash database object.   `hdb' specifies the hash database object connected as a writer.   If successful, the return value is true, else, it is false. */bool tchdbvanish(TCHDB *hdb);/* Copy the database file of a hash database object.   `hdb' specifies the hash 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. */bool tchdbcopy(TCHDB *hdb, const char *path);/* Begin the transaction of a hash database object.   `hdb' specifies the hash 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. */bool tchdbtranbegin(TCHDB *hdb);/* Commit the transaction of a hash database object.   `hdb' specifies the hash 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. */bool tchdbtrancommit(TCHDB *hdb);/* Abort the transaction of a hash database object.   `hdb' specifies the hash 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. */bool tchdbtranabort(TCHDB *hdb);

⌨️ 快捷键说明

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