📄 tcbdb.h
字号:
If successful, the return value is true, else, it is false. False is returned when the cursor is at invalid position. */bool tcbdbcurrec(BDBCUR *cur, TCXSTR *kxstr, TCXSTR *vxstr);/************************************************************************************************* * features for experts *************************************************************************************************//* Set the error code of a B+ tree database object. `bdb' specifies the B+ tree 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 tcbdbsetecode(TCBDB *bdb, int ecode, const char *filename, int line, const char *func);/* Set the file descriptor for debugging output. `bdb' specifies the B+ tree database object. `fd' specifies the file descriptor for debugging output. */void tcbdbsetdbgfd(TCBDB *bdb, int fd);/* Get the file descriptor for debugging output. `bdb' specifies the B+ tree database object. The return value is the file descriptor for debugging output. */int tcbdbdbgfd(TCBDB *bdb);/* Synchronize updating contents on memory of a B+ tree database object. `bdb' specifies the B+ tree database object connected as a writer. `phys' specifies whether to synchronize physically. If successful, the return value is true, else, it is false. */bool tcbdbmemsync(TCBDB *bdb, bool phys);/* Clear the cache of a B+ tree database object. `bdb' specifies the B+ tree database object. If successful, the return value is true, else, it is false. */bool tcbdbcacheclear(TCBDB *bdb);/* Get the comparison function of a B+ tree database object. `bdb' specifies the B+ tree database object. The return value is the pointer to the comparison function. */BDBCMP tcbdbcmpfunc(TCBDB *bdb);/* Get the opaque object for the comparison function of a B+ tree database object. `bdb' specifies the B+ tree database object. The return value is the opaque object for the comparison function. */void *tcbdbcmpop(TCBDB *bdb);/* Get the maximum number of cached leaf nodes of a B+ tree database object. `bdb' specifies the B+ tree database object. The return value is the maximum number of cached leaf nodes. */uint32_t tcbdblmemb(TCBDB *bdb);/* Get the maximum number of cached non-leaf nodes of a B+ tree database object. `bdb' specifies the B+ tree database object. The return value is the maximum number of cached non-leaf nodes. */uint32_t tcbdbnmemb(TCBDB *bdb);/* Get the number of the leaf nodes of B+ tree database object. `bdb' specifies the B+ tree database object. If successful, the return value is the number of the leaf nodes or 0 if the object does not connect to any database file. */uint64_t tcbdblnum(TCBDB *bdb);/* Get the number of the non-leaf nodes of B+ tree database object. `bdb' specifies the B+ tree database object. If successful, the return value is the number of the non-leaf nodes or 0 if the object does not connect to any database file. */uint64_t tcbdbnnum(TCBDB *bdb);/* Get the number of elements of the bucket array of a B+ tree database object. `bdb' specifies the B+ tree 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 tcbdbbnum(TCBDB *bdb);/* Get the record alignment of a B+ tree database object. `bdb' specifies the B+ tree database object. The return value is the record alignment or 0 if the object does not connect to any database file. */uint32_t tcbdbalign(TCBDB *bdb);/* Get the maximum number of the free block pool of a B+ tree database object. `bdb' specifies the B+ tree 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 tcbdbfbpmax(TCBDB *bdb);/* Get the inode number of the database file of a B+ tree database object. `bdb' specifies the B+ tree 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 tcbdbinode(TCBDB *bdb);/* Get the modification time of the database file of a B+ tree database object. `bdb' specifies the B+ tree 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 tcbdbmtime(TCBDB *bdb);/* Get the additional flags of a B+ tree database object. `bdb' specifies the B+ tree database object. The return value is the additional flags. */uint8_t tcbdbflags(TCBDB *bdb);/* Get the options of a B+ tree database object. `bdb' specifies the B+ tree database object. The return value is the options. */uint8_t tcbdbopts(TCBDB *bdb);/* Get the pointer to the opaque field of a B+ tree database object. `bdb' specifies the B+ tree database object. The return value is the pointer to the opaque field whose size is 128 bytes. */char *tcbdbopaque(TCBDB *bdb);/* Get the number of used elements of the bucket array of a B+ tree database object. `bdb' specifies the B+ tree 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 tcbdbbnumused(TCBDB *bdb);/* Set the maximum size of each leaf node. `bdb' specifies the B+ tree database object which is not opened. `lsmax' specifies the maximum size of each leaf node. If it is not more than 0, the maximum size is unlimited. If successful, the return value is true, else, it is false. Note that the tuning parameters of the database should be set before the database is opened. */bool tcbdbsetlsmax(TCBDB *bdb, uint32_t lsmax);/* Set the capacity number of records. `bdb' specifies the B+ tree database object which is not opened. `capnum' specifies the capacity number of records. If it is not more than 0, the capacity is unlimited. If successful, the return value is true, else, it is false. When the number of records exceeds the capacity, forehand records are removed implicitly. Note that the tuning parameters of the database should be set before the database is opened. */bool tcbdbsetcapnum(TCBDB *bdb, uint64_t capnum);/* Set the custom codec functions of a B+ tree database object. `bdb' specifies the B+ tree 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 tcbdbsetcodecfunc(TCBDB *bdb, BDBCODEC enc, void *encop, BDBCODEC dec, void *decop);/* Store a new record into a B+ tree database object with backward duplication. `bdb' specifies the B+ tree 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, the new record is placed after the existing one. */bool tcbdbputdupback(TCBDB *bdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a new string record into a B+ tree database object with backward duplication. `bdb' specifies the B+ tree 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, the new record is placed after the existing one. */bool tcbdbputdupback2(TCBDB *bdb, const char *kstr, const char *vstr);/* Move a cursor object to the rear of records corresponding a key. `cur' specifies the cursor 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 true, else, it is false. False is returned if there is no record corresponding the condition. The cursor is set to the last record corresponding the key or the previous substitute if completely matching record does not exist. */bool tcbdbcurjumpback(BDBCUR *cur, const void *kbuf, int ksiz);/* Move a cursor object to the rear of records corresponding a key string. `cur' specifies the cursor object. `kstr' specifies the string of the key. If successful, the return value is true, else, it is false. False is returned if there is no record corresponding the condition. The cursor is set to the last record corresponding the key or the previous substitute if completely matching record does not exist. */bool tcbdbcurjumpback2(BDBCUR *cur, const char *kstr);/* Compare two keys by lexical order. `aptr' specifies the pointer to the region of one key. `asiz' specifies the size of the region of one key. `bptr' specifies the pointer to the region of the other key. `bsiz' specifies the size of the region of the other key. `op' specifies the pointer to the optional opaque object. The return value is positive if the former is big, negative if the latter is big, 0 if both are equivalent. */int tcbdbcmplexical(const char *aptr, int asiz, const char *bptr, int bsiz, void *op);/* Compare two keys as decimal strings of real numbers. `aptr' specifies the pointer to the region of one key. `asiz' specifies the size of the region of one key. `bptr' specifies the pointer to the region of the other key. `bsiz' specifies the size of the region of the other key. `op' is ignored. The return value is positive if the former is big, negative if the latter is big, 0 if both are equivalent. */int tcbdbcmpdecimal(const char *aptr, int asiz, const char *bptr, int bsiz, void *op);/* Compare two keys as 32-bit integers in the native byte order. `aptr' specifies the pointer to the region of one key. `asiz' specifies the size of the region of one key. `bptr' specifies the pointer to the region of the other key. `bsiz' specifies the size of the region of the other key. `op' is ignored. The return value is positive if the former is big, negative if the latter is big, 0 if both are equivalent. */int tcbdbcmpint32(const char *aptr, int asiz, const char *bptr, int bsiz, void *op);/* Compare two keys as 64-bit integers in the native byte order. `aptr' specifies the pointer to the region of one key. `asiz' specifies the size of the region of one key. `bptr' specifies the pointer to the region of the other key. `bsiz' specifies the size of the region of the other key. `op' is ignored. The return value is positive if the former is big, negative if the latter is big, 0 if both are equivalent. */int tcbdbcmpint64(const char *aptr, int asiz, const char *bptr, int bsiz, void *op);/* tricks for backward compatibility */#define tcbdbrange3 tcbdbfwmkeys2__TCBDB_CLINKAGEEND#endif /* duplication check *//* END OF FILE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -