more TDB
This commit is contained in:
parent
4b538a15f8
commit
08ed99b069
|
@ -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/>.
|
|
||||||
*/
|
|
|
@ -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/>.
|
|
||||||
*/
|
|
|
@ -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/>.
|
|
||||||
*/
|
|
|
@ -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/>.
|
|
||||||
*/
|
|
|
@ -1,27 +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 _TDB_BTREE_INT_H_
|
|
||||||
#define _TDB_BTREE_INT_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TDB_BTREE_INT_H_*/
|
|
|
@ -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/>.
|
|
||||||
*/
|
|
|
@ -18,6 +18,7 @@ struct SPCache {
|
||||||
int pageSize;
|
int pageSize;
|
||||||
int cacheSize;
|
int cacheSize;
|
||||||
tdb_mutex_t mutex;
|
tdb_mutex_t mutex;
|
||||||
|
SPage *pList;
|
||||||
int nFree;
|
int nFree;
|
||||||
SPage *pFree;
|
SPage *pFree;
|
||||||
int nPage;
|
int nPage;
|
||||||
|
@ -35,16 +36,17 @@ struct SPCache {
|
||||||
#define PAGE_IS_PINNED(pPage) ((pPage)->pLruNext == NULL)
|
#define PAGE_IS_PINNED(pPage) ((pPage)->pLruNext == NULL)
|
||||||
|
|
||||||
static int tdbPCacheOpenImpl(SPCache *pCache);
|
static int tdbPCacheOpenImpl(SPCache *pCache);
|
||||||
static void tdbPCacheInitLock(SPCache *pCache);
|
|
||||||
static void tdbPCacheClearLock(SPCache *pCache);
|
|
||||||
static void tdbPCacheLock(SPCache *pCache);
|
|
||||||
static void tdbPCacheUnlock(SPCache *pCache);
|
|
||||||
static bool tdbPCacheLocked(SPCache *pCache);
|
|
||||||
static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
|
static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
|
||||||
static void tdbPCachePinPage(SPCache *pCache, SPage *pPage);
|
static void tdbPCachePinPage(SPCache *pCache, SPage *pPage);
|
||||||
static void tdbPCacheRemovePageFromHash(SPCache *pCache, SPage *pPage);
|
static void tdbPCacheRemovePageFromHash(SPCache *pCache, SPage *pPage);
|
||||||
static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage);
|
static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage);
|
||||||
static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage);
|
static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage);
|
||||||
|
static int tdbPCacheCloseImpl(SPCache *pCache);
|
||||||
|
|
||||||
|
static void tdbPCacheInitLock(SPCache *pCache) { tdbMutexInit(&(pCache->mutex), NULL); }
|
||||||
|
static void tdbPCacheDestroyLock(SPCache *pCache) { tdbMutexDestroy(&(pCache->mutex)); }
|
||||||
|
static void tdbPCacheLock(SPCache *pCache) { tdbMutexLock(&(pCache->mutex)); }
|
||||||
|
static void tdbPCacheUnlock(SPCache *pCache) { tdbMutexUnlock(&(pCache->mutex)); }
|
||||||
|
|
||||||
int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) {
|
int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) {
|
||||||
SPCache *pCache;
|
SPCache *pCache;
|
||||||
|
@ -69,7 +71,10 @@ int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbPCacheClose(SPCache *pCache) {
|
int tdbPCacheClose(SPCache *pCache) {
|
||||||
/* TODO */
|
if (pCache) {
|
||||||
|
tdbPCacheCloseImpl(pCache);
|
||||||
|
tdbOsFree(pCache);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,19 +104,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tdbPCacheInitLock(SPCache *pCache) { tdbMutexInit(&(pCache->mutex), NULL); }
|
int tdbPCacheGetPageSize(SPCache *pCache) { return pCache->pageSize; }
|
||||||
|
|
||||||
static void tdbPCacheClearLock(SPCache *pCache) { tdbMutexDestroy(&(pCache->mutex)); }
|
|
||||||
|
|
||||||
static void tdbPCacheLock(SPCache *pCache) { tdbMutexLock(&(pCache->mutex)); }
|
|
||||||
|
|
||||||
static void tdbPCacheUnlock(SPCache *pCache) { tdbMutexUnlock(&(pCache->mutex)); }
|
|
||||||
|
|
||||||
static bool tdbPCacheLocked(SPCache *pCache) {
|
|
||||||
assert(0);
|
|
||||||
// TODO
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNewPage) {
|
static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNewPage) {
|
||||||
SPage *pPage;
|
SPage *pPage;
|
||||||
|
@ -268,4 +261,18 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbPCacheGetPageSize(SPCache *pCache) { return pCache->pageSize; }
|
static int tdbPCacheDestroyPage(SPage *pPage) {
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tdbPCacheCloseImpl(SPCache *pCache) {
|
||||||
|
SPage *pPage;
|
||||||
|
|
||||||
|
for (pPage = pCache->pList; pPage; pPage = pCache->pList) {
|
||||||
|
pCache->pList = pPage->pCacheNext;
|
||||||
|
tdbPCacheDestroyPage(pPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
tdbPCacheDestroyLock(pCache);
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
u8 isLocalPage; \
|
u8 isLocalPage; \
|
||||||
u8 isDirty; \
|
u8 isDirty; \
|
||||||
i32 nRef; \
|
i32 nRef; \
|
||||||
|
SPage *pCacheNext; \
|
||||||
SPage *pFreeNext; \
|
SPage *pFreeNext; \
|
||||||
SPage *pHashNext; \
|
SPage *pHashNext; \
|
||||||
SPage *pLruNext; \
|
SPage *pLruNext; \
|
||||||
|
|
|
@ -25,6 +25,7 @@ typedef struct STxn TXN;
|
||||||
struct STxn {
|
struct STxn {
|
||||||
u64 txnId;
|
u64 txnId;
|
||||||
void *(*xMalloc)(void *, int);
|
void *(*xMalloc)(void *, int);
|
||||||
|
void (*xFree)(void *, void *);
|
||||||
void *xArg;
|
void *xArg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue