ChunkIterator Class Reference

#include <Allocator.h>


Public Member Functions

void * nextElement ()

Friends

class Chunk


Detailed Description

Definition at line 69 of file Allocator.h.


Member Function Documentation

void * ChunkIterator::nextElement (  ) 

Definition at line 35 of file ChunkIterator.cxx.

References DM_Iterator, ErrNotExists, PageInfo::nextPage_, PAGE_SIZE, printDebug, and printError.

Referenced by CatalogTableUSER::authenticate(), CatalogTableUSER::changePass(), CatalogTableINDEX::get(), CatalogTableTABLE::getChunkAndTblPtr(), CatalogTableFIELD::getFieldInfo(), CatalogTableINDEXFIELD::getFieldNameAndType(), CatalogTableFIELD::getFieldPtrs(), CatalogTableINDEX::getIndexName(), CatalogTableINDEX::getIndexPtrs(), Database::getLockHashBuckets(), CatalogTableINDEX::getNumIndexes(), CatalogTableTABLE::getTableList(), HashIndex::insert(), CatalogTableINDEXFIELD::insert(), CatalogTableINDEX::insert(), TupleIterator::next(), DatabaseManagerImpl::openTable(), HashIndex::remove(), CatalogTableUSER::remove(), CatalogTableINDEXFIELD::remove(), CatalogTableINDEX::remove(), CatalogTableFIELD::remove(), CatalogTableTABLE::remove(), and HashIndex::update().

00036 {
00037     if(NULL == iterPage_)
00038     {
00039         printError(ErrNotExists,"No iter page exists.");
00040         return NULL;
00041     }
00042     //No iterators for variable size allocators
00043     if(0 == allocSize_)
00044     {
00045         printError(ErrNotExists,"Iterators are not for variable size allocators");
00046         return NULL;
00047     }
00048     PageInfo* pageInfo = (PageInfo*)iterPage_;
00049     if (0 == noOfNodes_)
00050     {
00051         //means tuple larger than PAGE_SIZE
00052         iterPage_ = pageInfo->nextPage_;
00053         return (char*)pageInfo + sizeof(PageInfo)+ sizeof(int);
00054     }
00055 
00056     char *data = ((char*)iterPage_) + sizeof(PageInfo) + (nodeOffset_ * allocSize_) ;
00057 
00058     //check whether there are any nodes in the current page
00059     int i = nodeOffset_;
00060     while(nodeOffset_ < noOfNodes_)
00061     {
00062         if (*((int*)data) == 0)
00063         {
00064           //not used, so skip it
00065            data = data + allocSize_;
00066            nodeOffset_++;
00067            if (data >= (char*)iterPage_ + PAGE_SIZE) break; 
00068         }
00069         else
00070         {
00071            //used, return element pointer
00072            nodeOffset_++;
00073            printDebug(DM_Iterator,"ChunkID:%d Returning %x nodeOffset:%d",
00074                                   chunkID_, data + sizeof(int), nodeOffset_);
00075            return data + sizeof(int);
00076         }
00077     }
00078     //go to next page and check till it exhausts
00079     while(pageInfo->nextPage_ != NULL)
00080     {
00081         iterPage_ = pageInfo->nextPage_;
00082         pageInfo = ((PageInfo*)iterPage_);
00083         data = (char*)iterPage_ + sizeof(PageInfo);
00084         nodeOffset_ = 0;
00085         while(nodeOffset_ < noOfNodes_)
00086         {
00087             if (*((int*)data) == 0)
00088             {
00089                //not used, so skip it
00090                data = data + allocSize_;
00091                nodeOffset_++;
00092             }
00093             else
00094             {
00095                 nodeOffset_++;
00096                 printDebug(DM_Iterator,"ChunkID:%d Returning %x Page:%x nodeOffset:%d",
00097                                  chunkID_, data + sizeof(int), pageInfo, nodeOffset_);
00098                 return data +sizeof(int);
00099             }
00100         }
00101     }
00102     return NULL;
00103 }

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class Chunk [friend]

Definition at line 89 of file Allocator.h.


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