fix computation of granularity in vertical merges

This commit is contained in:
Anton Popov 2023-01-27 13:35:04 +00:00
parent fb3f7409fa
commit 9c1717b42d

View File

@ -135,6 +135,7 @@ static size_t computeIndexGranularityImpl(
{
size_t rows_in_block = block.rows();
size_t index_granularity_for_block;
if (!can_use_adaptive_index_granularity)
{
index_granularity_for_block = fixed_index_granularity_rows;
@ -143,7 +144,9 @@ static size_t computeIndexGranularityImpl(
{
size_t block_size_in_memory = block.bytes();
if (blocks_are_granules)
{
index_granularity_for_block = rows_in_block;
}
else if (block_size_in_memory >= index_granularity_bytes)
{
size_t granules_in_block = block_size_in_memory / index_granularity_bytes;
@ -155,10 +158,14 @@ static size_t computeIndexGranularityImpl(
index_granularity_for_block = index_granularity_bytes / size_of_row_in_bytes;
}
}
/// We should be less or equal than fixed index granularity
/// We should be less or equal than fixed index granularity.
/// But if block size is a granule size then do no ajust it.
/// Granularity greater than fixed granularity might come from compact part.
if (!blocks_are_granules)
index_granularity_for_block = std::min(fixed_index_granularity_rows, index_granularity_for_block);
/// very rare case when index granularity bytes less then single row
/// Very rare case when index granularity bytes less than single row.
if (index_granularity_for_block == 0)
index_granularity_for_block = 1;