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

📄 tcadb.h

📁 Tokyo Cabinet的Tokyo Cabinet 是一个DBM的实现。这里的数据库由一系列key-value对的记录构成。key和value都可以是任意长度的字节序列,既可以是二进制也可以是字符
💻 H
📖 第 1 页 / 共 2 页
字号:
   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 *tcadbiternext(TCADB *adb, int *sp);/* Get the next key string of the iterator of an abstract database object.   `adb' specifies the abstract 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 *tcadbiternext2(TCADB *adb);/* Get forward matching keys in an abstract database object.   `adb' specifies the abstract 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 *tcadbfwmkeys(TCADB *adb, const void *pbuf, int psiz, int max);/* Get forward matching string keys in an abstract database object.   `adb' specifies the abstract 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 *tcadbfwmkeys2(TCADB *adb, const char *pstr, int max);/* Add an integer to a record in an abstract database object.   `adb' specifies the abstract database object.   `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 tcadbaddint(TCADB *adb, const void *kbuf, int ksiz, int num);/* Add a real number to a record in an abstract database object.   `adb' specifies the abstract database object.   `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 tcadbadddouble(TCADB *adb, const void *kbuf, int ksiz, double num);/* Synchronize updated contents of an abstract database object with the file and the device.   `adb' specifies the abstract database object.   If successful, the return value is true, else, it is false. */bool tcadbsync(TCADB *adb);/* Optimize the storage of an abstract database object.   `adb' specifies the abstract database object.   `params' specifies the string of the tuning parameters, which works as with the tuning   of parameters the function `tcadbopen'.  If it is `NULL', it is not used.   If successful, the return value is true, else, it is false.   This function is useful to reduce the size of the database storage with data fragmentation by   successive updating. */bool tcadboptimize(TCADB *adb, const char *params);/* Remove all records of an abstract database object.   `adb' specifies the abstract database object.   If successful, the return value is true, else, it is false. */bool tcadbvanish(TCADB *adb);/* Copy the database file of an abstract database object.   `adb' specifies the abstract 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 tcadbcopy(TCADB *adb, const char *path);/* Begin the transaction of an abstract database object.   `adb' specifies the abstract database object.   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 tcadbtranbegin(TCADB *adb);/* Commit the transaction of an abstract database object.   `adb' specifies the abstract database object.   If successful, the return value is true, else, it is false.   Update in the transaction is fixed when it is committed successfully. */bool tcadbtrancommit(TCADB *adb);/* Abort the transaction of an abstract database object.   `adb' specifies the abstract database object.   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 tcadbtranabort(TCADB *adb);/* Get the file path of an abstract database object.   `adb' specifies the abstract database object.   The return value is the path of the database file or `NULL' if the object does not connect to   any database.  "*" stands for on-memory hash database.  "+" stands for on-memory tree   database. */const char *tcadbpath(TCADB *adb);/* Get the number of records of an abstract database object.   `adb' specifies the abstract database object.   The return value is the number of records or 0 if the object does not connect to any database   instance. */uint64_t tcadbrnum(TCADB *adb);/* Get the size of the database of an abstract database object.   `adb' specifies the abstract database object.   The return value is the size of the database or 0 if the object does not connect to any   database instance. */uint64_t tcadbsize(TCADB *adb);/* Call a versatile function for miscellaneous operations of an abstract database object.   `adb' specifies the abstract database object.   `name' specifies the name of the function.  All databases support "put", "out", "get",   "putlist", "outlist", and "getlist".  "put" is to store a record.  It receives a key and a   value, and returns an empty list.  "out" is to remove a record.  It receives a key, and   returns an empty list.  "get" is to retrieve a record.  It receives a key, and returns a list   of the values.  "putlist" is to store records.  It receives keys and values one after the   other, and returns an empty list.  "outlist" is to remove records.  It receives keys, and   returns an empty list.  "getlist" is to retrieve records.  It receives keys, and returns keys   and values of corresponding records one after the other.   `args' specifies a list object containing arguments.   If successful, the return value is a list object of the result.  `NULL' is returned on failure.   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. */TCLIST *tcadbmisc(TCADB *adb, const char *name, const TCLIST *args);/************************************************************************************************* * features for experts *************************************************************************************************//* type of the pointer to a mapping function.   `map' specifies the pointer to the destination manager.   `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.   `op' specifies the pointer to the optional opaque object.   The return value is true to continue iteration or false to stop iteration. */typedef bool (*ADBMAPPROC)(void *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz,                           void *op);/* Get the open mode of an abstract database object.   `adb' specifies the abstract database object.   The return value is `ADBOVOID' for not opened database, `ADBOMDB' for on-memory hash database,  `ADBONDB' for on-memory tree database, `ADBOHDB' for hash database, `ADBOBDB' for B+ tree  database, `ADBOFDB' for fixed-length database, `ADBOTDB' for table database. */int tcadbomode(TCADB *adb);/* Get the concrete database object of an abstract database object.   `adb' specifies the abstract database object.   The return value is the concrete database object depend on the open mode or 0 if the object   does not connect to any database instance. */void *tcadbreveal(TCADB *adb);/* Store a record into an abstract database object with a duplication handler.   `adb' specifies the abstract 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 region of the value.   `vsiz' specifies the size of the region of the value.   `proc' specifies the pointer to the callback function to process duplication.   `op' specifies an arbitrary pointer to be given as a parameter of the callback function.  If   it is not needed, `NULL' can be specified.   If successful, the return value is true, else, it is false.   This function does not work for the table database. */bool tcadbputproc(TCADB *adb, const void *kbuf, int ksiz, const char *vbuf, int vsiz,                  TCPDPROC proc, void *op);/* Process each record atomically of an abstract database object.   `adb' specifies the abstract database object.   `iter' specifies the pointer to the iterator function called for each record.   `op' specifies an arbitrary pointer to be given as a parameter of the iterator function.  If   it is not needed, `NULL' can be specified.   If successful, the return value is true, else, it is false. */bool tcadbforeach(TCADB *adb, TCITER iter, void *op);/* Map records of an abstract database object into another B+ tree database.   `adb' specifies the abstract database object.   `keys' specifies a list object of the keys of the target records.  If it is `NULL', every   record is processed.   `bdb' specifies the B+ tree database object into which records emitted by the mapping function   are stored.   `proc' specifies the pointer to the mapping function called for each record.   `op' specifies specifies the pointer to the optional opaque object for the mapping function.   `csiz' specifies the size of the cache to sort emitted records.  If it is negative, the   default size is specified.  The default size is 268435456.   If successful, the return value is true, else, it is false. */bool tcadbmapbdb(TCADB *adb, TCLIST *keys, TCBDB *bdb, ADBMAPPROC proc, void *op, int64_t csiz);/* Emit records generated by the mapping function into the result map.   `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. */bool tcadbmapbdbemit(void *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz);__TCADB_CLINKAGEEND#endif                                   /* duplication check *//* END OF FILE */

⌨️ 快捷键说明

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