-
Notifications
You must be signed in to change notification settings - Fork 175
Block API minor improvements #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(). |
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.