BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor > Class Template Reference

BTreeKeyedNodeAccessor is a template for implementing some of the virtual methods in the BTreeNodeAccessor interface. More...

#include <BTreeKeyedNodeAccessor.h>

List of all members.

Public Member Functions

virtual void accessTupleInline (BTreeNode const &node, uint iEntry)
virtual void accessTuple (BTreeNode const &node, uint iEntry)
virtual void unmarshalKey (TupleData &keyData)
virtual uint binarySearch (BTreeNode const &node, TupleDescriptor const &keyDescriptor, TupleData const &searchKey, DuplicateSeek dupSeek, bool leastUpper, TupleData &scratchKey, bool &found)
virtual int compareFirstKey (BTreeNode const &node, TupleDescriptor const &keyDescriptor, TupleData const &searchKey, TupleData &scratchKey)
virtual PConstBuffer getEntryForRead (BTreeNode const &node, uint iEntry)

Public Attributes

KeyAccessor * pKeyAccessor


Detailed Description

template<class NodeAccessor, class KeyAccessor>
class BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >

BTreeKeyedNodeAccessor is a template for implementing some of the virtual methods in the BTreeNodeAccessor interface.

It requires the class used to instantiate NodeAccessor to implement a getEntryForReadInline method.

Definition at line 39 of file BTreeKeyedNodeAccessor.h.


Member Function Documentation

template<class NodeAccessor, class KeyAccessor>
virtual void BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::accessTupleInline ( BTreeNode const &  node,
uint  iEntry 
) [inline, virtual]

Definition at line 44 of file BTreeKeyedNodeAccessor.h.

References BTreeNode::nEntries.

Referenced by BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::accessTuple(), BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::binarySearch(), and BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::compareFirstKey().

00045     {
00046         assert(iEntry < node.nEntries);
00047         NodeAccessor::tupleAccessor.setCurrentTupleBuf(
00048             NodeAccessor::getEntryForReadInline(node,iEntry));
00049     }

template<class NodeAccessor, class KeyAccessor>
virtual void BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::accessTuple ( BTreeNode const &  node,
uint  iEntry 
) [inline, virtual]

Definition at line 51 of file BTreeKeyedNodeAccessor.h.

References BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::accessTupleInline().

00052     {
00053         return accessTupleInline(node,iEntry);
00054     }

template<class NodeAccessor, class KeyAccessor>
virtual void BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::unmarshalKey ( TupleData keyData  )  [inline, virtual]

Definition at line 56 of file BTreeKeyedNodeAccessor.h.

References BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::pKeyAccessor.

00057     {
00058         pKeyAccessor->unmarshal(keyData);
00059     }

template<class NodeAccessor, class KeyAccessor>
virtual uint BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::binarySearch ( BTreeNode const &  node,
TupleDescriptor const &  keyDescriptor,
TupleData const &  searchKey,
DuplicateSeek  dupSeek,
bool  leastUpper,
TupleData scratchKey,
bool &  found 
) [inline, virtual]

Definition at line 61 of file BTreeKeyedNodeAccessor.h.

References BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::accessTupleInline(), TupleDescriptor::compareTuples(), DUP_SEEK_ANY, DUP_SEEK_BEGIN, DUP_SEEK_END, BTreeNode::height, BTreeNode::nEntries, and BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::pKeyAccessor.

00069     {
00070         uint probe = 0;
00071         uint base = probe;
00072         found = false;
00073         int nKeys = NodeAccessor::getKeyCount(node);
00074         while (nKeys > 0) {
00075             uint split = nKeys >> 1;
00076             probe = base + split;
00077             accessTupleInline(node,probe);
00078             pKeyAccessor->unmarshal(scratchKey);
00079             int j = keyDescriptor.compareTuples(
00080                 searchKey,scratchKey);
00081             if (j == 0) {
00082                 found = true;
00083                 switch (dupSeek) {
00084                 case DUP_SEEK_ANY:
00085                     return probe;
00086                 case DUP_SEEK_BEGIN:
00087                     j = -1;
00088                     break;
00089                 case DUP_SEEK_END:
00090                     j = 1;
00091                     break;
00092                 default:
00093                     permAssert(false);
00094                 }
00095             }
00096             if (j < 0) {
00097                 nKeys = split;
00098             } else {
00099                 base = probe + 1;
00100                 nKeys -= (split + 1);
00101             }
00102         }
00103         if (!found && !leastUpper && (base > 0)) {
00104             base--;
00105         }
00106         if (((base != probe) && (base < node.nEntries)) ||
00107             ((node.nEntries == 1) && (node.height != 0)))
00108         {
00109             // one entry: +infinity
00110             accessTupleInline(node,base);
00111         }
00112         return base;
00113     }

template<class NodeAccessor, class KeyAccessor>
virtual int BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::compareFirstKey ( BTreeNode const &  node,
TupleDescriptor const &  keyDescriptor,
TupleData const &  searchKey,
TupleData scratchKey 
) [inline, virtual]

Definition at line 115 of file BTreeKeyedNodeAccessor.h.

References BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::accessTupleInline(), TupleDescriptor::compareTuples(), and BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::pKeyAccessor.

00120     {
00121         int nKeys = NodeAccessor::getKeyCount(node);
00122         if (nKeys == 0) {
00123             return -1;
00124         }
00125         accessTupleInline(node, 0);
00126         pKeyAccessor->unmarshal(scratchKey);
00127         int compareResult = keyDescriptor.compareTuples(searchKey, scratchKey);
00128         return compareResult;
00129     }

template<class NodeAccessor, class KeyAccessor>
virtual PConstBuffer BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::getEntryForRead ( BTreeNode const &  node,
uint  iEntry 
) [inline, virtual]

Definition at line 131 of file BTreeKeyedNodeAccessor.h.

00132     {
00133         return NodeAccessor::getEntryForReadInline(node,iEntry);
00134     }


Member Data Documentation

template<class NodeAccessor, class KeyAccessor>
KeyAccessor* BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::pKeyAccessor

Definition at line 42 of file BTreeKeyedNodeAccessor.h.

Referenced by BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::binarySearch(), BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::compareFirstKey(), and BTreeKeyedNodeAccessor< NodeAccessor, KeyAccessor >::unmarshalKey().


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