LhxHashBlockAccessor Class Reference

#include <LhxHashTable.h>

Inheritance diagram for LhxHashBlockAccessor:

LhxHashNodeAccessor List of all members.

Public Member Functions

 LhxHashBlockAccessor ()
void init (uint usablePageSize)
 Set the size of the block.
void setCurrent (PBuffer blockPtrInit, bool valid, bool clearContent)
 Set the current node pointer for this accessor.
void reset ()
 Reset the node pointer to NULL.
uint getUsableSize ()
 
Returns:
the size of the block that a client can use.

uint getSlotsPerBlock ()
 
Returns:
the maximum number of slots per block.

PBuffer allocBuffer (uint bufSize)
 Allocate a buffer from this block.
void allocSlots (uint slotCount=1)
PBuffergetSlot (uint slotNum)
 Get the slot indexed by slotNum from this block.
PBuffer getCurrent ()
 
Returns:
current node associated with this accessor

void setCurrent (PBuffer nodePtrInit)
 Set the current node pointer for this accessor.
PBuffer getBuffer ()
 
Returns:
buffer to the payload in this node

PBuffer getNext ()
 
Returns:
the next node

PBuffer getNextLocation ()
 
Returns:
the location which stores the next node pointer

void setNext (PBuffer nextNode)
 Set the next node pointer for node associated with this accessor.
void setNext (PBuffer inputNode, PBuffer nextNode)
 Set the next node pointer for an input node.
uint getNextFieldSize ()
 
Returns:
number of bytes required to store the next node pointer

uint getBufferOffset ()
 
Returns:
offset to the .


Private Attributes

uint blockUsableSize
 Size of the buffer that a client can use.
uint numSlotsPerBlock
 Maximum number of slots per block.
PBuffer freePtr
 Free space in the current block.
PBuffer endPtr
 Free space in the current block.

Detailed Description

Definition at line 457 of file LhxHashTable.h.


Constructor & Destructor Documentation

LhxHashBlockAccessor::LhxHashBlockAccessor (  )  [inline]

Definition at line 481 of file LhxHashTable.h.

00481                            : LhxHashNodeAccessor()
00482     {
00483     }


Member Function Documentation

void LhxHashBlockAccessor::init ( uint  usablePageSize  ) 

Set the size of the block.

Parameters:
[in] usablePageSize 

Definition at line 195 of file LhxHashTable.cpp.

References blockUsableSize, LhxHashNodeAccessor::getBufferOffset(), and numSlotsPerBlock.

Referenced by LhxHashTable::init().

00196 {
00197     blockUsableSize = usablePageSize - getBufferOffset();
00198     numSlotsPerBlock = blockUsableSize / sizeof(PBuffer);
00199 }

void LhxHashBlockAccessor::setCurrent ( PBuffer  blockPtrInit,
bool  valid,
bool  clearContent 
)

Set the current node pointer for this accessor.

Parameters:
[in] blockPtrInit pointer to node that will be associated with this accessor
[in] valid whether buffer content is valid.
[in] clearContent whether to clear invalid content

Definition at line 201 of file LhxHashTable.cpp.

References blockUsableSize, endPtr, freePtr, LhxHashNodeAccessor::getBuffer(), and LhxHashNodeAccessor::setCurrent().

Referenced by LhxHashTable::allocateResources(), LhxHashTable::allocBlock(), LhxHashTable::allocBuffer(), and LhxHashTable::getSlot().

00205 {
00206     LhxHashNodeAccessor::setCurrent(blockPtrInit);
00207     freePtr = getBuffer();
00208     assert(freePtr);
00209     endPtr = freePtr + blockUsableSize;
00210 
00211     if (valid) {
00212         freePtr = endPtr;
00213     } else if (clearContent) {
00214         /*
00215          * Clear the memory if it is not valid.
00216          * The next link is not reset however since this block can be part of a
00217          * reusable block list.
00218          */
00219         memset(freePtr, 0, blockUsableSize);
00220     }
00221 
00222 }

void LhxHashBlockAccessor::reset (  )  [inline]

Reset the node pointer to NULL.

Reimplemented from LhxHashNodeAccessor.

Definition at line 1262 of file LhxHashTable.h.

References endPtr, freePtr, and LhxHashNodeAccessor::reset().

Referenced by LhxHashTable::releaseResources().

01263 {
01264     LhxHashNodeAccessor::reset();
01265     freePtr = endPtr = NULL;
01266 }

uint LhxHashBlockAccessor::getUsableSize (  )  [inline]

Returns:
the size of the block that a client can use.

Definition at line 510 of file LhxHashTable.h.

