Block API minor improvements#427
Merged
mshustov merged 9 commits intoClickHouse:masterfrom Jun 24, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces two new convenience methods in Block – Clear() to remove all rows and Reserve() to preallocate capacity – and adjusts the reservation strategy for LowCardinality columns to use a sqrt-based estimation. Additionally, it expands test coverage for ItemView serialization and block operations, while adding necessary declarations and minor improvements supporting these features.
- Added Block::Clear() and Block::Reserve() methods, with corresponding tests in ut/block_ut.cpp.
- Updated ColumnLowCardinality::Reserve() to reserve ceil(sqrt(new_cap)) for dictionary columns.
- Extended ItemView operator<< logic and integrated new includes and declarations.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ut/utils_ut.cpp | Expanded tests for ItemView serialization with new includes. |
| ut/utils_comparison.h | Introduced minor maintainability comments in CompareRecursive logic. |
| ut/utils.h | Added ItemView operator<< declaration. |
| ut/utils.cpp | Updated DateTime conversion and ItemView operator<< implementation. |
| ut/block_ut.cpp | Added tests for the new Clear() and Reserve() Block methods. |
| clickhouse/columns/lowcardinality.cpp | Modified Reserve() to improve memory usage via sqrt estimation. |
| clickhouse/columns/itemview.h | Enabled get() support for UInt128 in ItemView. |
| clickhouse/block.h | Declared new Block API methods (Clear and Reserve). |
| clickhouse/block.cpp | Implemented newly introduced Block::Clear() and Block::Reserve(). |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New minor feature.
Block::Clear()convenience method that clears out all rows from all columns.Block::Reserve()convenience method that increases capacity of all columns in the block.Those methods are for the clients that re-use the blocks for multiple batched inserts.
Also
ColumnLowCardinality::Reserve()now reservessqrt(X)items for dictionary column instead ofX-- this improves memory usage, since dictionary only holds unique keys of LC columns.