mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: Use element_type for Array is null operator (#41157)
Related to #41156 --------- Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
parent
8a77fb9cdc
commit
e2d8adb963
@ -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]<FilterType filter_type = FilterType::sequential>(
|
||||
[&bitmap_input, &
|
||||
processed_cursor ]<FilterType filter_type = FilterType::sequential>(
|
||||
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_) {
|
||||
|
||||
@ -79,6 +79,7 @@ class PhyExistsFilterExpr : public SegmentExpr {
|
||||
|
||||
VectorPtr
|
||||
EvalJsonExistsForIndex();
|
||||
|
||||
private:
|
||||
std::shared_ptr<const milvus::expr::ExistsExpr> expr_;
|
||||
};
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#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<T> shall be ScalarIndex<ElementType>
|
||||
// NOT ScalarIndex<ArrayView>
|
||||
if (std::is_same_v<T, ArrayView>) {
|
||||
auto element_type =
|
||||
segment_->get_schema()[field_id_].get_element_type();
|
||||
switch (element_type) {
|
||||
case DataType::BOOL: {
|
||||
return ProcessIndexChunksForValid<bool>();
|
||||
}
|
||||
case DataType::INT8: {
|
||||
return ProcessIndexChunksForValid<int8_t>();
|
||||
}
|
||||
case DataType::INT16: {
|
||||
return ProcessIndexChunksForValid<int16_t>();
|
||||
}
|
||||
case DataType::INT32: {
|
||||
return ProcessIndexChunksForValid<int32_t>();
|
||||
}
|
||||
case DataType::INT64: {
|
||||
return ProcessIndexChunksForValid<int64_t>();
|
||||
}
|
||||
case DataType::FLOAT: {
|
||||
return ProcessIndexChunksForValid<float>();
|
||||
}
|
||||
case DataType::DOUBLE: {
|
||||
return ProcessIndexChunksForValid<double>();
|
||||
}
|
||||
case DataType::STRING:
|
||||
case DataType::VARCHAR: {
|
||||
return ProcessIndexChunksForValid<std::string>();
|
||||
}
|
||||
default:
|
||||
PanicInfo(DataTypeInvalid,
|
||||
"unsupported element type: {}",
|
||||
element_type);
|
||||
}
|
||||
}
|
||||
return ProcessIndexChunksForValid<T>();
|
||||
} else {
|
||||
return ProcessDataChunksForValid<T>();
|
||||
@ -878,6 +916,51 @@ class SegmentExpr : public Expr {
|
||||
valid_result.set();
|
||||
|
||||
if (use_index) {
|
||||
// when T is ArrayView, the ScalarIndex<T> shall be ScalarIndex<ElementType>
|
||||
// NOT ScalarIndex<ArrayView>
|
||||
if (std::is_same_v<T, ArrayView>) {
|
||||
auto element_type =
|
||||
segment_->get_schema()[field_id_].get_element_type();
|
||||
switch (element_type) {
|
||||
case DataType::BOOL: {
|
||||
return ProcessChunksForValidByOffsets<bool>(use_index,
|
||||
input);
|
||||
}
|
||||
case DataType::INT8: {
|
||||
return ProcessChunksForValidByOffsets<int8_t>(use_index,
|
||||
input);
|
||||
}
|
||||
case DataType::INT16: {
|
||||
return ProcessChunksForValidByOffsets<int16_t>(
|
||||
use_index, input);
|
||||
}
|
||||
case DataType::INT32: {
|
||||
return ProcessChunksForValidByOffsets<int32_t>(
|
||||
use_index, input);
|
||||
}
|
||||
case DataType::INT64: {
|
||||
return ProcessChunksForValidByOffsets<int64_t>(
|
||||
use_index, input);
|
||||
}
|
||||
case DataType::FLOAT: {
|
||||
return ProcessChunksForValidByOffsets<float>(use_index,
|
||||
input);
|
||||
}
|
||||
case DataType::DOUBLE: {
|
||||
return ProcessChunksForValidByOffsets<double>(use_index,
|
||||
input);
|
||||
}
|
||||
case DataType::STRING:
|
||||
case DataType::VARCHAR: {
|
||||
return ProcessChunksForValidByOffsets<std::string>(
|
||||
use_index, input);
|
||||
}
|
||||
default:
|
||||
PanicInfo(DataTypeInvalid,
|
||||
"unsupported element type: {}",
|
||||
element_type);
|
||||
}
|
||||
}
|
||||
const Index& index =
|
||||
segment_->chunk_scalar_index<IndexInnerType>(field_id_, 0);
|
||||
auto* index_ptr = const_cast<Index*>(&index);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user