Referenced by LhxHashTable::init().

00511     {
00512         return blockUsableSize;
00513     }

uint LhxHashBlockAccessor::getSlotsPerBlock (  )  [inline]

Returns:
the maximum number of slots per block.

Definition at line 518 of file LhxHashTable.h.

Referenced by LhxHashTable::allocateResources(), and LhxHashTable::getSlot().

00519     {
00520         return numSlotsPerBlock;
00521     }

PBuffer LhxHashBlockAccessor::allocBuffer ( uint  bufSize  ) 

Allocate a buffer from this block.

Parameters:
[in] bufSize 
Returns:
null if no more space left in this block.

Definition at line 224 of file LhxHashTable.cpp.

References endPtr, and freePtr.

Referenced by LhxHashTable::allocBuffer(), and allocSlots().

00225 {
00226     PBuffer resultPtr = freePtr;
00227 
00228     if (freePtr + bufSize > endPtr) {
00229         resultPtr = NULL;
00230     } else {
00231         freePtr += bufSize;
00232     }
00233     return resultPtr;
00234 }

void LhxHashBlockAccessor::allocSlots ( uint  slotCount = 1  )  [inline]

Definition at line 1268 of file LhxHashTable.h.

References allocBuffer().

Referenced by LhxHashTable::allocateResources().

01269 {
01270     /*
01271      * A slot is a pointer to a hash key.
01272      */
01273     PBuffer bufPtr = allocBuffer(slotCount * sizeof(PBuffer));
01274     assert (bufPtr != NULL);
01275 }

PBuffer * LhxHashBlockAccessor::getSlot ( uint  slotNum  ) 

Get the slot indexed by slotNum from this block.

Parameters:
[in] slotNum 
Returns:
pointer to the slot. NULL if this slot does not exist on the current block.

Definition at line 236 of file LhxHashTable.cpp.

References LhxHashNodeAccessor::getBuffer(), LhxHashNodeAccessor::getCurrent(), and numSlotsPerBlock.

Referenced by LhxHashTable::getSlot().

00237 {
00238     assert (getCurrent() != NULL);
00239     if (slotNum >= numSlotsPerBlock) {
00240         /*
00241          * slotNum starts from 0.
00242          */
00243         return NULL;
00244     } else {
00245         return (PBuffer *)(getBuffer() + slotNum * sizeof(PBuffer));
00246     }
00247 }

PBuffer LhxHashNodeAccessor::getCurrent (  )  [inline, inherited]

Returns:
current node associated with this accessor

Definition at line 1051 of file LhxHashTable.h.

References LhxHashNodeAccessor::nodePtr.

Referenced by LhxHashKeyAccessor::getFirstData(), LhxHashKeyAccessor::getNextSlot(), getSlot(), LhxHashKeyAccessor::isMatched(), LhxHashKeyAccessor::setFirstData(), LhxHashKeyAccessor::setMatched(), and LhxHashKeyAccessor::setNextSlot().

01052 {
01053     return nodePtr;
01054 }

void LhxHashNodeAccessor::setCurrent ( PBuffer  nodePtrInit  )  [inline, inherited]

Set the current node pointer for this accessor.

Parameters:
[in] nodePtrInit pointer to node that will be associated with this accessor

Definition at line 1061 of file LhxHashTable.h.

References LhxHashNodeAccessor::nodePtr.

Referenced by LhxHashNodeAccessor::reset(), LhxHashKeyAccessor::setCurrent(), LhxHashDataAccessor::setCurrent(), and setCurrent().

01062 {
01063     nodePtr = nodePtrInit;
01064 }

PBuffer LhxHashNodeAccessor::getBuffer (  )  [inline, inherited]

Returns:
buffer to the payload in this node

Definition at line 1056 of file LhxHashTable.h.

References LhxHashNodeAccessor::nodeBufferOffset, and LhxHashNodeAccessor::nodePtr.

Referenced by getSlot(), LhxHashDataAccessor::pack(), LhxHashKeyAccessor::pack(), LhxHashKeyAccessor::setCurrent(), LhxHashDataAccessor::setCurrent(), setCurrent(), LhxHashKeyAccessor::unpack(), and LhxHashDataAccessor::unpack().

01057 {
01058     return (nodePtr + nodeBufferOffset);
01059 }

PBuffer LhxHashNodeAccessor::getNext (  )  [inline, inherited]

Returns:
the next node

Definition at line 1071 of file LhxHashTable.h.

References LhxHashNodeAccessor::nextNodeOffset, and LhxHashNodeAccessor::nodePtr.

