2019-07-28 10:31:56 +08:00
|
|
|
|
#ifndef ACL_ZDB_INCLUDE_H
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#define ACL_ZDB_INCLUDE_H
|
|
|
|
|
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/acl_define.h"
|
|
|
|
|
#include "../stdlib/acl_vstring.h"
|
|
|
|
|
#include "../stdlib/acl_fhandle.h"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-05-18 21:19:21 +08:00
|
|
|
|
#ifndef ACL_CLIENT_ONLY
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef struct ZDB ZDB;
|
|
|
|
|
typedef struct ZDB_KEY_HDR ZDB_KEY_HDR;
|
|
|
|
|
typedef struct ZDB_BLK ZDB_BLK;
|
|
|
|
|
typedef struct ZDB_BLK_OFF ZDB_BLK_OFF;
|
|
|
|
|
typedef struct ZDB_DAT_HDR ZDB_DAT_HDR;
|
|
|
|
|
typedef struct ZDB_KEY_STORE ZDB_KEY_STORE;
|
|
|
|
|
typedef struct ZDB_DAT_STORE ZDB_DAT_STORE;
|
|
|
|
|
typedef struct ZDB_IO ZDB_IO;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ƫ<><C6AB><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef acl_int64 zdb_off_t;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef acl_int64 zdb_key_t;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ֵ<>洢<EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef int zdb_lnk_t;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef struct ZDB_DISK {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
acl_int64 limit; /* <20>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
acl_int64 count; /* Ŀǰ<C4BF>÷<EFBFBD><C3B7><EFBFBD><EFBFBD>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
char *path; /* <20><><EFBFBD>̷<EFBFBD><CCB7><EFBFBD>·<EFBFBD><C2B7> */
|
|
|
|
|
int idisk; /* <20>ô<EFBFBD><C3B4>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int priority; /* Ȩ<><C8A8><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD> */
|
|
|
|
|
int *dat_ifiles; /* <20><>ǰ<EFBFBD><C7B0><EFBFBD>õ<EFBFBD> dat_ifile ֵ<>洢<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int dat_ifiles_size; /* dat_ifiles <20>Ĵ<EFBFBD>С */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
} ZDB_DISK;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD> zdb_open() ʱ<><CAB1> ZDB <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef struct ZDB_CFG {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
const char *key_path; /* <20><><EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD>ڵĸ<DAB5>Ŀ¼ */
|
|
|
|
|
zdb_key_t key_begin; /* <20><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ʼֵ */
|
|
|
|
|
zdb_key_t key_limit; /* ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>ļ<EFBFBD><C4BC>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
acl_int64 dat_limit; /* ÿ<><C3BF>ֵ<EFBFBD>洢<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
|
|
|
|
|
int key_cache_max; /* <20><><EFBFBD>ü<EFBFBD><C3BC>洢 IO <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int key_cache_timeout; /* <20><><EFBFBD>ü<EFBFBD><C3BC>洢 IO <20><><EFBFBD><EFBFBD>ʱÿ<CAB1><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>ʱ<EFBFBD><CAB1> */
|
|
|
|
|
int key_wback_max; /* <20><><EFBFBD>ü<EFBFBD><C3BC>洢 IO <20><><EFBFBD><EFBFBD>ʱд<CAB1><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
|
|
|
|
|
int dat_nstep; /* ֵ<>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ʱ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>ֵ */
|
|
|
|
|
int blk_dlen; /* ֵ<>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ֵij<D6B5><C4B3><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>) */
|
|
|
|
|
int dat_cache_max; /* <20><><EFBFBD><EFBFBD>ֵ<EFBFBD>洢 IO <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int dat_cache_timeout; /* <20><><EFBFBD><EFBFBD>ֵ<EFBFBD>洢 IO <20><><EFBFBD><EFBFBD>ʱÿ<CAB1><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>ʱ<EFBFBD><CAB1> */
|
|
|
|
|
int dat_wback_max; /* <20><><EFBFBD><EFBFBD>ֵ<EFBFBD>洢 IO <20><><EFBFBD><EFBFBD>ʱд<CAB1><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
} ZDB_CFG;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ZDB <20>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ZDB {
|
|
|
|
|
/* public */
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
char *dbname; /* <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD> */
|
|
|
|
|
char *key_path; /* ZDB <20><>key<65>洢·<E6B4A2><C2B7> */
|
|
|
|
|
unsigned int oflags; /* <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ı<EFBFBD>־λ */
|
|
|
|
|
#define ZDB_FLAG_LINK_BUSY (1 << 0) /* <20><>ֵ<EFBFBD>洢<EFBFBD>е<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
#define ZDB_FLAG_OPEN_LOCK (1 << 1) /* <20>Լ<EFBFBD><D4BC><EFBFBD>ģʽ<C4A3>洢<F2BFAAB4><E6B4A2><EFBFBD><EFBFBD> */
|
|
|
|
|
#define ZDB_FLAG_CACHE_DAT (1 << 2) /* <20>Ƿ<C7B7>ֵ<EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
#define ZDB_FLAG_CACHE_KEY (1 << 3) /* <20>Ƿ<C7B7><F1BBBAB4><EFBFBD><EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
#define ZDB_FLAG_SLICE_KEY (1 << 4) /* <20><><EFBFBD><EFBFBD>ֵ<EFBFBD>洢ʱ<E6B4A2>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Ƭ<EFBFBD><C6AC>ʽ */
|
|
|
|
|
#define ZDB_FLAG_SLICE_DAT (1 << 5) /* <20><><EFBFBD>ü<EFBFBD><C3BC>洢ʱ<E6B4A2>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Ƭ<EFBFBD><C6AC>ʽ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
unsigned int status; /* ״̬λ */
|
|
|
|
|
#define ZDB_STAT_KEY_NEW (1 << 0) /* <20>¼<EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/* private */
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
zdb_key_t key_begin; /* <20><><EFBFBD>м<EFBFBD><D0BC>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD>ʼֵ */
|
|
|
|
|
zdb_key_t key_limit; /* ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>м<EFBFBD><D0BC>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
|
|
|
|
int key_cache_max; /* <20><><EFBFBD>ü<EFBFBD><C3BC>洢 IO <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int key_cache_timeout; /* <20><><EFBFBD>ü<EFBFBD><C3BC>洢 IO <20><><EFBFBD><EFBFBD>ʱÿ<CAB1><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>ʱ<EFBFBD><CAB1> */
|
|
|
|
|
int key_wback_max; /* <20><><EFBFBD>ü<EFBFBD><C3BC>洢 IO <20><><EFBFBD><EFBFBD>ʱд<CAB1><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
acl_int64 dat_limit; /* ֵ<>洢<EFBFBD><E6B4A2>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int blk_dlen; /* ֵ<>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鵥Ԫ<E9B5A5><D4AA><EFBFBD><EFBFBD> */
|
|
|
|
|
int dat_nstep; /* ֵ<>洢<EFBFBD><E6B4A2>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>ĸ<EFBFBD><C4B8><EFBFBD> */
|
|
|
|
|
int dat_cache_max; /* <20><><EFBFBD><EFBFBD>ֵ<EFBFBD>洢 IO <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int dat_cache_timeout; /* <20><><EFBFBD><EFBFBD>ֵ<EFBFBD>洢 IO <20><><EFBFBD><EFBFBD>ʱÿ<CAB1><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>ʱ<EFBFBD><CAB1> */
|
|
|
|
|
int dat_wback_max; /* <20><><EFBFBD><EFBFBD>ֵ<EFBFBD>洢 IO <20><><EFBFBD><EFBFBD>ʱд<CAB1><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
ZDB_DISK *dat_disks; /* ֵ<>洢<EFBFBD><E6B4A2><EFBFBD>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
int (*key_get)(ZDB*, zdb_key_t, ZDB_BLK_OFF*);
|
|
|
|
|
int (*key_set) (ZDB*, zdb_key_t, const ZDB_BLK_OFF*);
|
|
|
|
|
|
|
|
|
|
ZDB_BLK *(*dat_get)(ZDB*, const ZDB_BLK_OFF*, zdb_key_t*, size_t*);
|
|
|
|
|
int (*dat_add)(ZDB*, zdb_key_t, const void*, int);
|
|
|
|
|
int (*dat_update)(ZDB*, zdb_key_t, const ZDB_BLK_OFF*,
|
|
|
|
|
const void*, size_t);
|
|
|
|
|
|
|
|
|
|
/* private */
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
ACL_VSTRING *path_tmp; /* <20><>ʱ<EFBFBD>õĴ洢<C4B4>ļ<EFBFBD><C4BC><EFBFBD>ȫ·<C8AB><C2B7>, <20><>ҪΪ<D2AA>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int blk_count_tmp; /* <20><>ʱ<EFBFBD>õĿ<C3B5><C4BF><EFBFBD>, <20><>ҪΪ<D2AA>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int inode_tmp; /* <20><>ʱ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD>ҪΪ<D2AA>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* xxx: Ϊ<>˱<EFBFBD>֤<EFBFBD><D6A4>ƽ̨<C6BD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD>½ṹ<C2BD><E1B9B9><EFBFBD>嶼<EFBFBD><E5B6BC>4<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
#ifdef ACL_SUNOS5
|
|
|
|
|
#pragma pack(4)
|
|
|
|
|
#else
|
|
|
|
|
#pragma pack(push, 4)
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ֵ<>洢ͷ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ZDB_DAT_HDR {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
acl_int64 limit; /* ֵ<>洢<EFBFBD><E6B4A2>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
acl_int64 size; /* <20><>ǰֵ<C7B0>洢<EFBFBD>ļ<EFBFBD><C4BC>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>洢<EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD> */
|
|
|
|
|
acl_int64 count; /* <20><>ǰֵ<C7B0>洢<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
acl_int64 reserv1; /* <20><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> */
|
|
|
|
|
acl_int64 reserv2; /* <20><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> */
|
|
|
|
|
acl_int64 reserv3; /* <20><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> */
|
|
|
|
|
acl_int64 reserv4; /* <20><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> */
|
|
|
|
|
int nstep; /* ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱֵ<CAB1>洢<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Сʱ<D0A1>IJ<EFBFBD><C4B2><EFBFBD>ֵ<EFBFBD><D6B5>С */
|
|
|
|
|
int blk_hdr_dlen; /* ֵ<>洢<EFBFBD><E6B4A2>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ZDB_BLK_HDR.sizeof */
|
|
|
|
|
int blk_dlen; /* ֵ<>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鵥Ԫ<E9B5A5><D4AA><EFBFBD><EFBFBD> */
|
|
|
|
|
int blk_count; /* <20><>ֵ<EFBFBD>洢<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
|
|
|
|
|
/* <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>λ<EFBFBD>õļ<C3B5><C4BC>㹫ʽΪ:
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* zdb_off_t off_head = ZDB_DAT_HDR.sizeof +
|
|
|
|
|
* ZDB_DAT_HDR.ihead_idle * (ZDB_DAT_HDR.blk_hdr_dlen +
|
|
|
|
|
* ZDB_DAT_HDR.blk_dlen * ZDB_DAT_HDR.blk_count);
|
|
|
|
|
*/
|
|
|
|
|
zdb_lnk_t ihead_idle;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>λ<EFBFBD>õļ<C3B5><C4BC>㹫ʽΪ:
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* zdb_off_t off_head = ZDB_DAT_HDR.sizeof +
|
|
|
|
|
* ZDB_DAT_HDR.ihead_busy * (ZDB_DAT_HDR.blk_hdr_dlen +
|
|
|
|
|
* ZDB_DAT_HDR.blk_dlen * ZDB_DAT_HDR.blk_count);
|
|
|
|
|
*/
|
|
|
|
|
zdb_lnk_t ihead_busy;
|
|
|
|
|
zdb_lnk_t itail_busy;
|
2019-07-28 10:31:56 +08:00
|
|
|
|
int dummy; /* <20><>֤8<D6A4>ֽڶ<D6BD><DAB6><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD>洢<EFBFBD><E6B4A2>ͷ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ZDB_KEY_HDR {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
zdb_key_t key_limit; /* <20>ü<EFBFBD><C3BC>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
zdb_key_t key_count; /* <20><>ǰ<EFBFBD><C7B0><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
zdb_key_t key_begin; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼֵ */
|
|
|
|
|
acl_int64 reserv1; /* <20><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> */
|
|
|
|
|
acl_int64 reserv2; /* <20><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> */
|
|
|
|
|
acl_int64 reserv3; /* <20><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> */
|
|
|
|
|
acl_int64 reserv4; /* <20><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ͷ<EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef struct ZDB_BLK_HDR {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
zdb_key_t key; /* <20><>Ӧ<EFBFBD>ڼ<EFBFBD><DABC>洢<EFBFBD>еļ<D0B5> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>, У<><D0A3><EFBFBD><EFBFBD>, ͬʱ<CDAC><CAB1>֤<EFBFBD><D6A4> 8 <20>ֽڶ<D6BD><DAB6><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
zdb_lnk_t blk_ilnk;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><> inext_idle <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>ӳ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ֵΪ -1 <20><><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
* <EFBFBD>ǿ<EFBFBD><EFBFBD>п<EFBFBD>, <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD>λ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õļ<EFBFBD><EFBFBD>㹫ʽΪ:
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* zdb_off_t off_next = ZDB_BLK_HDR.sizeof +
|
|
|
|
|
* ZDB_BLK_HDR.inext_idle * (ZDB_BLK_HDR.blk_hdr_dlen +
|
|
|
|
|
* ZDB_DAT_HDR.blk_dlen * ZDB_DAT_HDR.blk_count);
|
|
|
|
|
*/
|
|
|
|
|
zdb_lnk_t inext_idle;
|
|
|
|
|
|
|
|
|
|
#ifdef ZDB_LINK_BUSY
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><> inext_busy/iprev_busy <20><>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>ӳ<EFBFBD>һ<EFBFBD><D2BB>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ֵΪ -1
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ռ<EFBFBD>ÿ<EFBFBD>, <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ռ<EFBFBD>ÿ<EFBFBD>λ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ռ<EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õļ<EFBFBD><EFBFBD>㹫ʽΪ:
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* zdb_off_t off_next = ZDB_BLK_HDR.sizeof +
|
|
|
|
|
* ZDB_BLK_HDR.inext_busy * (ZDB_BLK_HDR.blk_hdr_dlen +
|
|
|
|
|
* ZDB_DAT_HDR.blk_dlen * ZDB_DAT_HDR.blk_count);
|
|
|
|
|
* zdb_off_t off_prev = ZDB_BLK_HDR.sizeof +
|
|
|
|
|
* ZDB_BLK_HDR.inext_prev * (ZDB_BLK_HDR.blk_hdr_dlen +
|
|
|
|
|
* ZDB_DAT_HDR.blk_dlen * ZDB_DAT_HDR.blk_count);
|
|
|
|
|
*/
|
|
|
|
|
zdb_lnk_t inext_busy;
|
|
|
|
|
zdb_lnk_t iprev_busy;
|
|
|
|
|
#endif
|
|
|
|
|
} ZDB_BLK_HDR;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD>洢<EFBFBD>д洢<D0B4><E6B4A2>ֵ<EFBFBD>洢<EFBFBD><E6B4A2>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ZDB_BLK_OFF {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
zdb_off_t offset; /* ƫ<><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ */
|
|
|
|
|
int inode; /* ·<><C2B7><EFBFBD><EFBFBD>Ϣ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ZDB_BLK {
|
|
|
|
|
ZDB_BLK_HDR hdr;
|
2019-07-28 10:31:56 +08:00
|
|
|
|
char dat[1]; /* ֵ<>洢<EFBFBD><E6B4A2>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef ACL_SUNOS5
|
2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma pack(0) /* <20><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>4<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#else
|
2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma pack(pop) /* <20><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>4<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ͨ<>ô洢<C3B4><E6B4A2><EFBFBD><EFBFBD><EFBFBD>ṹ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef struct ZDB_STORE {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
ACL_FHANDLE fhandle; /* <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
ZDB *db; /* <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD> */
|
|
|
|
|
ZDB_IO *io; /* IO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int cache_max; /* <20><><EFBFBD>ô洢 IO <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BBBAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int cache_timeout; /* <20><><EFBFBD>ô洢 IO <20><><EFBFBD><EFBFBD>ʱÿ<CAB1><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>ʱ<EFBFBD><CAB1> */
|
|
|
|
|
int wback_max; /* д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
|
|
|
|
|
unsigned int flag; /* <20><>־λ */
|
|
|
|
|
#define STORE_FLAG_KEY (1 << 0) /* <20><>ʾ<EFBFBD>Ǽ<EFBFBD><C7BC>洢 */
|
|
|
|
|
#define STORE_FLAG_DAT (1 << 1) /* <20><>ʾ<EFBFBD><CABE>ֵ<EFBFBD>洢 */
|
|
|
|
|
#define STORE_FLAG_IO_SLICE (1 << 2) /* <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> ZDB_IO <20><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD>䷽ʽ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/* for acl_iterator */
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
const void *(*iter_head)(ACL_ITER*, struct ZDB_STORE*);
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
const void *(*iter_next)(ACL_ITER*, struct ZDB_STORE*);
|
|
|
|
|
} ZDB_STORE;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* <20><><EFBFBD>洢 */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ZDB_KEY_STORE {
|
|
|
|
|
ZDB_STORE store;
|
2019-07-28 10:31:56 +08:00
|
|
|
|
ZDB_KEY_HDR hdr; /* <20><><EFBFBD>洢ͷ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ֵ<>洢 */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ZDB_DAT_STORE {
|
|
|
|
|
ZDB_STORE store;
|
2019-07-28 10:31:56 +08:00
|
|
|
|
ZDB_DAT_HDR hdr; /* ֵ<>洢ͷ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*------------------------- in zdb_test.c ----------------------------------*/
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* zdb <EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void zdb_test(const char *cmd);
|
|
|
|
|
|
|
|
|
|
/*---------------------------- in zdb.c ----------------------------------*/
|
|
|
|
|
|
|
|
|
|
/* in zdb.c */
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD> zdb
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void zdb_init(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>ǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD>ͷ<EFBFBD> zdb <EFBFBD>ڲ<EFBFBD>һЩ<EFBFBD><EFBFBD>Դ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void zdb_end(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ZDB<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
|
|
|
|
*/
|
|
|
|
|
ACL_API void zdb_sync(ZDB *db);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
|
|
|
|
* @param dbname {const char*} ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param oflags {unsigned int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZDB <EFBFBD><EFBFBD>ʱ<EFBFBD>ı<EFBFBD>־λ
|
|
|
|
|
* @param cfg {const ZDB_CFG*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZDB ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {ZDB*} ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ZDB *zdb_open(const char *dbname, unsigned int oflags, const ZDB_CFG *cfg);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ر<EFBFBD> ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param db {ZDB*} ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void zdb_close(ZDB *db);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param db {ZDB*} ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param key {zdb_key_t} <EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param size {size_t*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD>Ҳ<EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZDB_BLK.dat <EFBFBD>д洢<EFBFBD><EFBFBD><EFBFBD>ݵij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param blk_off_buf {ZDB_BLK_OFF*} <EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {ZDB_BLK*} NULL: δ<EFBFBD>ҵ<EFBFBD>; !NULL: ZDB_BLK->dat Ϊ<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĵ<EFBFBD>ַ,
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZDB_BLK <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> acl_myfree()/1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
|
|
|
|
|
* ע<EFBFBD><EFBFBD>:
|
|
|
|
|
* <EFBFBD><EFBFBD> size ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> size_t <EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><EFBFBD><EFBFBD> int <EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
|
|
|
|
|
* 64λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> size_t Ϊ8<EFBFBD><EFBFBD><EFBFBD>ֽڳ<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD> int Ϊ4<EFBFBD><EFBFBD><EFBFBD>ֽڳ<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>ڶ<EFBFBD> size <EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD> size_t <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ռ䳤<EFBFBD>ȸ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD> size Ϊ int <EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿռ<EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ī<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> valgrind
|
|
|
|
|
* Ҳ<EFBFBD>鲻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ZDB_BLK *zdb_lookup(ZDB *db, zdb_key_t key, size_t *size, ZDB_BLK_OFF *blk_off_buf);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> ZDB_BLK <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param b {ZDB_BLK*}
|
|
|
|
|
* @return {void*}
|
|
|
|
|
*/
|
|
|
|
|
#define zdb_blk_data(b) ((b)->dat)
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD> zdb_lookup()/3 <EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿռ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param b {ZDB_BLK*}
|
|
|
|
|
*/
|
|
|
|
|
#define zdb_blk_free(b) acl_myfree((b))
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param db {ZDB*} ZDB <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param key {zdb_key_t} <EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param blk_off_saved {const ZDB_BLK_OFF*} <EFBFBD>ϴε<EFBFBD><EFBFBD><EFBFBD> zdb_lookup()/4 ʱ<EFBFBD>ķ<EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
* <EFBFBD>Ӷ<EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> zdb_lookup()/4 ʱ<EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>,
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> zdb_update()/5 ʱ<EFBFBD><EFBFBD><EFBFBD>뽫<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD> NULL
|
|
|
|
|
* @param dat {const void*} <EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
|
|
|
|
* @param len {size_t} dat <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} 0: δ<EFBFBD><EFBFBD><EFBFBD>»<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>; 1: <EFBFBD>ɹ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_update(ZDB *db, zdb_key_t key, const ZDB_BLK_OFF *blk_off_saved,
|
|
|
|
|
const void *dat, size_t len);
|
|
|
|
|
|
|
|
|
|
/*--------------------------------- in zdb_key.c -----------------------------*/
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param store {ZDB_KEY_STORE*} ֵ<EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int} -1: error, > 0 ok
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int key_store_header_sync(ZDB_KEY_STORE *store);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>洢
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {zdb_key_t} <EFBFBD><EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {ZDB_KEY_STORE*} !NULL: ok; NULL: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API ZDB_KEY_STORE *zdb_key_store_open(ZDB *db, zdb_key_t key);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param filepath {const char*} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {ZDB_KEY_STORE*} !NULL: ok; NULL: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API ZDB_KEY_STORE *zdb_key_store_open2(ZDB *db, const char *filepath);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>رռ<EFBFBD><EFBFBD>洢
|
|
|
|
|
* @param store {ZDB_KEY_STORE*} <EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void zdb_key_store_close(ZDB_KEY_STORE *store);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD>洢<EFBFBD>м<EFBFBD>λ<EFBFBD>õ<EFBFBD>ֵλ<EFBFBD><EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
|
|
|
|
* @param key {zdb_key_t}
|
|
|
|
|
* @param blk_off {const ZDB_BLK_OFF*}
|
|
|
|
|
* @return {int} 0: ok; -1: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_key_set(ZDB *db, zdb_key_t key, const ZDB_BLK_OFF *blk_off);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>ֵ<EFBFBD>Ӽ<EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD>ȡ<EFBFBD>øü<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {zdb_key_t} <EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param blk_off {ZDB_BLK_OFF*} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} 1: <EFBFBD><EFBFBD>ʾ<EFBFBD>鵽, 0: <EFBFBD><EFBFBD>ʾδ<EFBFBD>鵽, -1: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_key_get(ZDB *db, zdb_key_t key, ZDB_BLK_OFF *blk_off);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD>洢ͷ<EFBFBD><EFBFBD>״̬
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param filepath {const char*} <EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>ļ<EFBFBD>ȫ·<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key_hdr {ZDB_KEY_HDR*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ż<EFBFBD><EFBFBD>洢ͷ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int} 0: ok; -1: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_key_status(ZDB *db, const char *filepath, ZDB_KEY_HDR *key_hdr);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>еļ<EFBFBD><EFBFBD><EFBFBD>״̬
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param filepath {const char*} <EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>ļ<EFBFBD>ȫ·<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key_hdr {ZDB_KEY_HDR*} <EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ż<EFBFBD><EFBFBD>洢ͷ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int} 0: ok; -1: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_key_check3(ZDB *db, const char *filepath, ZDB_KEY_HDR *key_hdr);
|
|
|
|
|
ACL_API int zdb_key_check(ZDB_KEY_STORE *store, ZDB_KEY_HDR *key_hdr);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key_begin {zdb_key_t} <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param key_end {zdb_key_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int} 0: ok; -1: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_key_init(ZDB *db, zdb_key_t key_begin, zdb_key_t key_end);
|
|
|
|
|
/*--------------------------------- in zdb_dat.c -----------------------------*/
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* ͬ<EFBFBD><EFBFBD>ֵ<EFBFBD>洢ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param store {ZDB_DAT_STORE*} ֵ<EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int} -1: error, > 0 ok
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int dat_store_header_sync(ZDB_DAT_STORE *store);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ر<EFBFBD>ֵ<EFBFBD>洢
|
|
|
|
|
* @param store {ZDB_DAT_STORE*} ֵ<EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void zdb_dat_store_close(ZDB_DAT_STORE *store);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ֵ<EFBFBD>洢
|
|
|
|
|
* @param filepath {const char*} ֵ<EFBFBD>洢<EFBFBD>ļ<EFBFBD>ȫ·<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {ZDB_DAT_STORE*} !NULL: ok; NULL: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API ZDB_DAT_STORE *zdb_dat_store_open(ZDB *db, const char *filepath);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ֵ<EFBFBD>洢<EFBFBD><EFBFBD>ȡ<EFBFBD>ö<EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
|
|
|
|
* @param blk_off {const ZDB_BLK_OFF*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {zdb_key_t*} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param size {size_t*} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD>ݵij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {void*} <EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>,
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD> zdb_blk_free()/1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
|
|
|
|
|
* ע<EFBFBD><EFBFBD>:
|
|
|
|
|
* <EFBFBD><EFBFBD> size ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> size_t <EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><EFBFBD><EFBFBD> int <EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
|
|
|
|
|
* 64λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> size_t Ϊ8<EFBFBD><EFBFBD><EFBFBD>ֽڳ<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD> int Ϊ4<EFBFBD><EFBFBD><EFBFBD>ֽڳ<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>ڶ<EFBFBD> size <EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD> size_t <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ռ䳤<EFBFBD>ȸ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD> size Ϊ int <EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿռ<EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ī<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> valgrind
|
|
|
|
|
* Ҳ<EFBFBD>鲻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ZDB_BLK *zdb_dat_get(ZDB *db, const ZDB_BLK_OFF *blk_off,
|
|
|
|
|
zdb_key_t *key, size_t *size);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ֵ<EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {zdb_key_t} <EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param dat {const void*} <EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
|
|
|
|
* @param len {size_t} dat <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>; 1: <EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_dat_add(ZDB *db, zdb_key_t key, const void *dat, int len);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>洢<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {zdb_key_t} <EFBFBD><EFBFBD>
|
|
|
|
|
* @param blk_off {const ZDB_BLK_OFF*} <EFBFBD>洢<EFBFBD>ڼ<EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧֵ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param dat {const void*} <EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
|
|
|
|
* @param len {size_t} dat <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>; 1: <EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_dat_update(ZDB *db, zdb_key_t key, const ZDB_BLK_OFF *blk_off,
|
|
|
|
|
const void *dat, size_t len);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ȡֵ<EFBFBD>洢<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>Ϣ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param filepath {const char*} ֵ<EFBFBD>洢<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param dat_hdr {ZDB_DAT_HDR*} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @retur {int} 0: ok; -1: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_dat_stat(ZDB *db, const char *filepath, ZDB_DAT_HDR *dat_hdr);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>洢<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param db {ZDB*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param filepath {const char*} ֵ<EFBFBD>洢<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param dat_hdr {ZDB_DAT_HDR*} <EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢ֵ<EFBFBD>洢ͷ<EFBFBD><EFBFBD>Ϣ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int} 0: ok; -1: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int zdb_dat_check3(ZDB *db, const char *filepath, ZDB_DAT_HDR *dat_hdr);
|
|
|
|
|
ACL_API int zdb_dat_check(ZDB_DAT_STORE *store, ZDB_DAT_HDR *dat_hdr);
|
|
|
|
|
|
|
|
|
|
/*-------------------- in zdb_key_walk.c -----------------------------------*/
|
|
|
|
|
ACL_API int zdb_key_walk(ZDB *db, int (*walk_fn)(ZDB_KEY_STORE *store));
|
|
|
|
|
|
|
|
|
|
/*-------------------- in zdb_dat_walk.c -----------------------------------*/
|
|
|
|
|
ACL_API int zdb_dat_walk(ZDB *db, int (*walk_fn)(ZDB_DAT_STORE *store));
|
|
|
|
|
|
|
|
|
|
/*-------------------- in zdb_key_iter.c -----------------------------------*/
|
|
|
|
|
|
|
|
|
|
/*-------------------- in zdb_dat_iter.c -----------------------------------*/
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>洢<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param store {ZDB_DAT_STORE*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param read_data {int} <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><EFBFBD><EFBFBD>, !0: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>е<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><EFBFBD><EFBFBD>; 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>е<EFBFBD>ͷ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void zdb_dat_iter_set(ZDB_DAT_STORE *store, int read_data);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-05-18 21:19:21 +08:00
|
|
|
|
#endif /* ACL_CLIENT_ONLY */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#endif
|