more tkv
This commit is contained in:
parent
7a57f0c70d
commit
1e84bce89f
|
@ -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);
|
||||||
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 @@
|
||||||
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 @@
|
||||||
#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 @@
|
||||||
* 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_*/
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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_*/
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#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;
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
Loading…
Reference in New Issue