This commit is contained in:
Hongze Cheng 2022-02-09 03:38:22 +00:00
parent 8d04fb6471
commit f571942846
5 changed files with 44 additions and 15 deletions

View File

@ -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);

View File

@ -18,4 +18,5 @@
struct STDbEnv {
TDB * dbList; // TDB list
SPgFile *pgFileList; // SPgFile list
SPgCache pgc; // page cache
};

View File

@ -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

View File

@ -0,0 +1,27 @@
/*
* 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 _TDB_ENV_H_
#define _TDB_ENV_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /*_TDB_ENV_H_*/

View File

@ -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);