clickhouse-rs
clickhouse-rs copied to clipboard
Questions about whether the with_capacity method of the Block interface is valid
I read the code of clickhouse-rs and found that after setting the capacity in Block::with_capacity, the later code does not use it. Shouldn't this be changed here?
/// Constructs a new, empty `Block` with the specified capacity.
pub fn with_capacity(capacity: usize) -> Self {
Self {
info: Default::default(),
columns: Vec::with_capacity(capacity),
capacity
}
}
The size field stores the estimated number of rows, not columns. This is reasonable because, in practice, the number of rows in blocks is usually much larger than the number of columns, and reducing unnecessary allocations when adding rows can significantly improve performance. These are the places where this field is used:
Thank you very much for your answer.