提交 d93d1093 编写于 作者: S slguan

[TD-15] refact the interface of sdb

上级 47029bc3
...@@ -21,46 +21,47 @@ extern "C" { ...@@ -21,46 +21,47 @@ extern "C" {
#endif #endif
typedef enum { typedef enum {
SDB_KEYTYPE_STRING, SDB_KEY_TYPE_STRING,
SDB_KEYTYPE_AUTO, SDB_KEY_TYPE_AUTO
SDB_KEYTYPE_MAX
} ESdbKeyType; } ESdbKeyType;
typedef enum { typedef enum {
SDB_OPER_GLOBAL, SDB_OPER_TYPE_GLOBAL,
SDB_OPER_LOCAL, SDB_OPER_TYPE_LOCAL
SDB_OPER_DISK
} ESdbOperType; } ESdbOperType;
enum _sdbaction { typedef struct {
SDB_TYPE_INSERT, ESdbOperType type;
SDB_TYPE_DELETE, int32_t maxRowSize;
SDB_TYPE_UPDATE, int32_t rowSize;
} ESdbForwardType; void * rowData;
void * pObj;
void * table;
int64_t version;
} SSdbOperDesc;
typedef struct { typedef struct {
char *tableName; char *tableName;
int32_t hashSessions; int32_t hashSessions;
int32_t maxRowSize; int32_t maxRowSize;
ESdbKeyType keyType; ESdbKeyType keyType;
int32_t (*insertFp)(void *pObj); int32_t (*insertFp)(SSdbOperDesc *pOper);
int32_t (*deleteFp)(void *pObj); int32_t (*deleteFp)(SSdbOperDesc *pOper);
int32_t (*updateFp)(void *pObj); int32_t (*updateFp)(SSdbOperDesc *pOper);
int32_t (*encodeFp)(void *pObj, void *pData, int32_t maxRowSize); int32_t (*encodeFp)(SSdbOperDesc *pOper);
void * (*decodeFp)(void *pData); int32_t (*decodeFp)(SSdbOperDesc *pDesc);
int32_t (*destroyFp)(void *pObj); int32_t (*destroyFp)(SSdbOperDesc *pDesc);
} SSdbTableDesc; } SSdbTableDesc;
void *sdbOpenTable(SSdbTableDesc *desc); void *sdbOpenTable(SSdbTableDesc *desc);
void sdbCloseTable(void *handle); void sdbCloseTable(void *handle);
int32_t sdbInsertRow(void *handle, void *row, ESdbOperType oper); int32_t sdbInsertRow(SSdbOperDesc *pOper);
int32_t sdbDeleteRow(void *handle, void *key, ESdbOperType oper); int32_t sdbDeleteRow(SSdbOperDesc *pOper);
int32_t sdbUpdateRow(void *handle, void *row, int32_t rowSize, ESdbOperType oper); int32_t sdbUpdateRow(SSdbOperDesc *pOper);
void *sdbGetRow(void *handle, void *key); void *sdbGetRow(void *handle, void *key);
void *sdbFetchRow(void *handle, void *pNode, void **ppRow); void *sdbFetchRow(void *handle, void *pNode, void **ppRow);
int64_t sdbGetId(void *handle);
int64_t sdbGetNumOfRows(void *handle); int64_t sdbGetNumOfRows(void *handle);
uint64_t sdbGetVersion(); uint64_t sdbGetVersion();
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册