diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index faf9208f8f..71ac3d97ed 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -22,42 +22,6 @@ extern "C" { #endif -// #define TDB_EXTERN -// #define TDB_PUBLIC -// #define TDB_STATIC static - -// 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 { -// void* bdata; -// uint32_t size; -// } TDB_KEY, TDB_VALUE; - -// // TDB Operations -// int tdbCreateDB(TDB** dbpp, tdb_db_t type); -// int tdbOpenDB(TDB* dbp, const char* fname, const char* dbname, uint32_t flags); -// 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 diff --git a/source/libs/tdb/src/db/btree.c b/source/libs/tdb/src/db/btree.c new file mode 100644 index 0000000000..6dea4a4e57 --- /dev/null +++ b/source/libs/tdb/src/db/btree.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ \ No newline at end of file diff --git a/source/libs/tdb/src/db/pgcache.c b/source/libs/tdb/src/db/pgcache.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/source/libs/tdb/src/db/pgfile.c b/source/libs/tdb/src/db/pgfile.c new file mode 100644 index 0000000000..6dea4a4e57 --- /dev/null +++ b/source/libs/tdb/src/db/pgfile.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdb_db.c b/source/libs/tdb/src/db/tdb.c similarity index 100% rename from source/libs/tdb/src/db/tdb_db.c rename to source/libs/tdb/src/db/tdb.c diff --git a/source/libs/tdb/src/db/tdb_util.c b/source/libs/tdb/src/db/tdb_util.c index 9a5df604c4..6391397efd 100644 --- a/source/libs/tdb/src/db/tdb_util.c +++ b/source/libs/tdb/src/db/tdb_util.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "tdb_inc.h" +#include "tdbInt.h" int tdbGnrtFileID(const char *fname, uint8_t *fileid) { struct stat statbuf; diff --git a/source/libs/tdb/src/inc/tdb_btree.h b/source/libs/tdb/src/inc/btree.h similarity index 85% rename from source/libs/tdb/src/inc/tdb_btree.h rename to source/libs/tdb/src/inc/btree.h index a593c3b4e8..7b1b6cd2ef 100644 --- a/source/libs/tdb/src/inc/tdb_btree.h +++ b/source/libs/tdb/src/inc/btree.h @@ -13,21 +13,21 @@ * along with this program. If not, see . */ -#ifndef _TDB_BTREE_H_ -#define _TDB_BTREE_H_ - -#include "tdb_inc.h" +#ifndef _TD_BTREE_H_ +#define _TD_BTREE_H_ #ifdef __cplusplus extern "C" { #endif +typedef struct SBTree SBTree; + struct SBTree { - pgno_t root; // root page number + // TODO }; #ifdef __cplusplus } #endif -#endif /*_TDB_BTREE_H_*/ \ No newline at end of file +#endif /*_TD_BTREE_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/inc/pgcache.h b/source/libs/tdb/src/inc/pgcache.h new file mode 100644 index 0000000000..0bf5d22f3f --- /dev/null +++ b/source/libs/tdb/src/inc/pgcache.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_PAGE_CACHE_H_ +#define _TD_PAGE_CACHE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SPgCache SPgCache; +typedef struct SPage SPage; + +// SPgCache +int pgCacheCreate(SPgCache **ppPgCache); +int pgCacheDestroy(SPgCache *pPgCache); +int pgCacheOpen(SPgCache *pPgCache); +int pgCacheClose(SPgCache *pPgCache); + +SPage *pgCacheFetch(SPgCache *pPgCache); +int pgCacheRelease(SPage *pPage); + +// SPage + +// Impl +struct SPgCache { + // TODO +}; + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_PAGE_CACHE_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdb_page.h b/source/libs/tdb/src/inc/pgfile.h similarity index 72% rename from source/libs/tdb/src/inc/tdb_page.h rename to source/libs/tdb/src/inc/pgfile.h index 42981a5e8b..f9a7435b3d 100644 --- a/source/libs/tdb/src/inc/tdb_page.h +++ b/source/libs/tdb/src/inc/pgfile.h @@ -13,25 +13,17 @@ * along with this program. If not, see . */ -#ifndef _TDB_PAGE_H_ -#define _TDB_PAGE_H_ - -#include "tdb_inc.h" +#ifndef _TD_PAGE_FILE_H_ +#define _TD_PAGE_FILE_H_ #ifdef __cplusplus extern "C" { #endif -// Page header -typedef struct { - uint32_t magic; - pgno_t pgno; // current page number - pgno_t npgno; // next page number - pgno_t ppgno; // prev page number -} SPgHdr; +typedef struct SPgFile SPgFile; #ifdef __cplusplus } #endif -#endif /*_TDB_PAGE_H_*/ \ No newline at end of file +#endif /*_TD_PAGE_FILE_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdb_inc.h b/source/libs/tdb/src/inc/tdbInt.h similarity index 93% rename from source/libs/tdb/src/inc/tdb_inc.h rename to source/libs/tdb/src/inc/tdbInt.h index 9e13f779e7..c2ca7b0cfb 100644 --- a/source/libs/tdb/src/inc/tdb_inc.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_TDB_INC_H_ -#define _TD_TDB_INC_H_ +#ifndef _TD_TDB_INTERNAL_H_ +#define _TD_TDB_INTERNAL_H_ #include "os.h" #include "tlist.h" @@ -58,4 +58,4 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid); } #endif -#endif /*_TD_TDB_INC_H_*/ +#endif /*_TD_TDB_INTERNAL_H_*/ diff --git a/source/libs/tdb/src/inc/tdb_mpool.h b/source/libs/tdb/src/inc/tdb_mpool.h index 37c82f3833..55754484c0 100644 --- a/source/libs/tdb/src/inc/tdb_mpool.h +++ b/source/libs/tdb/src/inc/tdb_mpool.h @@ -16,7 +16,7 @@ #ifndef _TD_TDB_MPOOL_H_ #define _TD_TDB_MPOOL_H_ -#include "tdb_inc.h" +#include "tdbInt.h" #ifdef __cplusplus extern "C" {