Database Class Reference

#include <Database.h>

Collaboration diagram for Database:

Collaboration graph
[legend]

Public Member Functions

DbRetVal createSystemDatabaseChunk (AllocType type=FixedSizeAllocator, size_t size=0, int chunkID=-1)
DbRetVal deleteSystemDatabaseChunk (int id)
ChunkgetSystemDatabaseChunk (int id)
TransactiongetSystemDatabaseTrans (int slot)
ThreadInfogetThreadInfo (int slot)
bool isLastThread ()
void createAllCatalogTables ()
void createSystemTables ()
void createMetaDataTables ()
void * allocLockHashBuckets ()
BucketgetLockHashBuckets ()
void incrementChunk ()
void decrementChunk ()
const char * getName ()
int getDatabaseID ()
long getMaxSize ()
long getCurrentSize ()
PagegetCurrentPage ()
int getNoOfChunks ()
DatabaseMetaDatagetMetaDataPtr ()
PagegetFirstPage ()
ChunkgetHashIndexChunk ()
void setDatabaseID (int id)
void setName (const char *name)
void setCurrentSize (long size)
void setCurrentPage (Page *page)
void setMaxSize (long size)
void setNoOfChunks (int maxChunks)
void setMetaDataPtr (DatabaseMetaData *ptr)
void setFirstPage (Page *ptr)
void setHashIndexChunk (Chunk *chunk)
PagegetFreePage ()
PagegetFreePage (size_t size)
void printStatistics ()
int initAllocDatabaseMutex ()
DbRetVal getAllocDatabaseMutex (bool procAccount=true)
DbRetVal releaseAllocDatabaseMutex (bool procAccount=true)
int initTransTableMutex ()
DbRetVal getTransTableMutex ()
DbRetVal releaseTransTableMutex ()
int initDatabaseMutex ()
DbRetVal getDatabaseMutex (bool procAccount=true)
DbRetVal releaseDatabaseMutex (bool procAccount=true)
int initProcessTableMutex ()
DbRetVal getProcessTableMutex (bool procAccount=true)
DbRetVal releaseProcessTableMutex (bool procAccount=true)
void setProcSlot (int slot)
bool isValidAddress (void *ptr)

Data Fields

int procSlot

Friends

class DatabaseManagerImpl
class Table

Detailed Description

Definition at line 70 of file Database.h.


Member Function Documentation

void * Database::allocLockHashBuckets (  ) 

Definition at line 468 of file Database.cxx.

References Chunk::allocate(), ErrNoMemory, getSystemDatabaseChunk(), LockTableHashBucketId, and printError.

Referenced by SessionImpl::initSystemDatabase().

