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

📄 tcadb.h

📁 高性能嵌入式数据库在高并发的环境下使用最好是64位系统比较好
💻 H
📖 第 1 页 / 共 2 页
字号:
/************************************************************************************************* * The abstract database API of Tokyo Cabinet *                                                      Copyright (C) 2006-2008 Mikio Hirabayashi * This file is part of Tokyo Cabinet. * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License or any later version.  Tokyo Cabinet is distributed in the hope * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public * License for more details. * You should have received a copy of the GNU Lesser General Public License along with Tokyo * Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA. *************************************************************************************************/#ifndef _TCADB_H                         /* duplication check */#define _TCADB_H#if defined(__cplusplus)#define __TCADB_CLINKAGEBEGIN extern "C" {#define __TCADB_CLINKAGEEND }#else#define __TCADB_CLINKAGEBEGIN#define __TCADB_CLINKAGEEND#endif__TCADB_CLINKAGEBEGIN#include <stdlib.h>#include <stdbool.h>#include <stdint.h>#include <time.h>#include <math.h>#include <tcutil.h>#include <tchdb.h>#include <tcbdb.h>#include <tcfdb.h>/************************************************************************************************* * API *************************************************************************************************/typedef struct {                         /* type of structure for an abstract database */  char *name;                            /* name of the database */  int omode;                             /* open mode */  TCMDB *mdb;                            /* on-memory hash database object */  TCNDB *ndb;                            /* on-memory tree database object */  TCHDB *hdb;                            /* hash database object */  TCBDB *bdb;                            /* B+ tree database object */  TCFDB *fdb;                            /* fixed-length databae object */  int64_t capnum;                        /* capacity number of records */  int64_t capsiz;                        /* capacity size of using memory */  uint32_t capcnt;                       /* count for capacity check */  BDBCUR *cur;                           /* cursor of B+ tree */} TCADB;/* Create an abstract database object.   The return value is the new abstract database object. */TCADB *tcadbnew(void);/* Delete an abstract database object.   `adb' specifies the abstract database object. */void tcadbdel(TCADB *adb);/* Open an abstract database.   `adb' specifies the abstract database object.   `name' specifies the name of the database.  If it is "*", the database will be an on-memory   hash database.  If it is "+", the database will be an on-memory tree database.  If its suffix   is ".tch", the database will be a hash database.  If its suffix is ".tcb", the database will   be a B+ tree database.  If its suffix is ".tcf", the database will be a fixed-length database.   Otherwise, this function fails.  Tuning parameters can trail the name, separated by "#".  Each   parameter is composed of the name and the number, separated by "=".  On-memory hash database   supports "bnum", "capnum", and "capsiz".  On-memory tree database supports "capnum" and   "capsiz".  Hash database supports "mode", "bnum", "apow", "fpow", "opts", "rcnum", and "xmsiz".   B+ tree database supports "mode", "lmemb", "nmemb", "bnum", "apow", "fpow", "opts", "lcnum",   "ncnum", and "xmsiz".  Fixed-length database supports "mode", "width", and "limsiz".  "capnum"   specifies the capacity number of records.  "capsiz" specifies the capacity size of using   memory.  Records spilled the capacity are removed by the storing order.  "mode" can contain   "w" of writer, "r" of reader, "c" of creating, "t" of truncating, "e" of no locking, and "f"   of non-blocking lock.  The default mode is relevant to "wc".  "opts" can contains "l" of large   option, "d" of Deflate option, "b" of BZIP2 option, and "t" of TCBS option.  For example,   "casket.tch#bnum=1000000#opts=ld" means that the name of the database file is "casket.tch",   and the bucket number is 1000000, and the options are large and Deflate.   If successful, the return value is true, else, it is false. */bool tcadbopen(TCADB *adb, const char *name);/* Close an abstract database object.   `adb' specifies the abstract database object.   If successful, the return value is true, else, it is false.   Update of a database is assured to be written when the database is closed.  If a writer opens   a database but does not close it appropriately, the database will be broken. */bool tcadbclose(TCADB *adb);/* Store a record into 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.   `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. */bool tcadbput(TCADB *adb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a string record into an abstract object.   `adb' specifies the abstract database object.   `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 tcadbput2(TCADB *adb, const char *kstr, const char *vstr);/* Store a new record into 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.   `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 tcadbputkeep(TCADB *adb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a new string record into an abstract database object.   `adb' specifies the abstract database object.   `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 tcadbputkeep2(TCADB *adb, const char *kstr, const char *vstr);/* Concatenate a value at the end of the existing 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.   `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 tcadbputcat(TCADB *adb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Concatenate a string value at the end of the existing record in an abstract database object.   `adb' specifies the abstract database object.   `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 tcadbputcat2(TCADB *adb, const char *kstr, const char *vstr);/* Remove a record of 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.   If successful, the return value is true, else, it is false. */bool tcadbout(TCADB *adb, const void *kbuf, int ksiz);/* Remove a string record of an abstract database object.   `adb' specifies the abstract database object.   `kstr' specifies the string of the key.   If successful, the return value is true, else, it is false. */bool tcadbout2(TCADB *adb, const char *kstr);

⌨️ 快捷键说明

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