Skip to content

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

Enmk
Copy link
Contributor

@Enmk Enmk commented Jun 3, 2025

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 reserves sqrt(X) items for dictionary column instead of X -- this improves memory usage, since dictionary only holds unique keys of LC columns.

@Enmk Enmk changed the title Block::Clear() and some tests Block API minor improvements Jun 5, 2025
@mshustov mshustov requested a review from Copilot June 5, 2025 08:24
Copy link

@Copilot Copilot AI left a 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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant