[TD-15] refact the interface of sdb

This commit is contained in:
slguan 2020-03-22 10:12:41 +08:00
parent 47029bc349
commit d93d1093b8
2 changed files with 438 additions and 405 deletions

View File

@ -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();

File diff suppressed because it is too large Load Diff