00469 {
00470     Chunk *chunk = getSystemDatabaseChunk(LockTableHashBucketId);
00471     void *ptr = chunk->allocate(this);
00472     if (NULL == ptr)
00473     {
00474         printError(ErrNoMemory, "Chunk Allocation failed for lock hash bucket catalog table");
00475     }
00476     return ptr;
00477 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Database::createAllCatalogTables (  ) 

Definition at line 369 of file Database.cxx.

References createMetaDataTables(), and createSystemTables().

Referenced by SessionImpl::initSystemDatabase().

00370 {
00371     //These are special chunks which hold catalog tables and other information
00372     //
00373     // chunk id 0 ->userChunkTable
00374     // chunk id 1 ->lockBucketHash
00375     // chunk id 2 ->lockTable
00376     //
00377     // chunk id 10->DATABASE
00378     // chunk id 11->USER
00379     // chunk id 12->TABLE
00380     // chunk id 13->FIELD
00381     // chunk id 14->ACCESS
00382 
00383     createSystemTables();
00384     createMetaDataTables();
00385 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Database::createMetaDataTables (  ) 

Definition at line 404 of file Database.cxx.

References AccessTableId, createSystemDatabaseChunk(), DatabaseTableId, FieldTableId, FixedSizeAllocator, IndexFieldTableId, IndexTableId, TableTableId, and UserTableId.

Referenced by createAllCatalogTables().

Here is the call graph for this function:

Here is the caller graph for this function:

DbRetVal Database::createSystemDatabaseChunk ( AllocType  type = FixedSizeAllocator,
size_t  size = 0,
int  chunkID = -1 
)

Definition at line 300 of file Database.cxx.

References Chunk::allocSize_, Chunk::curPage_, DM_Database, ErrNoMemory, ErrSysFatal, Chunk::firstPage_, FixedSizeAllocator, os::floor(), getFreePage(), getSystemDatabaseChunk(), incrementChunk(), VarSizeInfo::isUsed_, PageInfo::nextPageAfterMerge_, OK, PAGE_SIZE, printDebug, printError, Chunk::setAllocType(), Chunk::setChunkID(), PageInfo::setFirstPageAsUsed(), Chunk::setSize(), and VarSizeInfo::size_.

Referenced by createMetaDataTables(), and createSystemTables().

00301 {
00302 
00303     Chunk *chunk;
00304     if (-1 == id )
00305     {
00306         printError(ErrSysFatal, "Database ID corrupted");
00307         return ErrSysFatal;
00308     }
00309     chunk = getSystemDatabaseChunk(id);
00310 
00311     if (FixedSizeAllocator == type) chunk->setSize(size);
00312     //getDatabaseMutex();
00313     if (chunk->allocSize_ > PAGE_SIZE)
00314         chunk->curPage_ = getFreePage(chunk->allocSize_);
00315     else
00316          chunk->curPage_ = getFreePage();
00317     if ( chunk->curPage_ == NULL)
00318     {
00319        //releaseDatabaseMutex();
00320        printError(ErrNoMemory, "No free pages in database: Database full");
00321        return ErrNoMemory;
00322     }
00323 
00324     chunk->firstPage_ = chunk->curPage_;
00325     PageInfo* firstPageInfo = ((PageInfo*)chunk->firstPage_);
00326     firstPageInfo->setFirstPageAsUsed();
00327     chunk->setChunkID(id);
00328     chunk->setAllocType(type);
00329     printDebug(DM_Database, "Creating System Database Chunk:%d Size:%d",id, chunk->allocSize_);
00330     if (chunk->allocSize_ > PAGE_SIZE)
00331     {
00332         int multiple = os::floor(chunk->allocSize_ / PAGE_SIZE);
00333         int offset = ((multiple + 1) * PAGE_SIZE);
00334         firstPageInfo->nextPageAfterMerge_ = ((char*)firstPageInfo)+ offset;
00335     }
00336 
00337     if (0 == size)
00338     {
00339         VarSizeInfo *varInfo = (VarSizeInfo*)(((char*)firstPageInfo) + sizeof(PageInfo));
00340         varInfo->isUsed_ = 0;
00341         varInfo->size_ = PAGE_SIZE - sizeof(PageInfo) - sizeof(VarSizeInfo);
00342 
00343     }
00344     incrementChunk();
00345     //releaseDatabaseMutex();
00346     return OK;
00347 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Database::createSystemTables (  ) 

Definition at line 386 of file Database.cxx.

References createSystemDatabaseChunk(), FixedSizeAllocator, LOCK_BUCKET_SIZE, LockTableHashBucketId, LockTableId, LockTableMutexId, TransHasTableId, UndoLogTableID, UserChunkTableId, and VariableSizeAllocator.

Referenced by createAllCatalogTables().

Here is the call graph for this function:

Here is the caller graph for this function:

void Database::decrementChunk (  )  [inline]

Definition at line 101 of file Database.h.

References DatabaseMetaData::noOfChunks_.

Referenced by deleteSystemDatabaseChunk().

00101 { (metaData_->noOfChunks_)--;}

Here is the caller graph for this function:

DbRetVal Database::deleteSystemDatabaseChunk ( int  id  ) 

Definition at line 350 of file Database.cxx.

References Chunk::curPage_, decrementChunk(), Chunk::firstPage_, getSystemDatabaseChunk(), OK, Chunk::setAllocType(), Chunk::setChunkID(), Chunk::setSize(), and UnknownAllocator.

00351 {
00352 
00353     Chunk *chunk = getSystemDatabaseChunk(id);
00354     chunk->setChunkID(-1);
00355     chunk->setSize(0);
00356     chunk->setAllocType(UnknownAllocator);
00357     //TODO::
00358     //chunk->pageList_
00359     //walk though the pageList ptr and get all the page pointers
00360     //then free all the pages used to store this by setting the
00361     //start of page to notused
00362     chunk->firstPage_ = NULL;
00363     chunk->curPage_ = NULL;
00364     decrementChunk();
00365     return OK;
00366 }

Here is the call graph for this function:

DbRetVal Database::getAllocDatabaseMutex ( bool  procAccount = true  ) 

Definition at line 102 of file Database.cxx.

References DatabaseMetaData::dbAllocMutex_, ErrLockTimeOut, Mutex::getLock(), and OK.

00103 {
00104     int ret= metaData_->dbAllocMutex_.getLock(procAccount);
00105     if (ret) return ErrLockTimeOut; else return OK;
00106 }

Here is the call graph for this function:

Page * Database::getCurrentPage (  ) 

Definition at line 45 of file Database.cxx.

References DatabaseMetaData::curPage_.

Referenced by getFreePage().

00046 {
00047     return metaData_->curPage_;
00048 
00049 }

Here is the caller graph for this function:

long Database::getCurrentSize (  ) 

Definition at line 40 of file Database.cxx.

References DatabaseMetaData::curSize_.

00041 {
00042     return metaData_->curSize_;
00043 
00044 }

int Database::getDatabaseID (  ) 

Definition at line 30 of file Database.cxx.

References DatabaseMetaData::dbID_.

00031 {
00032     return metaData_->dbID_;
00033 }

DbRetVal Database::getDatabaseMutex ( bool  procAccount = true  ) 

Definition at line 153 of file Database.cxx.

References DatabaseMetaData::dbMutex_, ErrLockTimeOut, Mutex::getLock(), OK, and procSlot.

Referenced by DatabaseManagerImpl::createTable(), DatabaseManagerImpl::dropTable(), DatabaseManagerImpl::getAllTableNames(), SessionImpl::initSystemDatabase(), and DatabaseManagerImpl::openTable().

00154 {
00155     int ret = metaData_->dbMutex_.getLock(procSlot, procAccount);
00156     if (ret) return ErrLockTimeOut; else return OK;
00157 }

Here is the call graph for this function:

Here is the caller graph for this function:

Page * Database::getFirstPage (  ) 

Definition at line 50 of file Database.cxx.

References DatabaseMetaData::firstPage_.

Referenced by getFreePage(), and printStatistics().

00051 {
00052     return metaData_->firstPage_;
00053 
00054 }

Here is the caller graph for this function:

Page * Database::getFreePage ( size_t  size  ) 

Definition at line 215 of file Database.cxx.

References DM_Alloc, ErrSysInternal, getFirstPage(), getMaxSize(), getMetaDataPtr(), PageInfo::isUsed_, PageInfo::nextPageAfterMerge_, PAGE_SIZE, printDebug, printError, and setCurrentPage().

00216 {
00217     Page* page = getFirstPage();
00218     PageInfo* pageInfo = ((PageInfo*)page);
00219     int multiple = size / PAGE_SIZE;
00220     int offset = ((multiple + 1) * PAGE_SIZE);
00221     printDebug(DM_Alloc, "Database::getFreePage firstPage:%x size:%ld",page, size);
00222     char* endAddr = ((char*)getMetaDataPtr())  + getMaxSize();
00223     int pageSize = PAGE_SIZE;
00224     while(true){
00225         while( 1 == pageInfo->isUsed_)
00226         {
00227             //If any pages are merged to store data larger than PAGE_SIZE
00228             //move to the next page after the merge and check whether it is used
00229             if ( pageInfo->nextPageAfterMerge_ == NULL) {
00230                 pageInfo = (PageInfo*)((char*)pageInfo + pageSize);
00231                 printDebug(DM_Alloc,"Normal Page:Moving to page:%x",pageInfo);
00232             }
00233             else {
00234                 pageInfo = (PageInfo*)pageInfo->nextPageAfterMerge_;
00235                 printDebug(DM_Alloc,"Merged Page:Moving to page:%x",pageInfo);
00236             }
00237         }
00238         int i = 0;
00239         PageInfo *pInfo = pageInfo;
00240         if ((((char*)pInfo) + offset) >= endAddr)
00241         {
00242             printError(ErrSysInternal,"Invalid address %x",((char*)pInfo) + offset);
00243             return NULL;
00244         }
00245         for (i = 0; i< multiple + 1; i++)
00246         {
00247             if (1 == pInfo->isUsed_) break;
00248             pInfo = (PageInfo*)((char*)pInfo + pageSize);
00249         }
00250         if ( i == (multiple + 1))  break;
00251     }
00252 
00253     printDebug(DM_Alloc,"Database::getFreePage returning page:%x",pageInfo);
00254     setCurrentPage((Page*) pageInfo);
00255     return (Page*) pageInfo ;
00256 }

Here is the call graph for this function:

Page * Database::getFreePage (  ) 

Definition at line 175 of file Database.cxx.

References DM_Alloc, ErrSysInternal, getCurrentPage(), getMaxSize(), getMetaDataPtr(), PageInfo::isUsed_, isValidAddress(), PageInfo::nextPageAfterMerge_, PAGE_SIZE, printDebug, printError, and setCurrentPage().

Referenced by createSystemDatabaseChunk().

00176 {
00177     //Page* page = getFirstPage();
00178     Page* page = getCurrentPage();
00179     //printDebug(DM_Alloc, "Database::getFreePage firstPage:%x",page);
00180     printDebug(DM_Alloc, "Database::getFreePage currentpage:%x",page);
00181     PageInfo* pageInfo = ((PageInfo*)page);
00182     char* endAddr = ((char*)getMetaDataPtr())  + getMaxSize();
00183     int pageSize = PAGE_SIZE;
00184     while( 1 == pageInfo->isUsed_)
00185     {
00186         //If any pages are merged to store data larger than PAGE_SIZE
00187         //move to the next page after the merge and check whether it is used
00188         if ( pageInfo->nextPageAfterMerge_ == NULL) {
00189             pageInfo = (PageInfo*)((char*)pageInfo + pageSize);
00190             printDebug(DM_Alloc,"Normal Page:Moving to page:%x",pageInfo);
00191         }
00192         else {
00193             pageInfo = (PageInfo*)pageInfo->nextPageAfterMerge_;
00194             printDebug(DM_Alloc,"Merged Page:Moving to page:%x",pageInfo);
00195         }
00196         if ((char*)pageInfo >= endAddr)
00197         {
00198             //printError(ErrSysInternal,"Invalid address %x",pageInfo);
00199             return NULL;
00200         }
00201 
00202     }
00203     if (!isValidAddress(((char*) pageInfo) + pageSize))
00204     {
00205         printError(ErrSysInternal, "Invalid address %x",((char*) pageInfo) + pageSize);
00206         return NULL;
00207     }
00208     setCurrentPage((Page*) pageInfo);
00209     printDebug(DM_Alloc,"Database::getFreePage returning page:%x",pageInfo);
00210     return (Page*) pageInfo ;
00211 }

Here is the call graph for this function:

Here is the caller graph for this function:

Chunk * Database::getHashIndexChunk (  ) 

Definition at line 59 of file Database.cxx.

References DatabaseMetaData::hashIndexChunk_.

00060 {
00061     return metaData_->hashIndexChunk_;
00062 }

Bucket * Database::getLockHashBuckets (  ) 

Definition at line 479 of file Database.cxx.

References Chunk::getIterator(), getSystemDatabaseChunk(), LockTableHashBucketId, and ChunkIterator::nextElement().

Referenced by LockManager::printDebugInfo(), and LockManager::printUsageStatistics().

00480 {
00481     Chunk *tChunk = getSystemDatabaseChunk(LockTableHashBucketId);
00482     ChunkIterator iter = tChunk->getIterator();
00483     return (Bucket*)iter.nextElement();
00484 }

Here is the call graph for this function:

Here is the caller graph for this function:

long Database::getMaxSize (  ) 

Definition at line 35 of file Database.cxx.

References DatabaseMetaData::maxSize_.

Referenced by getFreePage(), isValidAddress(), and printStatistics().

00036 {
00037     return metaData_->maxSize_;
00038 }

Here is the caller graph for this function:

DatabaseMetaData* Database::getMetaDataPtr (  )  [inline]

Definition at line 109 of file Database.h.

Referenced by DatabaseManagerImpl::closeDatabase(), getFreePage(), and isValidAddress().

00109 { return metaData_; }

Here is the caller graph for this function:

const char * Database::getName (  ) 

Definition at line 25 of file Database.cxx.

References DatabaseMetaData::dbName_.

Referenced by DatabaseManagerImpl::closeDatabase(), and printStatistics().

00026 {
00027     return metaData_->dbName_;
00028 }

Here is the caller graph for this function:

int Database::getNoOfChunks (  ) 

Definition at line 55 of file Database.cxx.

References DatabaseMetaData::noOfChunks_.

Referenced by printStatistics().

00056 {
00057     return metaData_->noOfChunks_;
00058 }

Here is the caller graph for this function:

DbRetVal Database::getProcessTableMutex ( bool  procAccount = true  ) 

Definition at line 136 of file Database.cxx.

References DatabaseMetaData::dbProcTableMutex_, ErrLockTimeOut, Mutex::getLock(), and OK.

Referenced by cleanupDeadProcs(), ProcessManager::deregisterThread(), logActiveProcs(), and ProcessManager::registerThread().

00137 {
00138     int ret = metaData_->dbProcTableMutex_.getLock(-1, procAccount);
00139     if (ret) return ErrLockTimeOut; else return OK;
00140 }

Here is the call graph for this function:

Here is the caller graph for this function:

Chunk * Database::getSystemDatabaseChunk ( int  id  ) 

Definition at line 423 of file Database.cxx.

References os::alignLong().

Referenced by allocLockHashBuckets(), Transaction::applyUndoLogs(), CatalogTableUSER::authenticate(), CatalogTableUSER::changePass(), createSystemDatabaseChunk(), Transaction::createUndoLog(), deleteSystemDatabaseChunk(), DatabaseManagerImpl::dropTable(), CatalogTableINDEX::get(), CatalogTableTABLE::getChunkAndTblPtr(), CatalogTableFIELD::getFieldInfo(), CatalogTableINDEXFIELD::getFieldNameAndType(), CatalogTableFIELD::getFieldPtrs(), CatalogTableINDEX::getIndexName(), CatalogTableINDEX::getIndexPtrs(), getLockHashBuckets(), CatalogTableINDEX::getNumIndexes(), CatalogTableTABLE::getTableList(), CatalogTableUSER::insert(), CatalogTableINDEXFIELD::insert(), CatalogTableINDEX::insert(), CatalogTableFIELD::insert(), CatalogTableTABLE::insert(), Transaction::insertIntoHasList(), TransactionManager::printDebugInfo(), Transaction::printDebugInfo(), LockManager::printDebugInfo(), Transaction::releaseAllLocks(), CatalogTableUSER::remove(), CatalogTableINDEXFIELD::remove(), CatalogTableINDEX::remove(), CatalogTableFIELD::remove(), CatalogTableTABLE::remove(), Transaction::removeFromHasList(), and Transaction::removeUndoLogs().

00424 {
00425     size_t offset = os::alignLong(sizeof (DatabaseMetaData)) +
00426                         id * sizeof (Chunk);
00427     return (Chunk*)(((char*) metaData_) +  offset);
00428 }

Here is the call graph for this function:

Here is the caller graph for this function:

Transaction * Database::getSystemDatabaseTrans ( int  slot  ) 

Definition at line 432 of file Database.cxx.

References os::alignLong(), and MAX_CHUNKS.

00433 {
00434     size_t offset = os::alignLong(sizeof (DatabaseMetaData)) +
00435                     os::alignLong(MAX_CHUNKS * sizeof (Chunk)) +
00436                         slot  * sizeof (Transaction);
00437     return (Transaction*)(((char*) metaData_) +  offset);
00438 }

Here is the call graph for this function:

ThreadInfo * Database::getThreadInfo ( int  slot  ) 

Definition at line 441 of file Database.cxx.

References os::alignLong(), Conf::config, and MAX_CHUNKS.

Referenced by ProcessManager::addMutex(), cleanupDeadProcs(), ProcessManager::deregisterThread(), ProcessManager::getThreadTransaction(), ProcessManager::getThreadTransAddr(), ProcessManager::isAnyOneRegistered(), logActiveProcs(), ProcessManager::printDebugInfo(), ProcessManager::printUsageStatistics(), ProcessManager::registerThread(), ProcessManager::removeMutex(), and ProcessManager::setThreadTransaction().

00442 {
00443 /*     size_t offset = os::alignLong(sizeof (DatabaseMetaData));
00444      offset = offset + os::alignLong( MAX_CHUNKS  * sizeof (Chunk));
00445      offset = offset + os::alignLong( Conf::config.getMaxProcs()   * sizeof(Transaction));
00446      offset = offset + slot * sizeof (ThreadInfo);
00447      return (ThreadInfo*)(((char*) metaData_) +  offset);
00448 */
00449 
00450     static size_t offset = os::alignLong(sizeof (DatabaseMetaData)) +
00451                            os::alignLong( MAX_CHUNKS  * sizeof (Chunk)) +
00452                os::alignLong( Conf::config.getMaxProcs()*sizeof(Transaction));
00453         
00454     size_t off = offset + slot * sizeof (ThreadInfo);
00455     return (ThreadInfo*)(((char*) metaData_) +  off);
00456 
00457 }

Here is the call graph for this function:

Here is the caller graph for this function:

DbRetVal Database::getTransTableMutex (  ) 

Definition at line 119 of file Database.cxx.

References DatabaseMetaData::dbTransTableMutex_, ErrLockTimeOut, Mutex::getLock(), OK, and procSlot.

Referenced by TransactionManager::commit(), TransactionManager::rollback(), and TransactionManager::startTransaction().

00120 {
00121     int ret = metaData_->dbTransTableMutex_.getLock(procSlot);
00122     if (ret) return ErrLockTimeOut; else return OK;
00123 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Database::incrementChunk (  )  [inline]

Definition at line 100 of file Database.h.

References DatabaseMetaData::noOfChunks_.

Referenced by createSystemDatabaseChunk().

00100 { (metaData_->noOfChunks_)++;}

Here is the caller graph for this function:

int Database::initAllocDatabaseMutex (  ) 

Definition at line 98 of file Database.cxx.

References DatabaseMetaData::dbAllocMutex_, and Mutex::init().

Referenced by DatabaseManagerImpl::createDatabase().

00099 {
00100     return metaData_->dbAllocMutex_.init("allocdb");
00101 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Database::initDatabaseMutex (  ) 

Definition at line 149 of file Database.cxx.

References DatabaseMetaData::dbMutex_, and Mutex::init().

Referenced by DatabaseManagerImpl::createDatabase().

00150 {
00151     return metaData_->dbMutex_.init("db");
00152 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Database::initProcessTableMutex (  ) 

Definition at line 132 of file Database.cxx.

References DatabaseMetaData::dbProcTableMutex_, and Mutex::init().

Referenced by DatabaseManagerImpl::createDatabase().

00133 {
00134     return metaData_->dbProcTableMutex_.init("proctable");
00135 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Database::initTransTableMutex (  ) 

Definition at line 115 of file Database.cxx.

References DatabaseMetaData::dbTransTableMutex_, and Mutex::init().

Referenced by DatabaseManagerImpl::createDatabase().

00116 {
00117     return metaData_->dbTransTableMutex_.init("transtable");
00118 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Database::isLastThread (  ) 

bool Database::isValidAddress ( void *  ptr  ) 

Definition at line 459 of file Database.cxx.

References getMaxSize(), and getMetaDataPtr().

Referenced by getFreePage(), and printStatistics().

00460 {
00461     if ((char*) addr >= ((char*)getMetaDataPtr())  + getMaxSize())
00462         return false;
00463     else
00464         return true;
00465 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Database::printStatistics (  ) 

Definition at line 258 of file Database.cxx.

References DM_Alloc, getFirstPage(), getMaxSize(), getName(), getNoOfChunks(), isValidAddress(), PAGE_SIZE, and printDebug.

Referenced by main().

00259 {
00260     Page* page = getFirstPage();
00261     PageInfo* pageInfo = ((PageInfo*)page);
00262     int usedPageCount =0, usedMergedPageCount =0, totalPages=0;
00263     printf("<DatabaseStatistics>\n");
00264     printf("  <Database Name>  %s </Database Name>\n", getName());
00265     printf("  <Max Size> %ld </Max Size>\n", getMaxSize());
00266     printf("  <First Page> %x </First Page>\n", getFirstPage());
00267     while(isValidAddress((char*) pageInfo))
00268     {
00269         if (pageInfo == NULL) break;
00270         if (1 == pageInfo->isUsed_) {
00271            if ( pageInfo->nextPageAfterMerge_ == NULL) {
00272               pageInfo = (PageInfo*)((char*)pageInfo + PAGE_SIZE);
00273               usedPageCount++; totalPages++;
00274               printDebug(DM_Alloc, "Normal Page:Moving to page:%x\n",pageInfo);
00275               continue;
00276            }
00277            else {
00278               pageInfo = (PageInfo*)pageInfo->nextPageAfterMerge_;
00279               usedMergedPageCount++; totalPages++;
00280               printDebug(DM_Alloc,"Merged Page:Moving to page:%x\n",pageInfo);
00281               continue;
00282            }
00283         }
00284         pageInfo = (PageInfo*)((char*)pageInfo + PAGE_SIZE);
00285         printDebug(DM_Alloc,"Normal Page not used:Moving to page:%x\n",pageInfo);
00286         totalPages++;
00287     }
00288     printf("  <Total Pages> %d </Total Pages>\n", totalPages);
00289     printf("  <Used Normal Pages> %d </Used Normal Pages>\n", usedPageCount);
00290     printf("  <Used Merged Pages> %d </Used Merged Pages>\n", usedMergedPageCount);
00291     printf("  <Chunks Used> %d </Chunks Used>\n", getNoOfChunks());
00292     printf("</DatabaseStatistics>\n");
00293 
00294     return ;
00295 }

Here is the call graph for this function:

Here is the caller graph for this function:

DbRetVal Database::releaseAllocDatabaseMutex ( bool  procAccount = true  ) 

Definition at line 107 of file Database.cxx.

References DatabaseMetaData::dbAllocMutex_, OK, and Mutex::releaseLock().

00108 {
00109     metaData_->dbAllocMutex_.releaseLock(procAccount);
00110     return OK;
00111 }

Here is the call graph for this function:

DbRetVal Database::releaseDatabaseMutex ( bool  procAccount = true  ) 

Definition at line 158 of file Database.cxx.

References DatabaseMetaData::dbMutex_, OK, procSlot, and Mutex::releaseLock().

Referenced by DatabaseManagerImpl::createTable(), DatabaseManagerImpl::dropTable(), DatabaseManagerImpl::getAllTableNames(), SessionImpl::initSystemDatabase(), and DatabaseManagerImpl::openTable().

00159 {
00160     metaData_->dbMutex_.releaseLock(procSlot, procAccount);
00161     return OK;
00162 }

Here is the call graph for this function:

Here is the caller graph for this function:

DbRetVal Database::releaseProcessTableMutex ( bool  procAccount = true  ) 

Definition at line 141 of file Database.cxx.

References DatabaseMetaData::dbProcTableMutex_, OK, and Mutex::releaseLock().

Referenced by cleanupDeadProcs(), logActiveProcs(), and ProcessManager::registerThread().

00142 {
00143     metaData_->dbProcTableMutex_.releaseLock(-1, procAccount);
00144     return OK;
00145 }

Here is the call graph for this function:

Here is the caller graph for this function:

DbRetVal Database::releaseTransTableMutex (  ) 

Definition at line 124 of file Database.cxx.

References DatabaseMetaData::dbTransTableMutex_, OK, procSlot, and Mutex::releaseLock().

Referenced by TransactionManager::commit(), TransactionManager::rollback(), and TransactionManager::startTransaction().

00125 {
00126     metaData_->dbTransTableMutex_.releaseLock(procSlot);
00127     return OK;
00128 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Database::setCurrentPage ( Page page  ) 

Definition at line 76 of file Database.cxx.

References DatabaseMetaData::curPage_.

Referenced by DatabaseManagerImpl::createDatabase(), and getFreePage().

00077 {
00078     metaData_->curPage_ = page;
00079 }

Here is the caller graph for this function:

void Database::setCurrentSize ( long  size  ) 

Definition at line 72 of file Database.cxx.

References DatabaseMetaData::curSize_.

00073 {
00074     metaData_->curSize_ = size;
00075 }

void Database::setDatabaseID ( int  id  ) 

Definition at line 64 of file Database.cxx.

References DatabaseMetaData::dbID_.

Referenced by DatabaseManagerImpl::createDatabase().

00065 {
00066     metaData_->dbID_ = id;
00067 }

Here is the caller graph for this function:

void Database::setFirstPage ( Page ptr  ) 

Definition at line 80 of file Database.cxx.

References DatabaseMetaData::firstPage_.

Referenced by DatabaseManagerImpl::createDatabase().

00081 {
00082     metaData_->firstPage_ = page;
00083 }

Here is the caller graph for this function:

void Database::setHashIndexChunk ( Chunk chunk  ) 

Definition at line 92 of file Database.cxx.

References DatabaseMetaData::hashIndexChunk_.

00093 {
00094     metaData_->hashIndexChunk_ = ch;
00095 }

void Database::setMaxSize ( long  size  ) 

Definition at line 84 of file Database.cxx.

References DatabaseMetaData::maxSize_.

Referenced by DatabaseManagerImpl::createDatabase().

00085 {
00086     metaData_->maxSize_ = size;
00087 }

Here is the caller graph for this function:

void Database::setMetaDataPtr ( DatabaseMetaData ptr  )  [inline]

Definition at line 119 of file Database.h.

Referenced by DatabaseManagerImpl::createDatabase(), and DatabaseManagerImpl::openDatabase().

00119 {metaData_ = ptr; }

Here is the caller graph for this function:

void Database::setName ( const char *  name  ) 

Definition at line 68 of file Database.cxx.

References DatabaseMetaData::dbName_.

Referenced by DatabaseManagerImpl::createDatabase().

00069 {
00070     strcpy(metaData_->dbName_ , name);
00071 }

Here is the caller graph for this function:

void Database::setNoOfChunks ( int  maxChunks  ) 

Definition at line 88 of file Database.cxx.

References DatabaseMetaData::noOfChunks_.

Referenced by DatabaseManagerImpl::createDatabase().

00089 {
00090     metaData_->noOfChunks_ = chunks;
00091 }

Here is the caller graph for this function:

void Database::setProcSlot ( int  slot  )  [inline]

Definition at line 149 of file Database.h.

References procSlot.

Referenced by DatabaseManagerImpl::setProcSlot().

00149 { procSlot =slot;}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class DatabaseManagerImpl [friend]

Definition at line 152 of file Database.h.

friend class Table [friend]

Definition at line 153 of file Database.h.


Field Documentation

int Database::procSlot

Definition at line 148 of file Database.h.

Referenced by Chunk::allocate(), TransactionManager::commit(), TableImpl::execute(), Chunk::free(), getDatabaseMutex(), LockManager::getExclusiveLock(), LockManager::getSharedLock(), getTransTableMutex(), HashIndex::insert(), LockManager::isExclusiveLocked(), DatabaseManagerImpl::openTable(), releaseDatabaseMutex(), LockManager::releaseLock(), releaseTransTableMutex(), HashIndex::remove(), TransactionManager::rollback(), setProcSlot(), TransactionManager::startTransaction(), and HashIndex::update().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:46:31 2008 for csql by  doxygen 1.4.7