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

📄 tchdb.h

📁 高性能嵌入式数据库在高并发的环境下使用最好是64位系统比较好
💻 H
📖 第 1 页 / 共 3 页
字号:
/* 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);/* Get the file path of a hash database object.   `hdb' specifies the hash database object.   The return value is the path of the database file or `NULL' if the object does not connect to   any database file. */const char *tchdbpath(TCHDB *hdb);/* Get the number of records of a hash database object.   `hdb' specifies the hash database object.   The return value is the number of records or 0 if the object does not connect to any database   file. */uint64_t tchdbrnum(TCHDB *hdb);/* Get the size of the database file of a hash database object.   `hdb' specifies the hash database object.   The return value is the size of the database file or 0 if the object does not connect to any   database file. */uint64_t tchdbfsiz(TCHDB *hdb);/************************************************************************************************* * features for experts *************************************************************************************************//* Set the error code of a hash database object.   `hdb' specifies the hash database object.   `ecode' specifies the error code.   `file' specifies the file name of the code.   `line' specifies the line number of the code.   `func' specifies the function name of the code. */void tchdbsetecode(TCHDB *hdb, int ecode, const char *filename, int line, const char *func);/* Set the type of a hash database object.   `hdb' specifies the hash database object.   `type' specifies the database type. */void tchdbsettype(TCHDB *hdb, uint8_t type);/* Set the file descriptor for debugging output.   `hdb' specifies the hash database object.   `fd' specifies the file descriptor for debugging output. */void tchdbsetdbgfd(TCHDB *hdb, int fd);/* Get the file descriptor for debugging output.   `hdb' specifies the hash database object.   The return value is the file descriptor for debugging output. */int tchdbdbgfd(TCHDB *hdb);/* Synchronize updating contents on memory of a hash database object.   `hdb' specifies the hash database object connected as a writer.   `phys' specifies whether to synchronize physically.   If successful, the return value is true, else, it is false. */bool tchdbmemsync(TCHDB *hdb, bool phys);/* Clear the cache of a hash tree database object.   `bdb' specifies the hash tree database object.   If successful, the return value is true, else, it is false. */bool tchdbcacheclear(TCHDB *hdb);/* Get the number of elements of the bucket array of a hash database object.   `hdb' specifies the hash database object.   The return value is the number of elements of the bucket array or 0 if the object does not   connect to any database file. */uint64_t tchdbbnum(TCHDB *hdb);/* Get the record alignment of a hash database object.   `hdb' specifies the hash database object.   The return value is the record alignment or 0 if the object does not connect to any database   file. */uint32_t tchdbalign(TCHDB *hdb);/* Get the maximum number of the free block pool of a a hash database object.   `hdb' specifies the hash database object.   The return value is the maximum number of the free block pool or 0 if the object does not   connect to any database file. */uint32_t tchdbfbpmax(TCHDB *hdb);/* Get the size of the extra mapped memory of a hash database object.   `hdb' specifies the hash database object.   The return value is the size of the extra mapped memory or 0 if the object does not connect to   any database file. */uint64_t tchdbxmsiz(TCHDB *hdb);/* Get the inode number of the database file of a hash database object.   `hdb' specifies the hash database object.   The return value is the inode number of the database file or 0 the object does not connect to   any database file. */uint64_t tchdbinode(TCHDB *hdb);/* Get the modification time of the database file of a hash database object.   `hdb' specifies the hash database object.   The return value is the inode number of the database file or 0 the object does not connect to   any database file. */time_t tchdbmtime(TCHDB *hdb);/* Get the connection mode of a hash database object.   `hdb' specifies the hash database object.   The return value is the connection mode. */int tchdbomode(TCHDB *hdb);/* Get the database type of a hash database object.   `hdb' specifies the hash database object.   The return value is the database type. */uint8_t tchdbtype(TCHDB *hdb);/* Get the additional flags of a hash database object.   `hdb' specifies the hash database object.   The return value is the additional flags. */uint8_t tchdbflags(TCHDB *hdb);/* Get the options of a hash database object.   `hdb' specifies the hash database object.   The return value is the options. */uint8_t tchdbopts(TCHDB *hdb);/* Get the pointer to the opaque field of a hash database object.   `hdb' specifies the hash database object.   The return value is the pointer to the opaque field whose size is 128 bytes. */char *tchdbopaque(TCHDB *hdb);/* Get the number of used elements of the bucket array of a hash database object.   `hdb' specifies the hash database object.   The return value is the number of used elements of the bucket array or 0 if the object does not   connect to any database file. */uint64_t tchdbbnumused(TCHDB *hdb);/* Set the custom codec functions of a hash database object.   `hdb' specifies the hash database object.   `enc' specifies the pointer to the custom encoding function.   `encop' specifies an arbitrary pointer to be given as a parameter of the encoding function.   If it is not needed, `NULL' can be specified.   `dec' specifies the pointer to the custom decoding function.   `decop' specifies an arbitrary pointer to be given as a parameter of the decoding function.   If it is not needed, `NULL' can be specified.   If successful, the return value is true, else, it is false.   Note that the custom codec functions should be set before the database is opened and should be   set every time the database is being opened. */bool tchdbsetcodecfunc(TCHDB *hdb, HDBCODEC enc, void *encop, HDBCODEC dec, void *decop);/* Get the custom codec functions of a hash database object.   `hdb' specifies the hash database object.   `ep' specifies the pointer to a variable into which the pointer to the custom encoding   function is assigned   `eop' specifies the pointer to a variable into which the arbitrary pointer to be given to the   encoding function is assigned.   `dp' specifies the pointer to a variable into which the pointer to the custom decoding   function is assigned   `dop' specifies the pointer to a variable into which the arbitrary pointer to be given to the   decoding function is assigned. */void tchdbcodecfunc(TCHDB *hdb, HDBCODEC *ep, void **eop, HDBCODEC *dp, void **dop);/* Retrieve the next record of a record in a hash database object.   `hdb' specifies the hash database object.   `kbuf' specifies the pointer to the region of the key.  If it is `NULL', the first record is   retrieved.   `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 next 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 *tchdbgetnext(TCHDB *hdb, const void *kbuf, int ksiz, int *sp);/* Retrieve the next record of a string record in a hash database object.   `hdb' specifies the hash database object.   `kstr' specifies the string of the key.  If it is `NULL', the first record is retrieved.   If successful, the return value is the string of the value of the next 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 *tchdbgetnext2(TCHDB *hdb, const char *kstr);__TCHDB_CLINKAGEEND#endif                                   /* duplication check *//* END OF FILE */

⌨️ 快捷键说明

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