more tkv
This commit is contained in:
parent
3c512df931
commit
73f802c3f5
|
@ -29,10 +29,10 @@ extern "C" {
|
|||
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 TDB TDB;
|
||||
// typedef struct TDB_MPOOL TDB_MPOOL;
|
||||
// typedef struct TDB_MPFILE TDB_MPFILE;
|
||||
// typedef struct TDB_CURSOR TDB_CURSOR;
|
||||
|
||||
typedef struct {
|
||||
void* bdata;
|
||||
|
@ -46,17 +46,17 @@ 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_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_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);
|
||||
// // TDB_CURSOR
|
||||
// int tdbOpenCursor(TDB* dbp, TDB_CURSOR** tdbcpp);
|
||||
// int tdbCloseCurosr(TDB_CURSOR* tdbcp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -13,23 +13,15 @@
|
|||
* 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"
|
||||
#ifndef _TD_TDB_INC_H_
|
||||
#define _TD_TDB_INC_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_*/
|
||||
#endif /*_TD_TDB_INC_H_*/
|
|
@ -23,11 +23,21 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct TDB_MPFILE {
|
||||
TDB_MPOOL *mp; // memory pool used to get/put pages in this file
|
||||
// Exposed handle
|
||||
typedef struct TDB_MPFILE TDB_MPFILE;
|
||||
|
||||
char *fname;
|
||||
int fd;
|
||||
// Exposed apis
|
||||
int tdbMPFOpen(TDB_MPFILE **mpfp, const char *fname, TDB_MPOOL *mp);
|
||||
int tdbMPFClose(TDB_MPFILE *mpf);
|
||||
int tdbMPFGet(TDB_MPFILE *mpf, pgid_t pgid, void *addr);
|
||||
int tdbMPFPut(TDB_MPOOL *mpf, pgid_t pgid, void *addr);
|
||||
|
||||
// Hidden structures
|
||||
struct TDB_MPFILE {
|
||||
uint8_t fuid[20]; // file unique ID
|
||||
TDB_MPOOL *mp; // underlying memory pool
|
||||
char * fname; // file name
|
||||
int fd; // fd
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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
|
||||
|
||||
// Exposed handle
|
||||
typedef struct TDB_MPOOL TDB_MPOOL;
|
||||
|
||||
// Exposed apis
|
||||
int tdbOpenMP(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize);
|
||||
int tdbCloseMP(TDB_MPOOL *mp);
|
||||
int tdbMPFetchPage(TDB_MPOOL *mp, mp_pgid_t mpgid, void *p);
|
||||
int tdbMpUnfetchPage(TDB_MPOOL *mp, mp_pgid_t mpgid, void *p);
|
||||
|
||||
// Hidden impls
|
||||
#define TDB_FILE_UID_LEN 20
|
||||
|
||||
typedef struct {
|
||||
uint8_t fuid[TDB_FILE_UID_LEN];
|
||||
pgid_t pgid;
|
||||
} mp_pgid_t;
|
||||
|
||||
typedef struct MP_PAGE {
|
||||
SRWLatch rwLatch;
|
||||
mp_pgid_t mpgid;
|
||||
uint8_t dirty;
|
||||
int32_t pinRef;
|
||||
// TD_DLIST_NODE(MP_PAGE); // The free list handle
|
||||
char *page[];
|
||||
} MP_PAGE;
|
||||
|
||||
struct TDB_MPOOL {
|
||||
pthread_mutex_t mutex;
|
||||
int64_t cachesize;
|
||||
pgsize_t pgsize;
|
||||
MP_PAGE * pages;
|
||||
// TD_DBLIST(MP_PAGE) freeList;
|
||||
// TD_DLIST(TD_MPFILE) mpfList; // MPFILE registered on this memory pool
|
||||
// Hash<mp_pgid_t, frameid> hash;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_TDB_MPOOL_H_*/
|
|
@ -40,8 +40,8 @@ struct TDB {
|
|||
TDB_HEAP * heap;
|
||||
} dbam; // db access method
|
||||
|
||||
TDB_FH * fhp; // The backup file handle
|
||||
TDB_MPOOL *mph; // The memory pool handle
|
||||
// TDB_FH * fhp; // The backup file handle
|
||||
// TDB_MPOOL *mph; // The memory pool handle
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue