re_arrow_store 0.5.0

An in-memory time series database for Rerun log data, based on Apache Arrow
Documentation
//! Demonstrates usage of [`re_arrow_store::polars_util::latest_component`].
//!
//! ```text
//! POLARS_FMT_MAX_ROWS=100 cargo r -p re_arrow_store --example latest_component
//! ```

use re_arrow_store::polars_util::latest_component;
use re_arrow_store::{test_row, DataStore, LatestAtQuery, TimeType, Timeline};
use re_log_types::component_types::Rect2D;
use re_log_types::datagen::build_some_rects;
use re_log_types::{
    component_types::{InstanceKey, Point2D},
    datagen::{build_frame_nr, build_some_point2d},
    Component, EntityPath,
};

fn main() {
    let mut store = DataStore::new(InstanceKey::name(), Default::default());

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

    let row = test_row!(ent_path @ [build_frame_nr(2.into())] => 4; [build_some_rects(4)]);
    store.insert_row(&row).unwrap();

    let row = test_row!(ent_path @ [build_frame_nr(3.into())] => 2; [build_some_point2d(2)]);
    store.insert_row(&row).unwrap();

    let timeline_frame_nr = Timeline::new("frame_nr", TimeType::Sequence);

    println!("Store contents:\n{}", store.to_dataframe());

    println!("\n-----\n");

    let df = latest_component(
        &store,
        &LatestAtQuery::new(timeline_frame_nr, 10.into()),
        &ent_path,
        Rect2D::name(),
    )
    .unwrap();
    println!("Query results from {:?}'s PoV:\n{df}", Rect2D::name());

    println!("\n-----\n");

    let df = latest_component(
        &store,
        &LatestAtQuery::new(timeline_frame_nr, 10.into()),
        &ent_path,
        Point2D::name(),
    )
    .unwrap();
    println!("Query results from {:?}'s PoV:\n{df}", Point2D::name());
}