refactor: include capacity in Read Buffer chunk size
parent
03592aaf94
commit
311d36d776
|
@ -369,9 +369,9 @@ async fn sql_select_from_system_chunk_columns() {
|
|||
"+---------------+----------+------------+-------------+-------------------+-----------+------------+-----------+-----------+--------------+",
|
||||
"| partition_key | chunk_id | table_name | column_name | storage | row_count | null_count | min_value | max_value | memory_bytes |",
|
||||
"+---------------+----------+------------+-------------+-------------------+-----------+------------+-----------+-----------+--------------+",
|
||||
"| 1970-01-01T00 | 0 | h2o | city | ReadBuffer | 2 | 0 | Boston | Boston | 255 |",
|
||||
"| 1970-01-01T00 | 0 | h2o | city | ReadBuffer | 2 | 0 | Boston | Boston | 327 |",
|
||||
"| 1970-01-01T00 | 0 | h2o | other_temp | ReadBuffer | 2 | 1 | 70.4 | 70.4 | 471 |",
|
||||
"| 1970-01-01T00 | 0 | h2o | state | ReadBuffer | 2 | 0 | MA | MA | 243 |",
|
||||
"| 1970-01-01T00 | 0 | h2o | state | ReadBuffer | 2 | 0 | MA | MA | 315 |",
|
||||
"| 1970-01-01T00 | 0 | h2o | temp | ReadBuffer | 2 | 1 | 70.4 | 70.4 | 471 |",
|
||||
"| 1970-01-01T00 | 0 | h2o | time | ReadBuffer | 2 | 0 | 50 | 250 | 110 |",
|
||||
"| 1970-01-01T00 | 0 | o2 | city | OpenMutableBuffer | 2 | 1 | Boston | Boston | 35 |",
|
||||
|
|
|
@ -51,8 +51,17 @@ impl Column {
|
|||
// Meta information about the column
|
||||
//
|
||||
|
||||
/// The estimated size in bytes of the column that is held in memory.
|
||||
/// The estimated size in bytes of all data in the column, including all
|
||||
/// allocated but unfilled buffers. An estimation of the on-heap memory usage
|
||||
// of this column.
|
||||
pub fn size(&self) -> usize {
|
||||
self.size_bytes(true)
|
||||
}
|
||||
|
||||
// This method exposes two ways to calculate an estimation for the in-memory
|
||||
// size of the column. When `with_capacity` is true then all allocated but
|
||||
// unused buffers are taken into account.
|
||||
fn size_bytes(&self, with_capacity: bool) -> usize {
|
||||
// Since `MetaData` is generic each value in the range can have a
|
||||
// different size, so just do the calculations here where we know each
|
||||
// `T`.
|
||||
|
@ -63,19 +72,19 @@ impl Column {
|
|||
if let Some((min, max)) = &meta.range {
|
||||
meta_size += min.len() + max.len();
|
||||
};
|
||||
meta_size + data.size(false)
|
||||
meta_size + data.size(with_capacity)
|
||||
}
|
||||
Self::Float(_, data) => {
|
||||
let meta_size = size_of::<Option<(f64, f64)>>() + size_of::<ColumnProperties>();
|
||||
meta_size + data.size(false)
|
||||
meta_size + data.size(with_capacity)
|
||||
}
|
||||
Self::Integer(_, data) => {
|
||||
let meta_size = size_of::<Option<(i64, i64)>>() + size_of::<ColumnProperties>();
|
||||
meta_size + data.size(false)
|
||||
meta_size + data.size(with_capacity)
|
||||
}
|
||||
Self::Unsigned(_, data) => {
|
||||
let meta_size = size_of::<Option<(u64, u64)>>() + size_of::<ColumnProperties>();
|
||||
meta_size + data.size(false)
|
||||
meta_size + data.size(with_capacity)
|
||||
}
|
||||
Self::Bool(_, data) => {
|
||||
let meta_size = size_of::<Option<(bool, bool)>>() + size_of::<ColumnProperties>();
|
||||
|
@ -88,7 +97,7 @@ impl Column {
|
|||
meta_size += min.len() + max.len();
|
||||
};
|
||||
|
||||
meta_size + data.size(false)
|
||||
meta_size + data.size(with_capacity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2531,7 +2531,7 @@ mod tests {
|
|||
("svr_id", "1"),
|
||||
])
|
||||
.histogram()
|
||||
.sample_sum_eq(3308.0)
|
||||
.sample_sum_eq(3436.0)
|
||||
.unwrap();
|
||||
|
||||
let rb = collect_read_filter(&rb_chunk).await;
|
||||
|
|
Loading…
Reference in New Issue