Referenced by LhxHashTableReader::advanceData(), LhxHashTableReader::advanceKey(), LhxHashTableReader::advanceSlot(), LhxHashTable::aggData(), LhxHashTable::allocateResources(), LhxHashTable::allocBuffer(), LhxHashTable::findKeyLocation(), and LhxHashTable::printSlot().

01072 {
01073     // REVIEW jvs 25-Aug-2006:  Under what circumstances would
01074     // alignment be off?  Tuple sizes are always aligned.  Is it
01075     // because of the match indicator?  If so, it might make sense to
01076     // fold that into the tuple.
01077     /*
01078      * nodePtr+nextNodeOffset might not be aligned so copy the pointer
01079      * value out.
01080      */
01081     PBuffer returnPtr;
01082     memcpy((PBuffer)&returnPtr, nodePtr+nextNodeOffset, sizeof(PBuffer));
01083     return returnPtr;
01084 }

PBuffer LhxHashNodeAccessor::getNextLocation (  )  [inline, inherited]

Returns:
the location which stores the next node pointer

Definition at line 1086 of file LhxHashTable.h.

References LhxHashNodeAccessor::nextNodeOffset, and LhxHashNodeAccessor::nodePtr.

Referenced by LhxHashTable::findKeyLocation().

01087 {
01088     return nodePtr + nextNodeOffset;
01089 }

void LhxHashNodeAccessor::setNext ( PBuffer  nextNode  )  [inline, inherited]

Set the next node pointer for node associated with this accessor.

Parameters:
[in] nextNode pointer to the next node

Definition at line 1091 of file LhxHashTable.h.

References LhxHashNodeAccessor::getNextFieldSize(), LhxHashNodeAccessor::nextNodeOffset, and LhxHashNodeAccessor::nodePtr.

Referenced by LhxHashKeyAccessor::addData(), LhxHashTable::addKeyData(), LhxHashTable::aggData(), LhxHashTable::allocateResources(), LhxHashTable::allocBlock(), and LhxHashTable::allocBuffer().

01092 {
01093     memcpy(nodePtr+nextNodeOffset, (PBuffer)&nextNode, getNextFieldSize());
01094 }

void LhxHashNodeAccessor::setNext ( PBuffer  inputNode,
PBuffer  nextNode 
) [inline, inherited]

Set the next node pointer for an input node.

Parameters:
[in] inputNode input node to set the next node pointer
[in] nextNode pointer to the next node

Definition at line 1096 of file LhxHashTable.h.

References LhxHashNodeAccessor::getNextFieldSize(), and LhxHashNodeAccessor::nextNodeOffset.

01097 {
01098     memcpy(inputNode+nextNodeOffset, (PBuffer)&nextNode, getNextFieldSize());
01099 }

uint LhxHashNodeAccessor::getNextFieldSize (  )  [inline, inherited]

Returns:
number of bytes required to store the next node pointer

Definition at line 1101 of file LhxHashTable.h.

Referenced by LhxHashNodeAccessor::LhxHashNodeAccessor(), and LhxHashNodeAccessor::setNext().

01102 {
01103     return sizeof(PBuffer);
01104 }

uint LhxHashNodeAccessor::getBufferOffset (  )  [inline, inherited]

Returns:
offset to the .

This is equivalent to the total space used for the variable length payload.

Definition at line 1106 of file LhxHashTable.h.

References LhxHashNodeAccessor::nodeBufferOffset.

Referenced by LhxHashKeyAccessor::getAvgStorageSize(), LhxHashDataAccessor::getAvgStorageSize(), LhxHashKeyAccessor::getStorageSize(), LhxHashDataAccessor::getStorageSize(), and init().

01107 {
01108     return nodeBufferOffset;
01109 }


Member Data Documentation

uint LhxHashBlockAccessor::blockUsableSize [private]

Size of the buffer that a client can use.

Definition at line 463 of file LhxHashTable.h.

Referenced by init(), and setCurrent().

uint LhxHashBlockAccessor::numSlotsPerBlock [private]

Maximum number of slots per block.

Definition at line 468 of file LhxHashTable.h.

Referenced by getSlot(), and init().

PBuffer LhxHashBlockAccessor::freePtr [private]

Free space in the current block.

Definition at line 473 of file LhxHashTable.h.

Referenced by allocBuffer(), reset(), and setCurrent().

PBuffer LhxHashBlockAccessor::endPtr [private]

Free space in the current block.

Definition at line 478 of file LhxHashTable.h.

Referenced by allocBuffer(), reset(), and setCurrent().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:38 2009 for Fennel by  doxygen 1.5.1