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 May 2, 2023
1 parent 6e348db commit 25ca19c
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions crates/re_log_types/src/data_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,3 +1118,69 @@ impl DataTable {
table
}
}

#[test]
fn data_table_sizes() {
use crate::{component_types::InstanceKey, Component as _};
use arrow2::array::UInt64Array;

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(),
cell.num_instances(),
cell,
);

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!(num_bytes, table.heap_size_bytes());
}

// primitive
expect(
DataCell::from_arrow(
InstanceKey::name(),
UInt64Array::from_vec(vec![1, 2, 3]).boxed(),
),
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 25ca19c

Please sign in to comment.