diff --git a/internal/core/src/exec/expression/ExistsExpr.cpp b/internal/core/src/exec/expression/ExistsExpr.cpp index 3516b16bff..7b3fbf045c 100644 --- a/internal/core/src/exec/expression/ExistsExpr.cpp +++ b/internal/core/src/exec/expression/ExistsExpr.cpp @@ -112,8 +112,8 @@ PhyExistsFilterExpr::EvalJsonExistsForDataSegment(EvalCtx& context) { auto pointer = milvus::Json::pointer(expr_->column_.nested_path_); int processed_cursor = 0; auto execute_sub_batch = - [&bitmap_input, - &processed_cursor]( + [&bitmap_input, & + processed_cursor ]( const milvus::Json* data, const bool* valid_data, const int32_t* offsets, @@ -121,23 +121,23 @@ PhyExistsFilterExpr::EvalJsonExistsForDataSegment(EvalCtx& context) { TargetBitmapView res, TargetBitmapView valid_res, const std::string& pointer) { - bool has_bitmap_input = !bitmap_input.empty(); - for (int i = 0; i < size; ++i) { - auto offset = i; - if constexpr (filter_type == FilterType::random) { - offset = (offsets) ? offsets[i] : i; - } - if (valid_data != nullptr && !valid_data[offset]) { - res[i] = valid_res[i] = false; - continue; - } - if (has_bitmap_input && !bitmap_input[processed_cursor + i]) { - continue; - } - res[i] = data[offset].exist(pointer); + bool has_bitmap_input = !bitmap_input.empty(); + for (int i = 0; i < size; ++i) { + auto offset = i; + if constexpr (filter_type == FilterType::random) { + offset = (offsets) ? offsets[i] : i; } - processed_cursor += size; - }; + if (valid_data != nullptr && !valid_data[offset]) { + res[i] = valid_res[i] = false; + continue; + } + if (has_bitmap_input && !bitmap_input[processed_cursor + i]) { + continue; + } + res[i] = data[offset].exist(pointer); + } + processed_cursor += size; + }; int64_t processed_size; if (has_offset_input_) { diff --git a/internal/core/src/exec/expression/ExistsExpr.h b/internal/core/src/exec/expression/ExistsExpr.h index c15a5a5daf..cfba58c582 100644 --- a/internal/core/src/exec/expression/ExistsExpr.h +++ b/internal/core/src/exec/expression/ExistsExpr.h @@ -79,6 +79,7 @@ class PhyExistsFilterExpr : public SegmentExpr { VectorPtr EvalJsonExistsForIndex(); + private: std::shared_ptr expr_; }; diff --git a/internal/core/src/exec/expression/Expr.h b/internal/core/src/exec/expression/Expr.h index f7ad98e4c3..8f42055445 100644 --- a/internal/core/src/exec/expression/Expr.h +++ b/internal/core/src/exec/expression/Expr.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "common/FieldDataInterface.h" #include "common/Json.h" @@ -860,6 +861,43 @@ class SegmentExpr : public Expr { TargetBitmap ProcessChunksForValid(bool use_index) { if (use_index) { + // when T is ArrayView, the ScalarIndex shall be ScalarIndex + // NOT ScalarIndex + if (std::is_same_v) { + auto element_type = + segment_->get_schema()[field_id_].get_element_type(); + switch (element_type) { + case DataType::BOOL: { + return ProcessIndexChunksForValid(); + } + case DataType::INT8: { + return ProcessIndexChunksForValid(); + } + case DataType::INT16: { + return ProcessIndexChunksForValid(); + } + case DataType::INT32: { + return ProcessIndexChunksForValid(); + } + case DataType::INT64: { + return ProcessIndexChunksForValid(); + } + case DataType::FLOAT: { + return ProcessIndexChunksForValid(); + } + case DataType::DOUBLE: { + return ProcessIndexChunksForValid(); + } + case DataType::STRING: + case DataType::VARCHAR: { + return ProcessIndexChunksForValid(); + } + default: + PanicInfo(DataTypeInvalid, + "unsupported element type: {}", + element_type); + } + } return ProcessIndexChunksForValid(); } else { return ProcessDataChunksForValid(); @@ -878,6 +916,51 @@ class SegmentExpr : public Expr { valid_result.set(); if (use_index) { + // when T is ArrayView, the ScalarIndex shall be ScalarIndex + // NOT ScalarIndex + if (std::is_same_v) { + auto element_type = + segment_->get_schema()[field_id_].get_element_type(); + switch (element_type) { + case DataType::BOOL: { + return ProcessChunksForValidByOffsets(use_index, + input); + } + case DataType::INT8: { + return ProcessChunksForValidByOffsets(use_index, + input); + } + case DataType::INT16: { + return ProcessChunksForValidByOffsets( + use_index, input); + } + case DataType::INT32: { + return ProcessChunksForValidByOffsets( + use_index, input); + } + case DataType::INT64: { + return ProcessChunksForValidByOffsets( + use_index, input); + } + case DataType::FLOAT: { + return ProcessChunksForValidByOffsets(use_index, + input); + } + case DataType::DOUBLE: { + return ProcessChunksForValidByOffsets(use_index, + input); + } + case DataType::STRING: + case DataType::VARCHAR: { + return ProcessChunksForValidByOffsets( + use_index, input); + } + default: + PanicInfo(DataTypeInvalid, + "unsupported element type: {}", + element_type); + } + } const Index& index = segment_->chunk_scalar_index(field_id_, 0); auto* index_ptr = const_cast(&index);