diff --git a/source/libs/tdb/src/db/btree.c b/source/libs/tdb/src/db/btree.c index 6dea4a4e57392be988126c579648f39a8270b9bf..2ce1e62c16c2292457c8b5c05774113df82ee1b1 100644 --- a/source/libs/tdb/src/db/btree.c +++ b/source/libs/tdb/src/db/btree.c @@ -11,4 +11,6 @@ * * 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 + */ + +#include "tdbInt.h" \ No newline at end of file diff --git a/source/libs/tdb/src/db/pgcache.c b/source/libs/tdb/src/db/pgcache.c index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2ce1e62c16c2292457c8b5c05774113df82ee1b1 100644 --- a/source/libs/tdb/src/db/pgcache.c +++ b/source/libs/tdb/src/db/pgcache.c @@ -0,0 +1,16 @@ +/* + * 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 . + */ + +#include "tdbInt.h" \ No newline at end of file diff --git a/source/libs/tdb/src/db/pgfile.c b/source/libs/tdb/src/db/pgfile.c index 6dea4a4e57392be988126c579648f39a8270b9bf..2ce1e62c16c2292457c8b5c05774113df82ee1b1 100644 --- a/source/libs/tdb/src/db/pgfile.c +++ b/source/libs/tdb/src/db/pgfile.c @@ -11,4 +11,6 @@ * * 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 + */ + +#include "tdbInt.h" \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdb.c b/source/libs/tdb/src/db/tdb.c index 112fade741af99d0cea07157d2f2201dbf60f5f9..0a24331a362e846bf0a09dbe29252ace002e0407 100644 --- a/source/libs/tdb/src/db/tdb.c +++ b/source/libs/tdb/src/db/tdb.c @@ -13,61 +13,61 @@ * along with this program. If not, see . */ -#include "tdb_db.h" +#include "tdbInt.h" -static int tdbOpenImpl(TDB *dbp); +// static int tdbOpenImpl(TDB *dbp); -int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags) { - TDB * dbp; - TDB_MPFILE *mpf; - uint8_t fileid[TDB_FILE_ID_LEN]; +// int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags) { +// TDB * dbp; +// TDB_MPFILE *mpf; +// uint8_t fileid[TDB_FILE_ID_LEN]; - if ((dbp = (TDB *)calloc(1, sizeof(*dbp))) == NULL) { - return -1; - } +// if ((dbp = (TDB *)calloc(1, sizeof(*dbp))) == NULL) { +// return -1; +// } - if ((dbp->fname = strdup(fname)) == NULL) { - free(dbp); - return -1; - } +// if ((dbp->fname = strdup(fname)) == NULL) { +// free(dbp); +// return -1; +// } - if ((dbname) && ((dbp->dbname = strdup(dbname)) == NULL)) { - free(dbp->fname); - free(dbp); - return -1; - } +// if ((dbname) && ((dbp->dbname = strdup(dbname)) == NULL)) { +// free(dbp->fname); +// free(dbp); +// return -1; +// } - // if (tdbGnrtFileID(fname, fileid) < 0) { - // // todo - // return -1; - // } +// // if (tdbGnrtFileID(fname, fileid) < 0) { +// // // todo +// // return -1; +// // } - // TODO: mpf = tdbGetMPFileByID(fileid); - if (mpf == NULL) { - // todoerr: maybe we need to create one - return -1; - } +// // TODO: mpf = tdbGetMPFileByID(fileid); +// if (mpf == NULL) { +// // todoerr: maybe we need to create one +// return -1; +// } - if (tdbOpenImpl(dbp) < 0) { - // todoerr - return -1; - } +// if (tdbOpenImpl(dbp) < 0) { +// // todoerr +// return -1; +// } - *dbpp = dbp; - return 0; -} +// *dbpp = dbp; +// return 0; +// } -int tdbClose(TDB *dbp, uint32_t flags) { - // TODO - return 0; -} +// int tdbClose(TDB *dbp, uint32_t flags) { +// // TODO +// return 0; +// } -static int tdbOpenImpl(TDB *dbp) { - if (dbp->dbname == NULL) { - // todo: open the DB as a master DB - } else { - // todo: open the DB as a sub-db - } - // TODO - return 0; -} \ No newline at end of file +// static int tdbOpenImpl(TDB *dbp) { +// if (dbp->dbname == NULL) { +// // todo: open the DB as a master DB +// } else { +// // todo: open the DB as a sub-db +// } +// // TODO +// return 0; +// } \ No newline at end of file diff --git a/source/libs/tdb/src/inc/btree.h b/source/libs/tdb/src/inc/btree.h index 7b1b6cd2efc5d08b0e90d77a25bb6063f32b0af8..01658d5e0069d5ae2dd635f5e1e5d7c0dbf1dbc6 100644 --- a/source/libs/tdb/src/inc/btree.h +++ b/source/libs/tdb/src/inc/btree.h @@ -16,6 +16,8 @@ #ifndef _TD_BTREE_H_ #define _TD_BTREE_H_ +#include "tdbInt.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/source/libs/tdb/src/inc/pgfile.h b/source/libs/tdb/src/inc/pgfile.h index f9a7435b3d97b7036f90fafb1386db85b1553f59..9c502fed9e09cd53ded204ff1997b08da5b8a874 100644 --- a/source/libs/tdb/src/inc/pgfile.h +++ b/source/libs/tdb/src/inc/pgfile.h @@ -16,12 +16,21 @@ #ifndef _TD_PAGE_FILE_H_ #define _TD_PAGE_FILE_H_ +#include "tdbInt.h" + +#include "pgcache.h" + #ifdef __cplusplus extern "C" { #endif typedef struct SPgFile SPgFile; +struct SPgFile { + char * fname; // backend file name + SPgCache *pPgCache; // page cache underline +}; + #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index c2ca7b0cfb06e761a493b83ce66b0b533b091a1c..3746c5f0772a38be8c7bfb099de33607113a934d 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -20,6 +20,8 @@ #include "tlist.h" #include "tlockfree.h" +#include "tdb.h" + #ifdef __cplusplus extern "C" { #endif @@ -51,6 +53,8 @@ typedef int32_t pgsize_t; // tdb_log #define tdbError(var) +#include "pgcache.h" + // tdb util int tdbGnrtFileID(const char *fname, uint8_t *fileid); diff --git a/source/libs/tdb/src/inc/tdb_db.h b/source/libs/tdb/src/inc/tdb_db.h deleted file mode 100644 index 5f0529462b0f592b3d3adf927865c048d882b6f3..0000000000000000000000000000000000000000 --- a/source/libs/tdb/src/inc/tdb_db.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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_TDB_DB_H_ -#define _TD_TDB_DB_H_ - -#include "tdb_mpool.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct TDB TDB; - -struct TDB { - char * fname; - char * dbname; - TDB_MPFILE *mpf; - // union { - // TDB_BTREE *btree; - // TDB_HASH * hash; - // TDB_HEAP * heap; - // } dbam; // db access method -}; - -int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags); -int tdbClose(TDB *dbp, uint32_t flags); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_TDB_DB_H_*/ \ No newline at end of file