void tagForSort(MatchExpression* tree) { if (!Indexability::nodeCanUseIndexOnOwnField(tree)) { size_t myTagValue = IndexTag::kNoIndex; for (size_t i = 0; i < tree->numChildren(); ++i) { MatchExpression* child = tree->getChild(i); tagForSort(child); IndexTag* childTag = static_cast<IndexTag*>(child->getTag()); if (NULL != childTag) { myTagValue = std::min(myTagValue, childTag->index); } } if (myTagValue != IndexTag::kNoIndex) { tree->setTag(new IndexTag(myTagValue)); } } }
bool PlanEnumerator::getNext(MatchExpression** tree) { if (_done) { return false; } // Tag with our first solution. tagMemo(_nodeToId[_root]); *tree = _root->shallowClone(); tagForSort(*tree); sortUsingTags(*tree); _root->resetTag(); QLOG() << "Enumerator: memo right before moving:\n"; dumpMemo(); _done = nextMemo(_nodeToId[_root]); QLOG() << "Enumerator: memo right after moving:\n"; dumpMemo(); return true; }