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

📄 tchdb.h

📁 高性能嵌入式数据库在高并发的环境下使用最好是64位系统比较好
💻 H
📖 第 1 页 / 共 3 页
字号:
bool tchdbput(TCHDB *hdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a string record into 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 a record with the same key exists in the database, it is overwritten. */bool tchdbput2(TCHDB *hdb, const char *kstr, const char *vstr);/* Store a new record into 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.   `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, this function has no effect. */bool tchdbputkeep(TCHDB *hdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a new string record into 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 a record with the same key exists in the database, this function has no effect. */bool tchdbputkeep2(TCHDB *hdb, const char *kstr, const char *vstr);/* Concatenate a value at the end of the existing 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.   `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 `NAN'.   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);

⌨️ 快捷键说明

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