refact tdb
This commit is contained in:
parent
ebf0ee3625
commit
0230a529f7
|
@ -1,14 +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/>.
|
|
||||||
*/
|
|
|
@ -13,7 +13,7 @@
|
||||||
* 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 "tdb_mp.h"
|
#include "tdb_mpool.h"
|
||||||
|
|
||||||
int tdbOpenMP(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize) {
|
int tdbOpenMP(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize) {
|
||||||
TDB_MPOOL *mp;
|
TDB_MPOOL *mp;
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// pgid_t
|
// pgno_t
|
||||||
typedef int32_t pgid_t;
|
typedef int32_t pgno_t;
|
||||||
#define TDB_IVLD_PGID ((pgid_t)-1)
|
#define TDB_IVLD_PGID ((pgno_t)-1)
|
||||||
|
|
||||||
// framd_id_t
|
// framd_id_t
|
||||||
typedef int32_t frame_id_t;
|
typedef int32_t frame_id_t;
|
||||||
|
|
|
@ -1,46 +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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_TDB_MPFILE_H_
|
|
||||||
#define _TD_TDB_MPFILE_H_
|
|
||||||
|
|
||||||
#include "tdb_mpool.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Exposed handle
|
|
||||||
typedef struct TDB_MPFILE TDB_MPFILE;
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_TDB_MPFILE_H_*/
|
|
|
@ -24,10 +24,11 @@ extern "C" {
|
||||||
|
|
||||||
// Exposed handle
|
// Exposed handle
|
||||||
typedef struct TDB_MPOOL TDB_MPOOL;
|
typedef struct TDB_MPOOL TDB_MPOOL;
|
||||||
|
typedef struct TDB_MPFILE TDB_MPFILE;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t fuid[TDB_FILE_UID_LEN];
|
uint8_t fuid[TDB_FILE_UID_LEN];
|
||||||
pgid_t pgid;
|
pgno_t pgid;
|
||||||
} mp_pgid_t;
|
} mp_pgid_t;
|
||||||
|
|
||||||
typedef struct MP_PAGE {
|
typedef struct MP_PAGE {
|
||||||
|
@ -55,15 +56,28 @@ struct TDB_MPOOL {
|
||||||
// TODO: TD_DLIST(TD_MPFILE) mpfList; // MPFILE registered on this memory pool
|
// TODO: TD_DLIST(TD_MPFILE) mpfList; // MPFILE registered on this memory pool
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TDB_MPFILE {
|
||||||
|
uint8_t fuid[20]; // file unique ID
|
||||||
|
TDB_MPOOL *mp; // underlying memory pool
|
||||||
|
char * fname; // file name
|
||||||
|
int fd; // fd
|
||||||
|
};
|
||||||
|
|
||||||
#define MP_PAGE_AT(mp, idx) ((char *)((mp)->pages) + MP_PAGE_SIZE((mp)->pgsize) * (idx))
|
#define MP_PAGE_AT(mp, idx) ((char *)((mp)->pages) + MP_PAGE_SIZE((mp)->pgsize) * (idx))
|
||||||
|
|
||||||
// Exposed apis =====================================================================================================
|
/*=================================================== Exposed apis ==================================================*/
|
||||||
|
// TDB_MPOOL
|
||||||
int tdbOpenMP(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize);
|
int tdbOpenMP(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize);
|
||||||
int tdbCloseMP(TDB_MPOOL *mp);
|
int tdbCloseMP(TDB_MPOOL *mp);
|
||||||
int tdbMPFetchPage(TDB_MPOOL *mp, mp_pgid_t mpgid, void *p);
|
int tdbMPFetchPage(TDB_MPOOL *mp, mp_pgid_t mpgid, void *p);
|
||||||
int tdbMpUnfetchPage(TDB_MPOOL *mp, mp_pgid_t mpgid, void *p);
|
int tdbMpUnfetchPage(TDB_MPOOL *mp, mp_pgid_t mpgid, void *p);
|
||||||
|
|
||||||
|
// TDB_MPFILE
|
||||||
|
int tdbMPFOpen(TDB_MPFILE **mpfp, const char *fname, TDB_MPOOL *mp);
|
||||||
|
int tdbMPFClose(TDB_MPFILE *mpf);
|
||||||
|
int tdbMPFGet(TDB_MPFILE *mpf, pgno_t pgid, void *addr);
|
||||||
|
int tdbMPFPut(TDB_MPOOL *mpf, pgno_t pgid, void *addr);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue