-
Notifications
You must be signed in to change notification settings - Fork 405
/
Copy pathdataframe_query.rs
38 lines (30 loc) · 1.1 KB
/
dataframe_query.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Query and display the first 10 rows of a recording.
use rerun::{
dataframe::{QueryEngine, QueryExpression, SparseFillStrategy, TimelineName},
external::re_format_arrow::format_record_batch,
ChunkStoreConfig, VersionPolicy,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = std::env::args().collect::<Vec<_>>();
let path_to_rrd = &args[1];
let timeline = TimelineName::log_time();
let engines = QueryEngine::from_rrd_filepath(
&ChunkStoreConfig::DEFAULT,
path_to_rrd,
VersionPolicy::Warn,
)?;
let Some((_, engine)) = engines.first_key_value() else {
return Ok(());
};
let query = QueryExpression {
filtered_index: Some(timeline),
sparse_fill_strategy: SparseFillStrategy::LatestAtGlobal,
..Default::default()
};
let query_handle = engine.query(query.clone());
for row in query_handle.batch_iter().take(10) {
// Each row is a `RecordBatch`, which can be easily passed around across different data ecosystems.
println!("{}", format_record_batch(&row));
}
Ok(())
}