提交 1e84bce8 编写于 作者: H Hongze Cheng

more tkv

上级 7a57f0c7
...@@ -30,6 +30,8 @@ typedef enum { TDB_BTREE_T = 0, TDB_HASH_T = 1, TDB_HEAP_T = 2 } tdb_db_t; ...@@ -30,6 +30,8 @@ typedef enum { TDB_BTREE_T = 0, TDB_HASH_T = 1, TDB_HEAP_T = 2 } tdb_db_t;
// Forward declarations // Forward declarations
typedef struct TDB TDB; typedef struct TDB TDB;
typedef struct TDB_MPOOL TDB_MPOOL;
typedef struct TDB_MPFILE TDB_MPFILE;
typedef struct TDB_CURSOR TDB_CURSOR; typedef struct TDB_CURSOR TDB_CURSOR;
typedef struct { typedef struct {
...@@ -44,6 +46,18 @@ int tdbCloseDB(TDB* dbp, uint32_t flags); ...@@ -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 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); 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 #ifdef __cplusplus
} }
#endif #endif
......
...@@ -25,10 +25,6 @@ ...@@ -25,10 +25,6 @@
extern "C" { extern "C" {
#endif #endif
typedef struct {
// TODO
} TDB_MPOOL;
typedef struct { typedef struct {
int fd; int fd;
} TDB_FH; } TDB_FH;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define _TD_TDB_DEF_H_ #define _TD_TDB_DEF_H_
#include "os.h" #include "os.h"
#include "tlist.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -13,27 +13,25 @@ ...@@ -13,27 +13,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_TDB_BUF_POOL_H_ #ifndef _TD_TDB_MPFILE_H_
#define _TD_TDB_BUF_POOL_H_ #define _TD_TDB_MPFILE_H_
#include "tdbPage.h" #include "tdbDef.h"
#include "tdb_mpool.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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); char *fname;
int tbpClose(STdbBufPool *pTkvBufPool); int fd;
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);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /*_TD_TDB_BUF_POOL_H_*/ #endif /*_TD_TDB_MPFILE_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -13,42 +13,23 @@ ...@@ -13,42 +13,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "thash.h" #ifndef _TD_TDB_MPOOL_H_
#include "tlist.h" #define _TD_TDB_MPOOL_H_
#include "tdbBufPool.h" #include "tdbDef.h"
#include "tdbDiskMgr.h"
#include "tdbPage.h"
struct SFrameIdWrapper { #ifdef __cplusplus
TD_SLIST_NODE(SFrameIdWrapper); extern "C" {
frame_id_t id; #endif
};
struct STdbBufPool { struct TDB_MPOOL {
STdbPage* pages;
STkvDiskMgr* pDiskMgr;
SHashObj* pgTb; // page_id_t --> frame_id_t
TD_SLIST(SFrameIdWrapper) freeList;
pthread_mutex_t mutex; pthread_mutex_t mutex;
int64_t cachesize;
pgsize_t pgsize;
}; };
typedef struct STkvLRUReplacer { #ifdef __cplusplus
} STkvLRUReplacer; }
#endif
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 { #endif /*_TD_TDB_MPOOL_H_*/
tkv_replacer_t type; \ No newline at end of file
union {
STkvLRUReplacer lruRep;
STkvLFUReplacer lfuRep;
STkvCLKReplacer clkRep;
};
} STkvReplacer;
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册