From df1ab30567990edfd6934ddcec315a1ac2d0381f Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 3 Sep 2024 16:56:21 +0200 Subject: [PATCH] more flexible example --- crates/store/re_dataframe/examples/range.rs | 62 +++++++++------------ 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/crates/store/re_dataframe/examples/range.rs b/crates/store/re_dataframe/examples/range.rs index df081eae0510..9e844c5828b9 100644 --- a/crates/store/re_dataframe/examples/range.rs +++ b/crates/store/re_dataframe/examples/range.rs @@ -10,14 +10,21 @@ use re_log_types::{ResolvedTimeRange, StoreKind}; fn main() -> anyhow::Result<()> { let args = std::env::args().collect_vec(); - let Some(path_to_rrd) = args.get(1) else { - eprintln!( - "Usage: {} ", - args.first().map_or("$BIN", |s| s.as_str()) - ); - std::process::exit(1); + let get_arg = |i| { + let Some(value) = args.get(i) else { + eprintln!( + "Usage: {} [entity_path_expr]", + args.first().map_or("$BIN", |s| s.as_str()) + ); + std::process::exit(1); + }; + value }; + let path_to_rrd = get_arg(1); + let entity_path_pov = get_arg(2).as_str(); + let entity_path_expr = args.get(3).map_or("/**", |s| s.as_str()); + let stores = ChunkStore::from_rrd_filepath( &ChunkStoreConfig::DEFAULT, path_to_rrd, @@ -35,38 +42,19 @@ fn main() -> anyhow::Result<()> { cache: &cache, }; - { - let query = RangeQueryExpression { - entity_path_expr: "/**".into(), - timeline: Timeline::log_tick(), - time_range: ResolvedTimeRange::new(0, 30), - pov: ComponentColumnDescriptor::new::( - "helix/structure/scaffolding/beads".into(), - ), - }; - - let query_handle = engine.range(&query, None /* columns */); - eprintln!("{query}:"); - for batch in query_handle.into_iter() { - eprintln!("{batch}"); - } - } - eprintln!("---"); - { - let query = RangeQueryExpression { - entity_path_expr: "/helix/structure/scaffolding/**".into(), - timeline: Timeline::log_tick(), - time_range: ResolvedTimeRange::new(0, 30), - pov: ComponentColumnDescriptor::new::( - "helix/structure/scaffolding/beads".into(), - ), - }; + let query = RangeQueryExpression { + entity_path_expr: entity_path_expr.into(), + timeline: Timeline::log_tick(), + time_range: ResolvedTimeRange::new(0, 30), + pov: ComponentColumnDescriptor::new::( + entity_path_pov.into(), + ), + }; - let query_handle = engine.range(&query, None /* columns */); - eprintln!("{query}:"); - for batch in query_handle.into_iter() { - eprintln!("{batch}"); - } + let query_handle = engine.range(&query, None /* columns */); + eprintln!("{query}:"); + for batch in query_handle.into_iter() { + eprintln!("{batch}"); } }