bool BTreeSearchExecStream::innerSearchLoop() { while (!pReader->isPositioned()) { if (!pInAccessor->demandData()) { return false; } readSearchKey(); readDirectives(); pSearchKey = &inputKeyData; readUpperBoundKey(); if (!searchForKey()) { pInAccessor->consumeTuple(); } } return true; }
inline bool BTree<KeyType, KeyComparator>::searchForKey( KeyType key, TID &tid, uint64_t pageId, size_t currentHeight) { BufferFrame *currentFrame = &bufferManager.fixPage(this->segmentId, pageId, false); bool result; if (isLeafHeight(currentHeight)) { Leaf<KeyType, KeyComparator> *leaf = reinterpret_cast<Leaf<KeyType, KeyComparator> *>( currentFrame->getData()); result = leaf->lookup(key, smallerComparator, &tid); } else { //we haven't reached the leaves yet InnerNode<KeyType, KeyComparator> *currNode = reinterpret_cast<InnerNode<KeyType, KeyComparator> *> ( currentFrame->getData()); pageId = currNode->getNextNode(key, smallerComparator); result = searchForKey(key, tid, pageId, currentHeight + 1); } //return page as result was received and page is no longer required bufferManager.unfixPage(*currentFrame, false); return result; }
inline bool BTree<KeyType, KeyComparator>::lookup(KeyType key, TID &tid) { // start from the root node and receive frame */ return searchForKey(key, tid, rootPageId, 0); }