Skip to content

Commit

Permalink
fix index degeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
czpmango committed Nov 12, 2021
1 parent 2c1d720 commit 626ba25
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/graph/optimizer/rule/IndexScanRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ StatusOr<OptRule::TransformResult> IndexScanRule::transform(OptContext* ctx,
FilterItems items;
ScanKind kind;
NG_RETURN_IF_ERROR(analyzeExpression(filter, &items, &kind, isEdge(groupNode)));
NG_RETURN_IF_ERROR(createIndexQueryCtx(iqctx, kind, items, qctx, groupNode));
auto status = createIndexQueryCtx(iqctx, kind, items, qctx, groupNode);
if (!status.ok()) {
NG_RETURN_IF_ERROR(createIndexQueryCtx(iqctx, qctx, groupNode));
}
}

const auto* oldIN = groupNode->node();
Expand Down Expand Up @@ -426,20 +429,15 @@ std::vector<IndexItem> IndexScanRule::findValidIndex(graph::QueryContext* qctx,
std::vector<IndexItem> validIndexes;
// Find indexes for match all fields by where condition.
for (const auto& index : indexes) {
bool allColsHint = true;
const auto& fields = index->get_fields();
for (const auto& item : items.items) {
auto it = std::find_if(fields.begin(), fields.end(), [item](const auto& field) {
return field.get_name() == item.col_;
});
if (it == fields.end()) {
allColsHint = false;
break;
if (it != fields.end()) {
validIndexes.emplace_back(index);
}
}
if (allColsHint) {
validIndexes.emplace_back(index);
}
}
// If the first field of the index does not match any condition, the index is
// invalid. remove it from validIndexes.
Expand Down

0 comments on commit 626ba25

Please sign in to comment.