提交 afe0f1b6 编写于 作者: H Hongze Cheng

more TDB

上级 5fdfb808
......@@ -69,6 +69,11 @@ int tdbDbClose(STDb *pDb) {
return 0;
}
int tdbDbDrop(STDb *pDb) {
// TODO
return 0;
}
int tdbDbInsert(STDb *pDb, const void *pKey, int keyLen, const void *pVal, int valLen) {
// TODO
return 0;
......
......@@ -31,10 +31,16 @@ struct SPFile {
u8 inTran;
};
typedef struct {
/* TODO */
typedef struct __attribute__((__packed__)) {
u8 hdrString[16];
u16 pageSize;
SPgno freePage;
u32 nFreePages;
u8 reserved[102];
} SFileHdr;
TDB_STATIC_ASSERT(sizeof(SFileHdr) == 128, "Size of file header is not correct");
static int tdbPFileReadPage(SPFile *pFile, SPage *pPage);
int tdbPFileOpen(SPCache *pCache, const char *fileName, SPFile **ppFile) {
......
......@@ -24,6 +24,7 @@ typedef struct STDb STDb;
int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprFn, STEnv *pEnv, STDb **ppDb);
int tdbDbClose(STDb *pDb);
int tdbDbDrop(STDb *pDb);
int tdbDbInsert(STDb *pDb, const void *pKey, int keyLen, const void *pVal, int valLen);
#ifdef __cplusplus
......
......@@ -15,9 +15,14 @@ TEST(tdb_test, simple_test) {
ret = tdbDbOpen("db.db", TDB_VARIANT_LEN, TDB_VARIANT_LEN, NULL, pEnv, &pDb);
GTEST_ASSERT_EQ(ret, 0);
// Insert some data
ret = tdbDbInsert(pDb, "1", 1, "world", 5);
GTEST_ASSERT_EQ(ret, 0);
// // Insert some data
// ret = tdbDbInsert(pDb, "1", 1, "world", 5);
// GTEST_ASSERT_EQ(ret, 0);
ret = tdbDbDrop(pDb);
if (pDb == NULL) {
return -1;
}
// Close a database
tdbDbClose(pDb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册