From 8e2670e22f0a84e34cac73af358bbfa00edf8afb Mon Sep 17 00:00:00 2001 From: prabatuty Date: Tue, 31 May 2011 15:51:34 +0000 Subject: [PATCH] core reorg --- include/Allocator.h | 20 +++++++++++++------- src/storage/Chunk.cxx | 21 +-------------------- src/storage/VarChunk.cxx | 6 +++++- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/include/Allocator.h b/include/Allocator.h index 0cd08231..bf95519b 100644 --- a/include/Allocator.h +++ b/include/Allocator.h @@ -186,9 +186,11 @@ class Chunk void printMutexInfo() { chunkMutex_.print(); } long getTotalDataNodes(); + long getVarTotalDataNodes(); int totalPages(); int totalDirtyPages(); int compact(int procSlot); + void varCompact(); private: @@ -196,20 +198,24 @@ class Chunk int getChunkMutex(int procSlot); int releaseChunkMutex(int procSlot); int destroyMutex(); - int createDataBucket(Page *page, size_t totalSize, size_t needSize, int pslot); - int splitDataBucket(VarSizeInfo *varInfo, size_t needSize, int pslot, DbRetVal *status); - void* varSizeFirstFitAllocate(size_t size, int pslot, DbRetVal *status); - void freeForLargeAllocator(void *ptr, int pslot); - void freeForVarSizeAllocator(Database *db, void *ptr, int pslot); - void* allocateForLargeDataSize(Database *db); void* allocateFromFirstPage(Database *db, int noOfDataNodes, DbRetVal *status); void* allocateFromNewPage(Database *db, DbRetVal *status); - void* allocateForLargeDataSize(Database *db, size_t size); + + int createDataBucket(Page *page, size_t totalSize, size_t needSize, int pslot); + int splitDataBucket(VarSizeInfo *varInfo, size_t needSize, int pslot, DbRetVal *status); + void* varSizeFirstFitAllocate(size_t size, int pslot, DbRetVal *status); + void freeForVarSizeAllocator(Database *db, void *ptr, int pslot); + void* allocateForVarLargeSize(PageInfo *pInfo, size_t size, int offset); void* allocFromNewPageForVarSize(Database *db, size_t size, int pslot, DbRetVal *status); void* allocateFromCurPageForVarSize(size_t size, int pslot, DbRetVal *status); + + void* allocateForLargeDataSize(Database *db); + void* allocateForLargeDataSize(Database *db, size_t size); + void freeForLargeAllocator(void *ptr, int pslot); + void setPageDirty(Database *db, void *ptr); void setPageDirty(PageInfo *pInfo); diff --git a/src/storage/Chunk.cxx b/src/storage/Chunk.cxx index b23f83ca..c5dbf13e 100644 --- a/src/storage/Chunk.cxx +++ b/src/storage/Chunk.cxx @@ -592,26 +592,7 @@ int Chunk::compact(int procSlot) pageInfo = (PageInfo*)pageInfo->nextPage_; if (0 == allocSize_) { - while( pageInfo != NULL ) - { - bool flag = false; - VarSizeInfo *varInfo = (VarSizeInfo*)(((char*)pageInfo) + - sizeof(PageInfo)); - while ((char*) varInfo < ((char*)pageInfo + PAGE_SIZE)) - { - if (1 == varInfo->isUsed_) {flag=true; break;} - varInfo = (VarSizeInfo*)((char*)varInfo + sizeof(VarSizeInfo) - +varInfo->size_); - } - if (!flag) { - printDebug(DM_VarAlloc,"Freeing unused page in varsize allocator %x\n", pageInfo); - prevPage->nextPage_ = pageInfo->nextPage_; - pageInfo->isUsed_ = 0; - } - prevPage = pageInfo; - pageInfo = (PageInfo*)(((PageInfo*)pageInfo)->nextPage_) ; - printDebug(DM_VarAlloc,"compact iter %x\n", pageInfo); - } + varCompact(); }else if (allocSize_ < PAGE_SIZE) { while( pageInfo != NULL ) diff --git a/src/storage/VarChunk.cxx b/src/storage/VarChunk.cxx index a5538149..9e3f4815 100644 --- a/src/storage/VarChunk.cxx +++ b/src/storage/VarChunk.cxx @@ -399,8 +399,12 @@ long Chunk::getVarTotalDataNodes() return totalNodes; } -void Chunk:varCompact() +void Chunk::varCompact() { + PageInfo* pageInfo = ((PageInfo*)firstPage_); + PageInfo* prevPage = pageInfo; + //first page is not null as it is already checked in Chunk::compact + pageInfo = (PageInfo*)pageInfo->nextPage_; while( pageInfo != NULL ) { bool flag = false; -- 2.11.4.GIT