#include <TableImpl.h>
Collaboration diagram for TupleIterator:
Public Member Functions | |
TupleIterator (Predicate *p, ScanType t, IndexInfo *i, void *cptr, int pslot) | |
~TupleIterator () | |
DbRetVal | open () |
void * | next () |
DbRetVal | close () |
Definition at line 38 of file TableImpl.h.
TupleIterator::TupleIterator | ( | Predicate * | p, | |
ScanType | t, | |||
IndexInfo * | i, | |||
void * | cptr, | |||
int | pslot | |||
) | [inline] |
TupleIterator::~TupleIterator | ( | ) | [inline] |
DbRetVal TupleIterator::close | ( | ) |
Definition at line 123 of file TupleIterator.cxx.
References fullTableScan, hashIndexScan, OK, and unknownScan.
Referenced by TableImpl::close().
00124 { 00125 if (scanType_ == fullTableScan) 00126 { 00127 delete cIter; 00128 cIter = NULL; 00129 } else if (scanType_ == hashIndexScan) 00130 { 00131 delete bIter; 00132 bIter = NULL; 00133 } 00134 scanType_ = unknownScan; 00135 return OK; 00136 }
Here is the caller graph for this function:
void * TupleIterator::next | ( | ) |
Definition at line 61 of file TupleIterator.cxx.
References DM_HashIndex, DM_Table, PredicateImpl::evaluate(), fullTableScan, hashIndexScan, BucketIter::next(), ChunkIterator::nextElement(), OK, printDebug, HashIndexNode::ptrToTuple_, and PredicateImpl::setTuple().
Referenced by TableImpl::fetchNoBind().
00062 { 00063 PredicateImpl *predImpl = (PredicateImpl*) pred_; 00064 void *tuple = NULL; 00065 DbRetVal rv = OK; 00066 if (fullTableScan == scanType_) 00067 { 00068 00069 if (NULL == pred_ ) 00070 { 00071 //no predicates 00072 return cIter->nextElement(); 00073 } 00074 else 00075 { 00076 //evaluate till it succeeds 00077 bool result = false; 00078 while (!result) 00079 { 00080 tuple = cIter->nextElement(); 00081 if(NULL == tuple) return NULL; 00082 predImpl->setTuple(tuple); 00083 printDebug(DM_Table, "Evaluating the predicate from fullTableScan"); 00084 rv = predImpl->evaluate(result); 00085 if (rv != OK) return NULL; 00086 } 00087 } 00088 }else if (hashIndexScan == scanType_) 00089 { 00090 if (NULL == bIter) 00091 { 00092 //if there are no nodes in bucket bIter will be null 00093 return NULL; 00094 } 00095 //evaluate till it succeeds 00096 bool result = false; 00097 while (!result) 00098 { 00099 HashIndexNode *node = bIter->next(); 00100 if (node == NULL) return NULL; 00101 printDebug(DM_HashIndex, "next: returned HashIndexNode: %x", node); 00102 tuple = node->ptrToTuple_; 00103 if(NULL == tuple) { 00104 printDebug(DM_HashIndex, "next::tuple is null"); 00105 return NULL; 00106 } 00107 00108 //if (!predImpl->isSingleTerm()) { 00109 printDebug(DM_HashIndex, "next: predicate has more than single term"); 00110 predImpl->setTuple(tuple); 00111 printDebug(DM_Table, "Evaluating the predicate from hashIndexScan: has more than one term"); 00112 rv = predImpl->evaluate(result); 00113 if (rv != OK) return NULL; 00114 //} 00115 //else 00116 // return tuple; 00117 } 00118 00119 } 00120 return tuple; 00121 }
Here is the call graph for this function:
Here is the caller graph for this function:
DbRetVal TupleIterator::open | ( | ) |
Definition at line 23 of file TupleIterator.cxx.
References Bucket::bucketList_, SingleFieldHashIndexInfo::buckets, HashIndex::computeHashBucket(), DM_HashIndex, ErrLockTimeOut, SingleFieldHashIndexInfo::fldName, fullTableScan, Mutex::getLock(), hashIndexScan, Bucket::mutex_, SingleFieldHashIndexInfo::noOfBuckets, OK, printDebug, printError, Mutex::releaseLock(), SingleFieldHashIndexInfo::type, and PredicateImpl::valPtrForIndexField().
Referenced by TableImpl::execute().
00024 { 00025 00026 if (fullTableScan == scanType_) 00027 { 00028 cIter = new ChunkIterator(); 00029 *cIter = ((Chunk*)chunkPtr_)->getIterator(); 00030 }else if (hashIndexScan == scanType_) 00031 { 00032 SingleFieldHashIndexInfo *hIdxInfo = (SingleFieldHashIndexInfo*)info; 00033 PredicateImpl *predImpl = (PredicateImpl*) pred_; 00034 bool isPtr = false; 00035 void *keyPtr = (void*)predImpl->valPtrForIndexField(hIdxInfo->fldName); 00036 00037 int bucketNo = HashIndex::computeHashBucket(hIdxInfo->type, 00038 keyPtr, hIdxInfo->noOfBuckets); 00039 Bucket *bucket = &(hIdxInfo->buckets[bucketNo]); 00040 int ret = bucket->mutex_.getLock(procSlot); 00041 if (ret != 0) 00042 { 00043 printError(ErrLockTimeOut,"Unable to acquire bucket Mutex for bucket %d",bucketNo); 00044 return ErrLockTimeOut; 00045 } 00046 HashIndexNode *head = (HashIndexNode*) bucket->bucketList_; 00047 if (!head) 00048 { 00049 bucket->mutex_.releaseLock(procSlot); 00050 bIter = NULL ; 00051 return OK; 00052 } 00053 printDebug(DM_HashIndex, "open:head for bucket %x is :%x", bucket, head); 00054 bIter = new BucketIter(head); 00055 bucket->mutex_.releaseLock(procSlot); 00056 } 00057 return OK; 00058 }
Here is the call graph for this function:
Here is the caller graph for this function: