fix: [ut] regex query under unsupported index (#34087)

/kind improvement
issue: https://github.com/milvus-io/milvus/issues/29988

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
This commit is contained in:
Jiquan Long 2024-06-24 14:08:03 +08:00 committed by GitHub
parent d08cb885ca
commit aa36f9feed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -479,28 +479,33 @@ TEST_F(SealedSegmentRegexQueryTest, RegexQueryOnInvertedIndexStringField) {
ASSERT_TRUE(final[4]);
}
// TODO: optimize this case
// TEST_F(SealedSegmentRegexQueryTest, RegexQueryOnUnsupportedIndex) {
// std::string operand = "a%";
// const auto& str_meta = schema->operator[](FieldName("str"));
// auto column_info = test::GenColumnInfo(str_meta.get_id().get(),
// proto::schema::DataType::VarChar,
// false,
// false);
// auto unary_range_expr = test::GenUnaryRangeExpr(OpType::Match, operand);
// unary_range_expr->set_allocated_column_info(column_info);
// auto expr = test::GenExpr();
// expr->set_allocated_unary_range_expr(unary_range_expr);
TEST_F(SealedSegmentRegexQueryTest, RegexQueryOnUnsupportedIndex) {
std::string operand = "a%";
const auto& str_meta = schema->operator[](FieldName("str"));
auto column_info = test::GenColumnInfo(str_meta.get_id().get(),
proto::schema::DataType::VarChar,
false,
false);
auto unary_range_expr = test::GenUnaryRangeExpr(OpType::Match, operand);
unary_range_expr->set_allocated_column_info(column_info);
auto expr = test::GenExpr();
expr->set_allocated_unary_range_expr(unary_range_expr);
// auto parser = ProtoParser(*schema);
// auto typed_expr = parser.ParseExprs(*expr);
// auto parsed =
// std::make_shared<plan::FilterBitsNode>(DEFAULT_PLANNODE_ID, typed_expr);
auto parser = ProtoParser(*schema);
auto typed_expr = parser.ParseExprs(*expr);
auto parsed =
std::make_shared<plan::FilterBitsNode>(DEFAULT_PLANNODE_ID, typed_expr);
// LoadMockIndex();
LoadMockIndex();
// auto segpromote = dynamic_cast<SegmentSealedImpl*>(seg.get());
// query::ExecPlanNodeVisitor visitor(*segpromote, MAX_TIMESTAMP);
// BitsetType final;
// ASSERT_ANY_THROW(visitor.ExecuteExprNode(parsed, segpromote, N, final));
// }
auto segpromote = dynamic_cast<SegmentSealedImpl*>(seg.get());
query::ExecPlanNodeVisitor visitor(*segpromote, MAX_TIMESTAMP);
BitsetType final;
// regex query under this index will be executed using raw data (brute force).
visitor.ExecuteExprNode(parsed, segpromote, N, final);
ASSERT_FALSE(final[0]);
ASSERT_TRUE(final[1]);
ASSERT_TRUE(final[2]);
ASSERT_TRUE(final[3]);
ASSERT_TRUE(final[4]);
}