From daa910af6fa538247fea12d2f7d08526198ee750 Mon Sep 17 00:00:00 2001 From: Bingyi Sun Date: Thu, 10 Apr 2025 11:08:26 +0800 Subject: [PATCH] fix: Use int32 when creating array index for element type int8/int16 (#41186) issue: #41172 pr: #41185 Elements with type int8 or int16 in Array is encoded using int32, so we should parse it as int32 when creating index. Signed-off-by: sunby --- internal/core/src/index/InvertedIndexTantivy.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/core/src/index/InvertedIndexTantivy.cpp b/internal/core/src/index/InvertedIndexTantivy.cpp index 7ed8ddcb32..b77661fc5d 100644 --- a/internal/core/src/index/InvertedIndexTantivy.cpp +++ b/internal/core/src/index/InvertedIndexTantivy.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "InvertedIndexTantivy.h" @@ -572,6 +573,10 @@ template void InvertedIndexTantivy::build_index_for_array( const std::vector>& field_datas) { + using ElementType = std::conditional_t::value || + std::is_same::value, + int32_t, + T>; int64_t offset = 0; for (const auto& data : field_datas) { auto n = data->get_num_rows(); @@ -584,12 +589,16 @@ InvertedIndexTantivy::build_index_for_array( auto length = data->is_valid(i) ? array_column[i].length() : 0; if (!inverted_index_single_segment_) { wrapper_->template add_multi_data( - reinterpret_cast(array_column[i].data()), + reinterpret_cast( + array_column[i].data()), length, offset++); } else { wrapper_->template add_multi_data_by_single_segment_writer( - reinterpret_cast(array_column[i].data()), length); + reinterpret_cast( + array_column[i].data()), + length); + offset++; } } }