fix indexes for ColumnArray

This commit is contained in:
FArthur-cmd 2022-08-30 15:32:05 +00:00
parent e7abc06c89
commit c7d31c3a90
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
option(ENABLE_ANNOY "Enable Annoy index support" ${ENABLE_LIBRARIES})
if ((NOT ENABLE_ANNOY) OR (SANITIZE STREQUAL "undefined"))
if (NOT ENABLE_ANNOY)
message (STATUS "Not using annoy")
return()
endif()

View File

@ -128,6 +128,8 @@ void MergeTreeIndexAggregatorAnnoy::update(const Block & block, size_t * pos, si
toString(*pos), toString(block.rows()));
size_t rows_read = std::min(limit, block.rows() - *pos);
if (rows_read == 0)
return;
if (index_sample_block.columns() > 1)
{
@ -142,7 +144,7 @@ void MergeTreeIndexAggregatorAnnoy::update(const Block & block, size_t * pos, si
const auto & data = column_array->getData();
const auto & array = typeid_cast<const ColumnFloat32&>(data).getData();
const auto & offsets = column_array->getOffsets();
size_t num_rows = column_array->size();
size_t num_rows = offsets->size();
/// All sizes are the same
size_t size = offsets[0];
@ -155,6 +157,8 @@ void MergeTreeIndexAggregatorAnnoy::update(const Block & block, size_t * pos, si
}
index = std::make_shared<AnnoyIndex>(size);
index->add_item(index->get_n_items(), &array[0]);
/// add all rows from 1 to num_rows - 1 (this is the same as the beginning of the last element)
for (size_t current_row = 0; current_row < num_rows; ++current_row)
{
index->add_item(index->get_n_items(), &array[offsets[current_row]]);