提交 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;
// 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
......
......@@ -25,10 +25,6 @@
extern "C" {
#endif
typedef struct {
// TODO
} TDB_MPOOL;
typedef struct {
int fd;
} TDB_FH;
......
......@@ -17,6 +17,7 @@
#define _TD_TDB_DEF_H_
#include "os.h"
#include "tlist.h"
#ifdef __cplusplus
extern "C" {
......
......@@ -13,27 +13,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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
......@@ -13,42 +13,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "thash.h"
#include "tlist.h"
#ifndef _TD_TDB_MPOOL_H_
#define _TD_TDB_MPOOL_H_
#include "tdbBufPool.h"
#include "tdbDiskMgr.h"
#include "tdbPage.h"
#include "tdbDef.h"
struct SFrameIdWrapper {
TD_SLIST_NODE(SFrameIdWrapper);
frame_id_t id;
};
#ifdef __cplusplus
extern "C" {
#endif
struct STdbBufPool {
STdbPage* pages;
STkvDiskMgr* pDiskMgr;
SHashObj* pgTb; // page_id_t --> frame_id_t
TD_SLIST(SFrameIdWrapper) freeList;
struct TDB_MPOOL {
pthread_mutex_t mutex;
int64_t cachesize;
pgsize_t pgsize;
};
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;
#ifdef __cplusplus
}
#endif
typedef struct STkvReplacer {
tkv_replacer_t type;
union {
STkvLRUReplacer lruRep;
STkvLFUReplacer lfuRep;
STkvCLKReplacer clkRep;
};
} STkvReplacer;
\ No newline at end of file
#endif /*_TD_TDB_MPOOL_H_*/
\ 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.
先完成此消息的编辑!
想要评论请 注册