diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h
index 02b4422882f2f95873e53197a7a9ff4f58643309..3a1523e6c6124b0f032a189f4327f5983f2a5d58 100644
--- a/source/libs/tdb/inc/tdb.h
+++ b/source/libs/tdb/inc/tdb.h
@@ -30,6 +30,8 @@ typedef enum { TDB_BTREE_T = 0, TDB_HASH_T = 1, TDB_HEAP_T = 2 } tdb_db_t;
// Forward declarations
typedef struct TDB TDB;
+typedef struct TDB_MPOOL TDB_MPOOL;
+typedef struct TDB_MPFILE TDB_MPFILE;
typedef struct TDB_CURSOR TDB_CURSOR;
typedef struct {
@@ -44,6 +46,18 @@ int tdbCloseDB(TDB* dbp, uint32_t flags);
int tdbPut(TDB* dbp, const TDB_KEY* key, const TDB_VALUE* value, uint32_t flags);
int tdbGet(TDB* dbp, const TDB_KEY* key, TDB_VALUE* value, uint32_t flags);
+// TDB_MPOOL
+int tdbOpenMPool(TDB_MPOOL** mp);
+int tdbCloseMPool(TDB_MPOOL* mp);
+
+// TDB_MPFILE
+int tdbOpenMPFile(TDB_MPFILE** mpf, TDB_MPOOL* mp);
+int tdbCloseMPFile(TDB_MPFILE** mpf);
+
+// TDB_CURSOR
+int tdbOpenCursor(TDB* dbp, TDB_CURSOR** tdbcpp);
+int tdbCloseCurosr(TDB_CURSOR* tdbcp);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/libs/tdb/src/inc/tdbDB.h b/source/libs/tdb/src/inc/tdbDB.h
index d0ef9e22d0f625889ee2403c2820b6c3a5fc54d2..261fb587b42680197cb621ddadd7cd12bd046d38 100644
--- a/source/libs/tdb/src/inc/tdbDB.h
+++ b/source/libs/tdb/src/inc/tdbDB.h
@@ -25,10 +25,6 @@
extern "C" {
#endif
-typedef struct {
- // TODO
-} TDB_MPOOL;
-
typedef struct {
int fd;
} TDB_FH;
diff --git a/source/libs/tdb/src/inc/tdbDef.h b/source/libs/tdb/src/inc/tdbDef.h
index 4b5e54368bddd630c21db87a80dd398c8354fce1..48a6831f869874e833cd0de6940cd735707f6b73 100644
--- a/source/libs/tdb/src/inc/tdbDef.h
+++ b/source/libs/tdb/src/inc/tdbDef.h
@@ -17,6 +17,7 @@
#define _TD_TDB_DEF_H_
#include "os.h"
+#include "tlist.h"
#ifdef __cplusplus
extern "C" {
diff --git a/source/libs/tdb/src/inc/tdbBufPool.h b/source/libs/tdb/src/inc/tdb_mpfile.h
similarity index 57%
rename from source/libs/tdb/src/inc/tdbBufPool.h
rename to source/libs/tdb/src/inc/tdb_mpfile.h
index 5200d22faaa8153d2e71265b0fbc22b7158af3d6..8eaafafd41c56a61c7904f22d1d9b66c968286c1 100644
--- a/source/libs/tdb/src/inc/tdbBufPool.h
+++ b/source/libs/tdb/src/inc/tdb_mpfile.h
@@ -13,27 +13,25 @@
* along with this program. If not, see .
*/
-#ifndef _TD_TDB_BUF_POOL_H_
-#define _TD_TDB_BUF_POOL_H_
+#ifndef _TD_TDB_MPFILE_H_
+#define _TD_TDB_MPFILE_H_
-#include "tdbPage.h"
+#include "tdbDef.h"
+#include "tdb_mpool.h"
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct STdbBufPool STdbBufPool;
+struct TDB_MPFILE {
+ TDB_MPOOL *mp; // memory pool used to get/put pages in this file
-int tbpOpen(STdbBufPool **ppTkvBufPool);
-int tbpClose(STdbBufPool *pTkvBufPool);
-STdbPage *tbpNewPage(STdbBufPool *pTkvBufPool);
-int tbpDelPage(STdbBufPool *pTkvBufPool);
-STdbPage *tbpFetchPage(STdbBufPool *pTkvBufPool, pgid_t pgid);
-int tbpUnpinPage(STdbBufPool *pTkvBufPool, pgid_t pgid);
-void tbpFlushPages(STdbBufPool *pTkvBufPool);
+ char *fname;
+ int fd;
+};
#ifdef __cplusplus
}
#endif
-#endif /*_TD_TDB_BUF_POOL_H_*/
\ No newline at end of file
+#endif /*_TD_TDB_MPFILE_H_*/
\ No newline at end of file
diff --git a/source/libs/tdb/src/inc/tdb_mpool.h b/source/libs/tdb/src/inc/tdb_mpool.h
new file mode 100644
index 0000000000000000000000000000000000000000..9e34362c40760676e9cd879f5cd35112f09d400c
--- /dev/null
+++ b/source/libs/tdb/src/inc/tdb_mpool.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program 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.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef _TD_TDB_MPOOL_H_
+#define _TD_TDB_MPOOL_H_
+
+#include "tdbDef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct TDB_MPOOL {
+ pthread_mutex_t mutex;
+ int64_t cachesize;
+ pgsize_t pgsize;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_TD_TDB_MPOOL_H_*/
\ No newline at end of file
diff --git a/source/libs/tdb/src/mpool/tdbBufPool.c b/source/libs/tdb/src/mpool/tdbBufPool.c
deleted file mode 100644
index bc3c386b0fc23a5796decefa4d959a53d6a35cd6..0000000000000000000000000000000000000000
--- a/source/libs/tdb/src/mpool/tdbBufPool.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program 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.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#include "thash.h"
-#include "tlist.h"
-
-#include "tdbBufPool.h"
-#include "tdbDiskMgr.h"
-#include "tdbPage.h"
-
-struct SFrameIdWrapper {
- TD_SLIST_NODE(SFrameIdWrapper);
- frame_id_t id;
-};
-
-struct STdbBufPool {
- STdbPage* pages;
- STkvDiskMgr* pDiskMgr;
- SHashObj* pgTb; // page_id_t --> frame_id_t
- TD_SLIST(SFrameIdWrapper) freeList;
- pthread_mutex_t mutex;
-};
-
-typedef struct STkvLRUReplacer {
-} STkvLRUReplacer;
-
-typedef struct STkvLFUReplacer {
-} STkvLFUReplacer;
-
-typedef struct STkvCLKReplacer {
-} STkvCLKReplacer;
-
-typedef enum { TKV_LRU_REPLACER = 0, TKV_LFU_REPLACER, TVK_CLK_REPLACER } tkv_replacer_t;
-
-typedef struct STkvReplacer {
- tkv_replacer_t type;
- union {
- STkvLRUReplacer lruRep;
- STkvLFUReplacer lfuRep;
- STkvCLKReplacer clkRep;
- };
-} STkvReplacer;
\ No newline at end of file
diff --git a/source/libs/tdb/src/mpool/tdb_mpool.c b/source/libs/tdb/src/mpool/tdb_mpool.c
new file mode 100644
index 0000000000000000000000000000000000000000..6dea4a4e57392be988126c579648f39a8270b9bf
--- /dev/null
+++ b/source/libs/tdb/src/mpool/tdb_mpool.c
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program 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.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
\ No newline at end of file