More simpliest test

This commit is contained in:
alesapin 2019-03-18 19:09:31 +03:00
parent 2b2a637a38
commit 05215b181f
3 changed files with 35 additions and 8 deletions

View File

@ -128,7 +128,9 @@ void fillIndexGranularityImpl(
index_granularity_for_block = rows_in_block;
else if (block_size_in_memory >= index_granularity_bytes)
{
std::cerr << "BLOCK SIZE In MEMORY:" << block_size_in_memory << std::endl;
size_t granules_in_block = block_size_in_memory / index_granularity_bytes;
std::cerr << "GRANULES IN BLOCK:" << granules_in_block << std::endl;
index_granularity_for_block = rows_in_block / granules_in_block;
}
else
@ -137,6 +139,7 @@ void fillIndexGranularityImpl(
index_granularity_for_block = index_granularity_bytes / size_of_row_in_bytes;
}
}
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)
index_granularity.push_back(index_granularity_for_block);

View File

@ -1,21 +1,43 @@
DROP TABLE IF EXISTS test.adapted_index_granularity_table;
DROP TABLE IF EXISTS test.two_rows_per_granule;
CREATE TABLE test.adapted_index_granularity_table (
CREATE TABLE test.two_rows_per_granule (
p Date,
k UInt64,
v1 UInt64,
v2 Int64
) ENGINE MergeTree() PARTITION BY toYYYYMM(p) ORDER BY k SETTINGS index_granularity_bytes = 40;
INSERT INTO test.adapted_index_granularity_table (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);
INSERT INTO test.two_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.adapted_index_granularity_table;
SELECT COUNT(*) FROM test.two_rows_per_granule;
OPTIMIZE TABLE test.adapted_index_granularity_table FINAL;
OPTIMIZE TABLE test.two_rows_per_granule FINAL;
INSERT INTO test.adapted_index_granularity_table (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);
INSERT INTO test.two_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.adapted_index_granularity_table;
SELECT COUNT(*) FROM test.two_rows_per_granule;
DROP TABLE IF EXISTS test.adapted_index_granularity_table;
DROP TABLE IF EXISTS test.two_rows_per_granule;
DROP TABLE IF EXISTS test.two_rows_per_granule;
CREATE TABLE test.four_rows_per_granule (
p Date,
k UInt64,
v1 UInt64,
v2 Int64
) ENGINE MergeTree() PARTITION BY toYYYYMM(p) ORDER BY k SETTINGS index_granularity_bytes = 40;
INSERT INTO test.four_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.four_rows_per_granule;
OPTIMIZE TABLE test.four_rows_per_granule FINAL;
INSERT INTO test.four_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.four_rows_per_granule;
DROP TABLE IF EXISTS test.four_rows_per_granule;