Fix granule size less than row size

This commit is contained in:
alesapin 2019-03-18 19:21:52 +03:00
parent 3fb494fea1
commit 4ad4fc3f7b
3 changed files with 31 additions and 1 deletions

View File

@ -139,6 +139,8 @@ void fillIndexGranularityImpl(
index_granularity_for_block = index_granularity_bytes / size_of_row_in_bytes;
}
}
if (index_granularity_for_block == 0) /// very rare case when index granularity bytes less then single row
index_granularity_for_block = 1;
std::cerr << "GRANULARITY SIZE IN ROWS:"<< index_granularity_for_block << std::endl;
for (size_t current_row = index_offset; current_row < rows_in_block; current_row += index_granularity_for_block)

View File

@ -1,3 +1,27 @@
DROP TABLE IF EXISTS test.zero_rows_per_granule;
CREATE TABLE test.zero_rows_per_granule (
p Date,
k UInt64,
v1 UInt64,
v2 Int64
) ENGINE MergeTree() PARTITION BY toYYYYMM(p) ORDER BY k SETTINGS index_granularity_bytes = 20;
INSERT INTO test.zero_rows_per_granule (p, k, v1, v2) VALUES ('2018-05-15', 1, 1000, 2000), ('2018-05-16', 2, 3000, 4000), ('2018-05-17', 3, 5000, 6000), ('2018-05-18', 4, 7000, 8000);
SELECT COUNT(*) FROM test.zero_rows_per_granule;
OPTIMIZE TABLE test.zero_rows_per_granule FINAL;
INSERT INTO test.zero_rows_per_granule (p, k, v1, v2) VALUES ('2018-05-15', 1, 1000, 2000), ('2018-05-16', 5, 3000, 4000), ('2018-05-17', 6, 5000, 6000), ('2018-05-19', 7, 7000, 8000);
SELECT COUNT(*) FROM test.zero_rows_per_granule;
DROP TABLE IF EXISTS test.zero_rows_per_granule;
-----
DROP TABLE IF EXISTS test.two_rows_per_granule;
CREATE TABLE test.two_rows_per_granule (
@ -20,7 +44,9 @@ SELECT COUNT(*) FROM test.two_rows_per_granule;
DROP TABLE IF EXISTS test.two_rows_per_granule;
DROP TABLE IF EXISTS test.two_rows_per_granule;
------
DROP TABLE IF EXISTS test.four_rows_per_granule;
CREATE TABLE test.four_rows_per_granule (
p Date,