diff --git a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp index 34cced3be29..8b7650cf18a 100644 --- a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp +++ b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp @@ -31,14 +31,17 @@ IMergedBlockOutputStream::IMergedBlockOutputStream( size_t min_compress_block_size_, size_t max_compress_block_size_, CompressionSettings compression_settings_, - size_t aio_threshold_) + size_t aio_threshold_, + const std::vector & index_granularity_) : storage(storage_), - min_compress_block_size(min_compress_block_size_), - max_compress_block_size(max_compress_block_size_), - aio_threshold(aio_threshold_), - compression_settings(compression_settings_), - marks_file_extension(storage.index_granularity_bytes == 0 ? FIXED_MARKS_FILE_EXTENSION : ADAPTIVE_MARKS_FILE_EXTENSION), - mark_size_in_bytes(storage.index_granularity_bytes == 0 ? FIXED_MARK_BYTE_SIZE : ADAPTIVE_MARK_BYTE_SIZE) + min_compress_block_size(min_compress_block_size_), + max_compress_block_size(max_compress_block_size_), + aio_threshold(aio_threshold_), + compression_settings(compression_settings_), + marks_file_extension(storage.index_granularity_bytes == 0 ? FIXED_MARKS_FILE_EXTENSION : ADAPTIVE_MARKS_FILE_EXTENSION), + mark_size_in_bytes(storage.index_granularity_bytes == 0 ? FIXED_MARK_BYTE_SIZE : ADAPTIVE_MARK_BYTE_SIZE), + index_granularity(index_granularity_), + compute_granularity_unknown(index_granularity.empty()) { } @@ -570,11 +573,11 @@ void MergedColumnOnlyOutputStream::write(const Block & block) for (size_t i = 0; i < block.columns(); ++i) { const ColumnWithTypeAndName & column = block.safeGetByPosition(i); - writeData(column.name, *column.type, *column.column, offset_columns, skip_offsets, serialization_states[i], current_block_index_granularity); + writeData(column.name, *column.type, *column.column, offset_columns, skip_offsets, serialization_states[i], storage.index_granularity); } - size_t written_for_last_mark = (current_block_index_granularity - index_offset + rows) % current_block_index_granularity; - index_offset = (current_block_index_granularity - written_for_last_mark) % current_block_index_granularity; + // size_t written_for_last_mark = (current_block_index_granularity - index_offset + rows) % current_block_index_granularity; + // index_offset = (current_block_index_granularity - written_for_last_mark) % current_block_index_granularity; } void MergedColumnOnlyOutputStream::writeSuffix() diff --git a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.h b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.h index 0f6dbe1d07b..f82b1f597d9 100644 --- a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.h +++ b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.h @@ -21,7 +21,8 @@ public: size_t min_compress_block_size_, size_t max_compress_block_size_, CompressionSettings compression_settings_, - size_t aio_threshold_); + size_t aio_threshold_, + const std::vector & index_granularity_ = {}); using WrittenOffsetColumns = std::set; @@ -91,8 +92,11 @@ protected: CompressionSettings compression_settings; + std::vector index_granularity; + std::string marks_file_extension; size_t mark_size_in_bytes; + bool compute_granularity_unknown; }; @@ -151,7 +155,6 @@ private: size_t rows_count = 0; size_t marks_count = 0; - std::vector marks_index_granularity; std::unique_ptr index_file_stream; std::unique_ptr index_stream; diff --git a/dbms/src/Storages/tests/CMakeLists.txt b/dbms/src/Storages/tests/CMakeLists.txt index 2ca5ad78dc1..2942ecfe6bc 100644 --- a/dbms/src/Storages/tests/CMakeLists.txt +++ b/dbms/src/Storages/tests/CMakeLists.txt @@ -27,4 +27,3 @@ target_link_libraries (get_current_inserts_in_replicated PRIVATE dbms clickhouse add_executable (get_abandonable_lock_in_all_partitions get_abandonable_lock_in_all_partitions.cpp) target_link_libraries (get_abandonable_lock_in_all_partitions PRIVATE dbms clickhouse_common_config clickhouse_common_zookeeper) -target_link_libraries (get_abandonable_lock_in_all_partitions dbms)