Skip to content

Commit

Permalink
LogDb -> StoreDb
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jun 2, 2023
1 parent 1f07303 commit 603ab32
Show file tree
Hide file tree
Showing 47 changed files with 289 additions and 282 deletions.
2 changes: 1 addition & 1 deletion crates/re_data_store/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::hash::Hash;

use re_log_types::{EntityPath, EntityPathHash, InstanceKey};

use crate::log_db::EntityDb;
use crate::store_db::EntityDb;

// ----------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ mod editable_auto_value;
pub mod entity_properties;
pub mod entity_tree;
mod instance_path;
pub mod log_db;
pub mod store_db;
mod util;

pub use entity_properties::*;
pub use entity_tree::*;
pub use instance_path::*;
pub use log_db::LogDb;
pub use store_db::StoreDb;
pub use util::*;

#[cfg(feature = "serde")]
Expand Down
8 changes: 4 additions & 4 deletions crates/re_data_store/src/log_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ impl EntityDb {
// ----------------------------------------------------------------------------

/// A in-memory database built from a stream of [`LogMsg`]es.
pub struct LogDb {
pub struct StoreDb {
/// The [`StoreId`] for this log.
store_id: StoreId,

/// All [`EntityPathOpMsg`]s ever received.
entity_op_msgs: BTreeMap<RowId, EntityPathOpMsg>,

/// Set by whomever created this [`LogDb`].
/// Set by whomever created this [`StoreDb`].
pub data_source: Option<re_smart_channel::SmartChannelSource>,

/// Comes in a special message, [`LogMsg::SetStoreInfo`].
Expand All @@ -188,7 +188,7 @@ pub struct LogDb {
pub entity_db: EntityDb,
}

impl LogDb {
impl StoreDb {
pub fn new(store_id: StoreId) -> Self {
Self {
store_id,
Expand Down Expand Up @@ -266,7 +266,7 @@ impl LogDb {
self.recording_msg = Some(msg.clone());
}

/// Returns an iterator over all [`EntityPathOpMsg`]s that have been written to this `LogDb`.
/// Returns an iterator over all [`EntityPathOpMsg`]s that have been written to this `StoreDb`.
pub fn iter_entity_op_msgs(&self) -> impl Iterator<Item = &EntityPathOpMsg> {
self.entity_op_msgs.values()
}
Expand Down
6 changes: 3 additions & 3 deletions crates/re_data_store/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use re_log_types::{
DataRow, DeserializableComponent, EntityPath, RowId, SerializableComponent, TimePoint, Timeline,
};

use crate::LogDb;
use crate::StoreDb;

// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -60,7 +60,7 @@ where

/// Store a single value for a given [`re_log_types::Component`].
pub fn store_one_component<C: SerializableComponent>(
log_db: &mut LogDb,
store_db: &mut StoreDb,
entity_path: &EntityPath,
timepoint: &TimePoint,
component: C,
Expand All @@ -74,7 +74,7 @@ pub fn store_one_component<C: SerializableComponent>(
);
row.compute_all_size_bytes();

match log_db.entity_db.try_add_data_row(&row) {
match store_db.entity_db.try_add_data_row(&row) {
Ok(()) => {}
Err(err) => {
re_log::warn_once!(
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/annotation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn annotation_info(
keypoint_id: &re_components::KeypointId,
) -> Option<re_components::AnnotationInfo> {
let class_id = ctx
.log_db
.store_db
.entity_db
.data_store
.query_latest_component::<ClassId>(entity_path, query)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/component_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl DataUi for ComponentPath {
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
) {
let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;

if let Some((_, component_data)) = re_query::get_component_with_instances(
store,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl DataUi for InstancePath {
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
) {
let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;

let Some(mut components) = store.all_components(&query.timeline, &self.entity_path) else {
ui.label(format!("No components in entity {}", self.entity_path));
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl SceneSpatial {
DefaultPoints,
}

let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;

// Use a BTreeSet for entity hashes to get a stable order.
let mut entities_per_draw_order = BTreeMap::<DrawOrder, BTreeSet<DrawOrderTarget>>::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl ScenePart for Arrows3DPart {
};

match query_primary_with_history::<Arrow3D, 5>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl ScenePart for Boxes2DPart {
};

match query_primary_with_history::<Rect2D, 6>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ScenePart for Boxes3DPart {
let entity_highlight = highlights.entity_outline_mask(ent_path.hash());

match query_primary_with_history::<Box3D, 8>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view_spatial/src/scene/scene_part/cameras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ impl ScenePart for CamerasPart {
) {
re_tracing::profile_scope!("CamerasPart");

let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;
for (ent_path, props) in query.iter_entities() {
let query = re_arrow_store::LatestAtQuery::new(query.timeline, query.latest_at);

if let Some(pinhole) = store.query_latest_component::<Pinhole>(ent_path, &query) {
let view_coordinates = determine_view_coordinates(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&ctx.rec_cfg.time_ctrl,
ent_path.clone(),
);
Expand Down
6 changes: 3 additions & 3 deletions crates/re_space_view_spatial/src/scene/scene_part/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl ImagesPart {
if *properties.backproject_depth.get() && tensor.meaning == TensorDataMeaning::Depth {
let query = ctx.current_query();
let closet_pinhole = ctx
.log_db
.store_db
.entity_db
.data_store
.query_latest_component_at_closest_ancestor::<Pinhole>(ent_path, &query);
Expand Down Expand Up @@ -261,7 +261,7 @@ impl ImagesPart {
) -> Result<(), String> {
re_tracing::profile_function!();

let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;
let Some(intrinsics) = store.query_latest_component::<Pinhole>(
pinhole_ent_path,
&ctx.current_query(),
Expand Down Expand Up @@ -392,7 +392,7 @@ impl ScenePart for ImagesPart {
};

match query_primary_with_history::<Tensor, 4>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl ScenePart for Lines2DPart {
let entity_highlight = highlights.entity_outline_mask(ent_path.hash());

match query_primary_with_history::<LineStrip2D, 4>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl ScenePart for Lines3DPart {
let entity_highlight = highlights.entity_outline_mask(ent_path.hash());

match query_primary_with_history::<LineStrip3D, 4>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl ScenePart for MeshPart {
};

match query_primary_with_history::<Mesh3D, 3>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl ScenePart for Points2DPart {
let entity_highlight = highlights.entity_outline_mask(ent_path.hash());

match query_primary_with_history::<Point2D, 7>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl ScenePart for Points3DPart {
let entity_highlight = highlights.entity_outline_mask(ent_path.hash());

match query_primary_with_history::<Point3D, 7>(
&ctx.log_db.entity_db.data_store,
&ctx.store_db.entity_db.data_store,
&query.timeline,
&query.latest_at,
&props.visible_history,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/transform_cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use nohash_hasher::IntMap;
use re_arrow_store::LatestAtQuery;
use re_components::{DisconnectedSpace, Pinhole, Transform3D};
use re_data_store::{log_db::EntityDb, EntityPath, EntityPropertyMap, EntityTree};
use re_data_store::{store_db::EntityDb, EntityPath, EntityPropertyMap, EntityTree};
use re_log_types::EntityPathHash;
use re_viewer_context::TimeControl;

Expand Down
10 changes: 5 additions & 5 deletions crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl ViewSpatialState {
query: &re_arrow_store::LatestAtQuery,
entity_path: &EntityPath,
) {
let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;
if store
.query_latest_component::<Pinhole>(entity_path, query)
.is_some()
Expand Down Expand Up @@ -191,7 +191,7 @@ impl ViewSpatialState {
query: &re_arrow_store::LatestAtQuery,
entity_path: &EntityPath,
) -> Option<()> {
let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;
let tensor = store.query_latest_component::<Tensor>(entity_path, query)?;

let mut properties = data_blueprint.data_blueprints_individual().get(entity_path);
Expand Down Expand Up @@ -389,7 +389,7 @@ impl ViewSpatialState {
}
self.scene_num_primitives = scene.primitives.num_primitives();

let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;
match *self.nav_mode.get() {
SpatialNavigationMode::ThreeD => {
let coordinates = store.query_latest_component(space, &ctx.current_query());
Expand Down Expand Up @@ -728,7 +728,7 @@ pub fn picking(
// TODO(#1818): Depth at pointer only works for depth images so far.
let mut depth_at_pointer = None;
for hit in &picking_result.hits {
let Some(mut instance_path) = hit.instance_path_hash.resolve(&ctx.log_db.entity_db)
let Some(mut instance_path) = hit.instance_path_hash.resolve(&ctx.store_db.entity_db)
else { continue; };

let ent_properties = entity_properties.get(&instance_path.entity_path);
Expand All @@ -740,7 +740,7 @@ pub fn picking(
let picked_image_with_coords = if hit.hit_type == PickingHitType::TexturedRect
|| *ent_properties.backproject_depth.get()
{
let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;
store
.query_latest_component::<Tensor>(&instance_path.entity_path, &ctx.current_query())
.and_then(|tensor| {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/ui_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub fn view_2d(
// Save off the available_size since this is used for some of the layout updates later
let available_size = ui.available_size();

let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;

// Determine the canvas which determines the extent of the explorable scene coordinates,
// and thus the size of the scroll area.
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_text/src/scene_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl SceneElementImpl for SceneText {
query: &SceneQuery<'_>,
state: &TextSpaceViewState,
) {
let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;

for entity_path in query.entity_paths {
let ent_path = entity_path;
Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view_text/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl ViewTextFilters {
row_log_levels,
} = self;

for timeline in ctx.log_db.timelines() {
for timeline in ctx.store_db.timelines() {
col_timelines.entry(*timeline).or_insert(true);
}

Expand All @@ -219,7 +219,7 @@ impl ViewTextFilters {

fn get_time_point(ctx: &ViewerContext<'_>, entry: &TextEntry) -> Option<TimePoint> {
if let Some(time_point) = ctx
.log_db
.store_db
.entity_db
.data_store
.get_msg_metadata(&entry.row_id)
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_text_box/src/scene_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl SceneElement for SceneTextBox {
query: &SceneQuery<'_>,
_state: &dyn SpaceViewState,
) {
let store = &ctx.log_db.entity_db.data_store;
let store = &ctx.store_db.entity_db.data_store;

for (ent_path, props) in query.iter_entities() {
if !props.visible {
Expand Down
Loading

0 comments on commit 603ab32

Please sign in to comment.