Skip to content

Commit

Permalink
fix: disable use_index when some array expr (#34894)
Browse files Browse the repository at this point in the history
#34797

Signed-off-by: luzhang <luzhang@zilliz.com>
Co-authored-by: luzhang <luzhang@zilliz.com>
  • Loading branch information
zhagnlu and luzhang authored Jul 28, 2024
1 parent 5584ae2 commit f77f536
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ PhyBinaryArithOpEvalRangeExpr::Eval(EvalCtx& context, VectorPtr& result) {
auto value_type = expr_->value_.val_case();
switch (value_type) {
case proto::plan::GenericValue::ValCase::kInt64Val: {
SetNotUseIndex();
result = ExecRangeVisitorImplForArray<int64_t>();
break;
}
case proto::plan::GenericValue::ValCase::kFloatVal: {
SetNotUseIndex();
result = ExecRangeVisitorImplForArray<double>();
break;
}
Expand Down
3 changes: 3 additions & 0 deletions internal/core/src/exec/expression/BinaryRangeExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@ PhyBinaryRangeFilterExpr::Eval(EvalCtx& context, VectorPtr& result) {
auto value_type = expr_->lower_val_.val_case();
switch (value_type) {
case proto::plan::GenericValue::ValCase::kInt64Val: {
SetNotUseIndex();
result = ExecRangeVisitorImplForArray<int64_t>();
break;
}
case proto::plan::GenericValue::ValCase::kFloatVal: {
SetNotUseIndex();
result = ExecRangeVisitorImplForArray<double>();
break;
}
case proto::plan::GenericValue::ValCase::kStringVal: {
SetNotUseIndex();
result = ExecRangeVisitorImplForArray<std::string>();
break;
}
Expand Down
5 changes: 5 additions & 0 deletions internal/core/src/exec/expression/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ class SegmentExpr : public Expr {
return true;
}

void
SetNotUseIndex() {
use_index_ = false;
}

protected:
const segcore::SegmentInternalInterface* segment_;
const FieldId field_id_;
Expand Down
5 changes: 5 additions & 0 deletions internal/core/src/exec/expression/TermExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,26 @@ PhyTermFilterExpr::Eval(EvalCtx& context, VectorPtr& result) {
}
case DataType::ARRAY: {
if (expr_->vals_.size() == 0) {
SetNotUseIndex();
result = ExecVisitorImplTemplateArray<bool>();
break;
}
auto type = expr_->vals_[0].val_case();
switch (type) {
case proto::plan::GenericValue::ValCase::kBoolVal:
SetNotUseIndex();
result = ExecVisitorImplTemplateArray<bool>();
break;
case proto::plan::GenericValue::ValCase::kInt64Val:
SetNotUseIndex();
result = ExecVisitorImplTemplateArray<int64_t>();
break;
case proto::plan::GenericValue::ValCase::kFloatVal:
SetNotUseIndex();
result = ExecVisitorImplTemplateArray<double>();
break;
case proto::plan::GenericValue::ValCase::kStringVal:
SetNotUseIndex();
result = ExecVisitorImplTemplateArray<std::string>();
break;
default:
Expand Down
4 changes: 4 additions & 0 deletions internal/core/src/exec/expression/UnaryExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,19 @@ PhyUnaryRangeFilterExpr::Eval(EvalCtx& context, VectorPtr& result) {
auto val_type = expr_->val_.val_case();
switch (val_type) {
case proto::plan::GenericValue::ValCase::kBoolVal:
SetNotUseIndex();
result = ExecRangeVisitorImplArray<bool>();
break;
case proto::plan::GenericValue::ValCase::kInt64Val:
SetNotUseIndex();
result = ExecRangeVisitorImplArray<int64_t>();
break;
case proto::plan::GenericValue::ValCase::kFloatVal:
SetNotUseIndex();
result = ExecRangeVisitorImplArray<double>();
break;
case proto::plan::GenericValue::ValCase::kStringVal:
SetNotUseIndex();
result = ExecRangeVisitorImplArray<std::string>();
break;
case proto::plan::GenericValue::ValCase::kArrayVal:
Expand Down

0 comments on commit f77f536

Please sign in to comment.