提交 c4e86a73 编写于 作者: H Hongze Cheng

more TDB

上级 0b62ccf5
......@@ -86,7 +86,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, S
pBt->pageSize = tdbPagerGetPageSize(pPager);
// pBt->maxLocal
pBt->maxLocal = (pBt->pageSize - sizeof(SPageHdr)) / pBt->fanout;
// pBt->minLocal
// pBt->minLocal: Should not be allowed smaller than 15, which is [nPayload][nKey][nData]
pBt->minLocal = (pBt->pageSize - sizeof(SPageHdr)) / pBt->fanout / 2;
// pBt->maxLeaf
pBt->maxLeaf = pBt->pageSize - sizeof(SPageHdr);
......
......@@ -85,11 +85,6 @@ SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage) {
return pPage;
}
void tdbPCacheFetchFinish(SPCache *pCache, SPage *pPage) {
/* TODO */
pPage->nRef++; // TODO: do we need atomic operation???
}
void tdbPCacheRelease(SPage *pPage) {
pPage->nRef--;
if (pPage->nRef == 0) {
......
......@@ -23,7 +23,6 @@ extern "C" {
int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache);
int tdbPCacheClose(SPCache *pCache);
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
void tdbPCacheFetchFinish(SPCache *pCache, SPage *pPage);
void tdbPCacheRelease(SPage *pPage);
int tdbPCacheGetPageSize(SPCache *pCache);
......
......@@ -54,12 +54,19 @@ struct SPage {
int minLocal;
};
#define TDB_INIT_PAGE_LOCK(pPage) pthread_spin_init(&((pPage)->lock), 0) // TODO: use the macros
// For page lock
#define TDB_INIT_PAGE_LOCK(pPage) pthread_spin_init(&((pPage)->lock), 0)
#define TDB_DESTROY_PAGE_LOCK(pPage) pthread_spin_destroy(&((pPage)->lock))
#define TDB_LOCK_PAGE(pPage) pthread_spin_lock(&((pPage)->lock))
#define TDB_TRY_LOCK_PAGE(pPage) pthread_spin_trylock(&((pPage)->lock))
#define TDB_UNLOCK_PAGE(pPage) pthread_spin_unlock(&((pPage)->lock))
// For page ref (TODO: Need atomic operation)
#define TDB_INIT_PAGE_REF(pPage) ((pPage)->nRef = 0)
#define TDB_REF_PAGE(pPage) (++(pPage)->nRef)
#define TDB_UNREF_PAGE(pPage) (--(pPage)->nRef)
#define TDB_PAGE_REF(pPage) ((pPage)->nRef)
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册