Skip to content

Commit

Permalink
propagate new DataStore constructor everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Nov 13, 2023
1 parent e04c722 commit 7c07b08
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 45 deletions.
6 changes: 5 additions & 1 deletion crates/re_arrow_store/benches/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@ fn insert_table(
cluster_key: ComponentName,
table: &DataTable,
) -> DataStore {
let mut store = DataStore::new(cluster_key, config);
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
cluster_key,
config,
);
for row in table.to_rows() {
store.insert_row(&row.unwrap()).unwrap();
}
Expand Down
6 changes: 5 additions & 1 deletion crates/re_arrow_store/examples/dump_dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ use re_types_core::Loggable as _;
// ---

fn main() {
let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let ent_paths = [
EntityPath::from("this/that"),
Expand Down
6 changes: 5 additions & 1 deletion crates/re_arrow_store/examples/latest_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ use re_types::{
use re_types_core::Loggable as _;

fn main() {
let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let ent_path = EntityPath::from("my/entity");

Expand Down
6 changes: 5 additions & 1 deletion crates/re_arrow_store/examples/latest_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ use re_types::{
use re_types_core::Loggable as _;

fn main() {
let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let ent_path = EntityPath::from("my/entity");

Expand Down
6 changes: 5 additions & 1 deletion crates/re_arrow_store/examples/range_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ use re_types::{
use re_types_core::Loggable as _;

fn main() {
let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let ent_path = EntityPath::from("this/that");

Expand Down
54 changes: 45 additions & 9 deletions crates/re_arrow_store/tests/correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ fn row_id_ordering_semantics() -> anyhow::Result<()> {
// * Query at frame #11 and make sure we get `point2` because random `RowId`s are monotonically
// increasing.
{
let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let row_id = RowId::random();
let row = DataRow::from_component_batches(
Expand Down Expand Up @@ -73,7 +77,11 @@ fn row_id_ordering_semantics() -> anyhow::Result<()> {
// * Insert `point1` at frame #10 with a random `RowId`.
// * Fail to insert `point2` at frame #10 using `point1`s `RowId` because it is illegal.
{
let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let row_id = RowId::random();

Expand All @@ -100,7 +108,11 @@ fn row_id_ordering_semantics() -> anyhow::Result<()> {
// * Insert `point2` at frame #10 using `point1`'s `RowId`, decremented by one.
// * Query at frame #11 and make sure we get `point1` because of intra-timestamp tie-breaks.
{
let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let row_id1 = RowId::random();
let row_id2 = row_id1.next();
Expand Down Expand Up @@ -151,7 +163,11 @@ fn write_errors() {
DataCell::from_component_sparse::<InstanceKey>([Some(1), None, Some(3)])
}

let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);
let row = test_row!(ent_path @
[build_frame_nr(32.into()), build_log_time(Time::now())] => 3; [
build_sparse_instances(), build_some_positions2d(3)
Expand All @@ -171,7 +187,11 @@ fn write_errors() {
DataCell::from_component::<InstanceKey>([1, 2, 2])
}

let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);
{
let row = test_row!(ent_path @
[build_frame_nr(32.into()), build_log_time(Time::now())] => 3; [
Expand All @@ -195,7 +215,11 @@ fn write_errors() {
}

{
let mut store = DataStore::new(InstanceKey::name(), Default::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let mut row = test_row!(ent_path @ [
build_frame_nr(1.into()),
Expand Down Expand Up @@ -228,7 +252,11 @@ fn latest_at_emptiness_edge_cases() {
init_logs();

for config in re_arrow_store::test_util::all_configs() {
let mut store = DataStore::new(InstanceKey::name(), config.clone());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
latest_at_emptiness_edge_cases_impl(&mut store);
}
}
Expand Down Expand Up @@ -354,7 +382,11 @@ fn range_join_across_single_row() {
init_logs();

for config in re_arrow_store::test_util::all_configs() {
let mut store = DataStore::new(InstanceKey::name(), config.clone());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
range_join_across_single_row_impl(&mut store);
}
}
Expand Down Expand Up @@ -422,7 +454,11 @@ fn range_join_across_single_row_impl(store: &mut DataStore) {
fn gc_correct() {
init_logs();

let mut store = DataStore::new(InstanceKey::name(), DataStoreConfig::default());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
DataStoreConfig::default(),
);

let stats_empty = DataStoreStats::from_store(&store);

Expand Down
51 changes: 43 additions & 8 deletions crates/re_arrow_store/tests/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ fn all_components() {
let assert_latest_components_at =
|store: &mut DataStore, ent_path: &EntityPath, expected: Option<&[ComponentName]>| {
// Stress test save-to-disk & load-from-disk
let mut store2 = DataStore::new(store.cluster_key(), store.config().clone());
let mut store2 = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
store.cluster_key(),
store.config().clone(),
);
for table in store.to_data_tables(None) {
insert_table_with_retries(&mut store2, &table);
}
Expand Down Expand Up @@ -100,6 +104,7 @@ fn all_components() {
// One big bucket, demonstrating the easier-to-reason-about cases.
{
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
DataStoreConfig {
indexed_bucket_num_rows: u64::MAX,
Expand Down Expand Up @@ -143,6 +148,7 @@ fn all_components() {
// Tiny buckets, demonstrating the harder-to-reason-about cases.
{
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
DataStoreConfig {
indexed_bucket_num_rows: 0,
Expand Down Expand Up @@ -203,6 +209,7 @@ fn all_components() {
// reason about, it is technically incorrect.
{
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
DataStoreConfig {
indexed_bucket_num_rows: 0,
Expand Down Expand Up @@ -276,7 +283,11 @@ fn latest_at() {
init_logs();

for config in re_arrow_store::test_util::all_configs() {
let mut store = DataStore::new(InstanceKey::name(), config.clone());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
latest_at_impl(&mut store);
}
}
Expand Down Expand Up @@ -324,7 +335,11 @@ fn latest_at_impl(store: &mut DataStore) {
);

// Stress test save-to-disk & load-from-disk
let mut store2 = DataStore::new(store.cluster_key(), store.config().clone());
let mut store2 = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
store.cluster_key(),
store.config().clone(),
);
for table in store.to_data_tables(None) {
insert_table(&mut store2, &table);
}
Expand Down Expand Up @@ -390,7 +405,11 @@ fn range() {
init_logs();

for config in re_arrow_store::test_util::all_configs() {
let mut store = DataStore::new(InstanceKey::name(), config.clone());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
range_impl(&mut store);
}
}
Expand Down Expand Up @@ -466,7 +485,11 @@ fn range_impl(store: &mut DataStore) {
components: [ComponentName; 2],
rows_at_times: &[(Option<TimeInt>, &[(ComponentName, &DataRow)])]| {
// Stress test save-to-disk & load-from-disk
let mut store2 = DataStore::new(store.cluster_key(), store.config().clone());
let mut store2 = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
store.cluster_key(),
store.config().clone(),
);
for table in store.to_data_tables(None) {
insert_table_with_retries(&mut store2, &table);
}
Expand Down Expand Up @@ -869,7 +892,11 @@ fn gc() {
init_logs();

for config in re_arrow_store::test_util::all_configs() {
let mut store = DataStore::new(InstanceKey::name(), config.clone());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
gc_impl(&mut store);
}
}
Expand Down Expand Up @@ -933,7 +960,11 @@ fn protected_gc() {
init_logs();

for config in re_arrow_store::test_util::all_configs() {
let mut store = DataStore::new(InstanceKey::name(), config.clone());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
protected_gc_impl(&mut store);
}
}
Expand Down Expand Up @@ -1029,7 +1060,11 @@ fn protected_gc_clear() {
init_logs();

for config in re_arrow_store::test_util::all_configs() {
let mut store = DataStore::new(InstanceKey::name(), config.clone());
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
protected_gc_clear_impl(&mut store);
}
}
Expand Down
36 changes: 30 additions & 6 deletions crates/re_arrow_store/tests/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,21 @@ fn data_store_dump() {
// NOTE: insert IDs aren't serialized and can be different across runs.
config.store_insert_ids = false;

let mut store1 = DataStore::new(InstanceKey::name(), config.clone());
let mut store2 = DataStore::new(InstanceKey::name(), config.clone());
let mut store3 = DataStore::new(InstanceKey::name(), config.clone());
let mut store1 = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
let mut store2 = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
let mut store3 = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);

data_store_dump_impl(&mut store1, &mut store2, &mut store3);

Expand Down Expand Up @@ -137,8 +149,16 @@ fn data_store_dump_filtered() {
// NOTE: insert IDs aren't serialized and can be different across runs.
config.store_insert_ids = false;

let mut store1 = DataStore::new(InstanceKey::name(), config.clone());
let mut store2 = DataStore::new(InstanceKey::name(), config.clone());
let mut store1 = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);
let mut store2 = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config.clone(),
);

data_store_dump_filtered_impl(&mut store1, &mut store2);

Expand Down Expand Up @@ -271,7 +291,11 @@ fn data_store_dump_empty_column() {
};
config.store_insert_ids = false;

let mut store = DataStore::new(InstanceKey::name(), config);
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
config,
);

data_store_dump_empty_column_impl(&mut store);
}
Expand Down
2 changes: 2 additions & 0 deletions crates/re_arrow_store/tests/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ fn pathological_bucket_topology() {
init_logs();

let mut store_forward = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
DataStoreConfig {
indexed_bucket_num_rows: 10,
..Default::default()
},
);
let mut store_backward = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
DataStoreConfig {
indexed_bucket_num_rows: 10,
Expand Down
Loading

0 comments on commit 7c07b08

Please sign in to comment.