mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
fix indexes for ColumnArray
This commit is contained in:
parent
e7abc06c89
commit
c7d31c3a90
@ -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()
|
||||
|
@ -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]]);
|
||||
|
Loading…
Reference in New Issue
Block a user