diff --git a/source/libs/tdb/src/db/pgcache.c b/source/libs/tdb/src/db/pgcache.c index 1d7fe0c32f33e298844738412de5c1a398d2f746..b0c4406a3c509f058532846f8b50a2206caaa3d4 100644 --- a/source/libs/tdb/src/db/pgcache.c +++ b/source/libs/tdb/src/db/pgcache.c @@ -14,21 +14,6 @@ */ #include "tdbInt.h" -typedef TD_DLIST(SPage) SPgList; - -struct SPgCache { - SRWLatch mutex; - pgsize_t pgsize; - int32_t npage; - SPage * pages; - SPgList freeList; - SPgList lru; - struct { - int32_t nbucket; - SPgList *buckets; - } pght; // page hash table -}; - static void pgCachePinPage(SPage *pPage); static void pgCacheUnpinPage(SPage *pPage); diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index aae92f2bedaa57d44ab8f40128f630057924a008..7de52f36593e9a9a67d9e39eb7c1dcada5f1506d 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -18,4 +18,5 @@ struct STDbEnv { TDB * dbList; // TDB list SPgFile *pgFileList; // SPgFile list + SPgCache pgc; // page cache }; \ No newline at end of file diff --git a/source/libs/tdb/src/inc/pgcache.h b/source/libs/tdb/src/inc/pgcache.h index d25877e8ffe14bc77cc5e4c1fcc7034c96be02e2..9296e0bea13be39eb3daa351e9e9a22aaf1844a9 100644 --- a/source/libs/tdb/src/inc/pgcache.h +++ b/source/libs/tdb/src/inc/pgcache.h @@ -44,6 +44,21 @@ struct SPage { uint8_t * pData; // real data }; +typedef TD_DLIST(SPage) SPgList; +struct SPgCache { + TENV * pEnv; // TENV containing this page cache + SRWLatch mutex; + pgsize_t pgsize; + int32_t npage; + SPage * pages; + SPgList freeList; + SPgList lru; + struct { + int32_t nbucket; + SPgList *buckets; + } pght; // page hash table +}; + #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/src/inc/tdbEnv.h b/source/libs/tdb/src/inc/tdbEnv.h new file mode 100644 index 0000000000000000000000000000000000000000..2bd93fc530d5ac2fd3a4ea1efc75192dc229cc38 --- /dev/null +++ b/source/libs/tdb/src/inc/tdbEnv.h @@ -0,0 +1,27 @@ +/* + * 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 _TDB_ENV_H_ +#define _TDB_ENV_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TDB_ENV_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index a2bbcbd562927b6b77ec754d562573c1a50c43b8..cbab052049f8eb5151999803d4bffdb757fff112 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -79,6 +79,7 @@ typedef int32_t pgsize_t; #include "btree.h" #include "pgcache.h" #include "pgfile.h" +#include "tdbEnv.h" // tdb util int tdbGnrtFileID(const char *fname, uint8_t *fileid);