Skip to content

Commit

Permalink
demonstrating the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 28, 2023
1 parent 0e69707 commit b41f4ea
Showing 1 changed file with 49 additions and 23 deletions.
72 changes: 49 additions & 23 deletions crates/re_log_types/src/data_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,37 +1124,63 @@ fn data_table_sizes() {
use crate::{component_types::InstanceKey, Component as _};
use arrow2::array::UInt64Array;

{
let mut cell = DataCell::from_arrow(
InstanceKey::name(),
UInt64Array::from_vec(vec![1, 2, 3]).boxed(),
);
fn expect(mut cell: DataCell, num_rows: usize, num_bytes: u64) {
cell.compute_size_bytes();

let row = DataRow::from_cells1(RowId::random(), "a/b/c", TimePoint::default(), 3, cell);
let row = DataRow::from_cells1(
RowId::random(),
"a/b/c",
TimePoint::default(),
cell.num_instances(),
cell,
);

let table = DataTable::from_rows(TableId::random(), [row]);
assert_eq!(244, table.heap_size_bytes());
let table = DataTable::from_rows(
TableId::random(),
std::iter::repeat_with(|| row.clone()).take(num_rows),
);
assert_eq!(num_bytes, table.heap_size_bytes());

let mut table = DataTable::from_arrow_msg(&table.to_arrow_msg().unwrap()).unwrap();
table.compute_all_size_bytes();
assert_eq!(244, table.heap_size_bytes());
assert_eq!(num_bytes, table.heap_size_bytes());
}

{
let mut cell = DataCell::from_arrow(
// primitive
expect(
DataCell::from_arrow(
InstanceKey::name(),
UInt64Array::from_vec(vec![1, 2, 3]).boxed(),
);
cell.compute_size_bytes();

let row = DataRow::from_cells1(RowId::random(), "a/b/c", TimePoint::default(), 3, cell);

let table = DataTable::from_rows(TableId::random(), [row.clone(), row]);
assert_eq!(424, table.heap_size_bytes());

let mut table = DataTable::from_arrow_msg(&table.to_arrow_msg().unwrap()).unwrap();
table.compute_all_size_bytes();
assert_eq!(424, table.heap_size_bytes());
}
),
10_000, // num_rows
1_800_064, // expected_num_bytes
);

// utf8
expect(
DataCell::from_native([crate::component_types::Label("hey".into())].as_slice()),
10_000, // num_rows
1_670_064, // expected_num_bytes
);

// struct
expect(
DataCell::from_native([crate::component_types::Point2D::new(42.0, 666.0)].as_slice()),
10_000, // num_rows
4_060_064, // expected_num_bytes
);

// struct + fixedsizelist
expect(
DataCell::from_native([crate::component_types::Vec2D::from([42.0, 666.0])].as_slice()),
10_000, // num_rows
2_880_064, // expected_num_bytes
);

// union
expect(
DataCell::from_native([crate::Transform::Unknown].as_slice()),
10_000, // num_rows
15_610_064, // expected_num_bytes
);
}

0 comments on commit b41f4ea

Please sign in to comment.