pub struct EntityDb {
pub data_source: Option<SmartChannelSource>,
/* private fields */
}
Expand description
An in-memory database built from a stream of LogMsg
es.
NOTE: all mutation is to be done via public functions!
Fields§
§data_source: Option<SmartChannelSource>
Implementations§
Source§impl EntityDb
impl EntityDb
pub fn new(store_id: StoreId) -> Self
pub fn with_store_config( store_id: StoreId, store_config: ChunkStoreConfig, ) -> Self
pub fn tree(&self) -> &EntityTree
Sourcepub fn storage_engine(&self) -> StorageEngineReadGuard<'_>
pub fn storage_engine(&self) -> StorageEngineReadGuard<'_>
Returns a read-only guard to the backing StorageEngine
.
Sourcepub fn storage_engine_arc(&self) -> StorageEngineArcReadGuard
pub fn storage_engine_arc(&self) -> StorageEngineArcReadGuard
Returns a read-only guard to the backing StorageEngine
.
That guard can be cloned at will and has a static lifetime.
It is not possible to insert any more data in this EntityDb
until the returned guard,
and any clones, have been dropped.
pub fn store_info_msg(&self) -> Option<&SetStoreInfo>
pub fn store_info(&self) -> Option<&StoreInfo>
pub fn app_id(&self) -> Option<&ApplicationId>
Sourcepub fn latest_at(
&self,
query: &LatestAtQuery,
entity_path: &EntityPath,
component_names: impl IntoIterator<Item = ComponentName>,
) -> LatestAtResults
pub fn latest_at( &self, query: &LatestAtQuery, entity_path: &EntityPath, component_names: impl IntoIterator<Item = ComponentName>, ) -> LatestAtResults
Queries for the given component_names
using latest-at semantics.
See re_query::LatestAtResults
for more information about how to handle the results.
This is a cached API – data will be lazily cached upon access.
Sourcepub fn latest_at_component<C: Component>(
&self,
entity_path: &EntityPath,
query: &LatestAtQuery,
) -> Option<((TimeInt, RowId), C)>
pub fn latest_at_component<C: Component>( &self, entity_path: &EntityPath, query: &LatestAtQuery, ) -> Option<((TimeInt, RowId), C)>
Get the latest index and value for a given dense re_types_core::Component
.
This assumes that the row we get from the store contains at most one instance for this component; it will log a warning otherwise.
This should only be used for “mono-components” such as Transform
and Tensor
.
This is a best-effort helper, it will merely log errors on failure.
Sourcepub fn latest_at_component_quiet<C: Component>(
&self,
entity_path: &EntityPath,
query: &LatestAtQuery,
) -> Option<((TimeInt, RowId), C)>
pub fn latest_at_component_quiet<C: Component>( &self, entity_path: &EntityPath, query: &LatestAtQuery, ) -> Option<((TimeInt, RowId), C)>
Get the latest index and value for a given dense re_types_core::Component
.
This assumes that the row we get from the store contains at most one instance for this component; it will log a warning otherwise.
This should only be used for “mono-components” such as Transform
and Tensor
.
This is a best-effort helper, and will quietly swallow any errors.
pub fn latest_at_component_at_closest_ancestor<C: Component>( &self, entity_path: &EntityPath, query: &LatestAtQuery, ) -> Option<(EntityPath, (TimeInt, RowId), C)>
pub fn store_kind(&self) -> StoreKind
pub fn store_id(&self) -> StoreId
Sourcepub fn cloned_from(&self) -> Option<&StoreId>
pub fn cloned_from(&self) -> Option<&StoreId>
If this entity db is the result of a clone, which store was it cloned from?
A cloned store always gets a new unique ID.
We currently only use entity db cloning for blueprints: when we activate a default blueprint that was received on the wire (e.g. from a recording), we clone it and make the clone the active blueprint. This means all active blueprints are clones.
pub fn timelines(&self) -> impl ExactSizeIterator<Item = &Timeline>
pub fn times_per_timeline(&self) -> &TimesPerTimeline
pub fn has_any_data_on_timeline(&self, timeline: &Timeline) -> bool
Sourcepub fn time_range_for(&self, timeline: &Timeline) -> Option<ResolvedTimeRange>
pub fn time_range_for(&self, timeline: &Timeline) -> Option<ResolvedTimeRange>
Returns the time range of data on the given timeline, ignoring any static times.
Sourcepub fn time_histogram(&self, timeline: &Timeline) -> Option<&TimeHistogram>
pub fn time_histogram(&self, timeline: &Timeline) -> Option<&TimeHistogram>
Histogram of all events on the timeeline, of all entities.
pub fn num_rows(&self) -> u64
Sourcepub fn generation(&self) -> ChunkStoreGeneration
pub fn generation(&self) -> ChunkStoreGeneration
Return the current ChunkStoreGeneration
. This can be used to determine whether the
database has been modified since the last time it was queried.
pub fn last_modified_at(&self) -> Instant
Sourcepub fn latest_row_id(&self) -> Option<RowId>
pub fn latest_row_id(&self) -> Option<RowId>
The highest RowId
in the store,
which corresponds to the last edit time.
Ignores deletions.
pub fn is_empty(&self) -> bool
Sourcepub fn entity_paths(&self) -> Vec<&EntityPath>
pub fn entity_paths(&self) -> Vec<&EntityPath>
A sorted list of all the entity paths in this database.
pub fn ingestion_stats(&self) -> &IngestionStatistics
pub fn entity_path_from_hash( &self, entity_path_hash: &EntityPathHash, ) -> Option<&EntityPath>
Sourcepub fn is_known_entity(&self, entity_path: &EntityPath) -> bool
pub fn is_known_entity(&self, entity_path: &EntityPath) -> bool
Returns true
also for entities higher up in the hierarchy.
Sourcepub fn is_logged_entity(&self, entity_path: &EntityPath) -> bool
pub fn is_logged_entity(&self, entity_path: &EntityPath) -> bool
If you log world/points
, then that is a logged entity, but world
is not,
unless you log something to world
too.
pub fn add(&mut self, msg: &LogMsg) -> Result<Vec<ChunkStoreEvent>, Error>
pub fn add_chunk( &mut self, chunk: &Arc<Chunk>, ) -> Result<Vec<ChunkStoreEvent>, Error>
pub fn set_store_info(&mut self, store_info: SetStoreInfo)
pub fn gc_everything_but_the_latest_row_on_non_default_timelines( &mut self, ) -> Vec<ChunkStoreEvent>
Sourcepub fn purge_fraction_of_ram(
&mut self,
fraction_to_purge: f32,
) -> Vec<ChunkStoreEvent>
pub fn purge_fraction_of_ram( &mut self, fraction_to_purge: f32, ) -> Vec<ChunkStoreEvent>
Free up some RAM by forgetting the older parts of all timelines.
Sourcepub fn drop_time_range(
&mut self,
timeline: &Timeline,
drop_range: ResolvedTimeRange,
) -> Vec<ChunkStoreEvent>
pub fn drop_time_range( &mut self, timeline: &Timeline, drop_range: ResolvedTimeRange, ) -> Vec<ChunkStoreEvent>
Drop all events in the given time range from the given timeline.
Used to implement undo (erase the last event from the blueprint db).
Sourcepub fn drop_entity_path(&mut self, entity_path: &EntityPath)
pub fn drop_entity_path(&mut self, entity_path: &EntityPath)
Unconditionally drops all the data for a given EntityPath
.
This is not recursive. Children of this entity will not be affected.
To drop the entire subtree below an entity, see: Self::drop_entity_path_recursive
.
Sourcepub fn drop_entity_path_recursive(&mut self, entity_path: &EntityPath)
pub fn drop_entity_path_recursive(&mut self, entity_path: &EntityPath)
Unconditionally drops all the data for a given EntityPath
and all its children.
Sourcepub fn to_messages(
&self,
time_selection: Option<(Timeline, ResolvedTimeRangeF)>,
) -> impl Iterator<Item = ChunkResult<LogMsg>> + '_
pub fn to_messages( &self, time_selection: Option<(Timeline, ResolvedTimeRangeF)>, ) -> impl Iterator<Item = ChunkResult<LogMsg>> + '_
Export the contents of the current database to a sequence of messages.
If time_selection
is specified, then only data for that specific timeline over that
specific time range will be accounted for.
Source§impl EntityDb
impl EntityDb
§Stats
Sourcepub fn subtree_stats_static(
&self,
engine: &StorageEngineReadGuard<'_>,
entity_path: &EntityPath,
) -> ChunkStoreChunkStats
pub fn subtree_stats_static( &self, engine: &StorageEngineReadGuard<'_>, entity_path: &EntityPath, ) -> ChunkStoreChunkStats
Returns the stats for the static store of the entity and all its children, recursively.
This excludes temporal data.
Sourcepub fn subtree_stats_on_timeline(
&self,
engine: &StorageEngineReadGuard<'_>,
entity_path: &EntityPath,
timeline: &Timeline,
) -> ChunkStoreChunkStats
pub fn subtree_stats_on_timeline( &self, engine: &StorageEngineReadGuard<'_>, entity_path: &EntityPath, timeline: &Timeline, ) -> ChunkStoreChunkStats
Returns the stats for the entity and all its children on the given timeline, recursively.
This excludes static data.
Sourcepub fn subtree_has_data_on_timeline(
&self,
engine: &StorageEngineReadGuard<'_>,
timeline: &Timeline,
entity_path: &EntityPath,
) -> bool
pub fn subtree_has_data_on_timeline( &self, engine: &StorageEngineReadGuard<'_>, timeline: &Timeline, entity_path: &EntityPath, ) -> bool
Returns true if an entity or any of its children have any data on the given timeline.
This includes static data.
Sourcepub fn subtree_has_temporal_data_on_timeline(
&self,
engine: &StorageEngineReadGuard<'_>,
timeline: &Timeline,
entity_path: &EntityPath,
) -> bool
pub fn subtree_has_temporal_data_on_timeline( &self, engine: &StorageEngineReadGuard<'_>, timeline: &Timeline, entity_path: &EntityPath, ) -> bool
Returns true if an entity or any of its children have any temporal data on the given timeline.
This ignores static data.
Trait Implementations§
Source§impl SizeBytes for EntityDb
impl SizeBytes for EntityDb
Source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
self
on the heap, in bytes.Source§fn total_size_bytes(&self) -> u64
fn total_size_bytes(&self) -> u64
self
in bytes, accounting for both stack and heap space.Source§fn stack_size_bytes(&self) -> u64
fn stack_size_bytes(&self) -> u64
self
on the stack, in bytes. Read moreAuto Trait Implementations§
impl !Freeze for EntityDb
impl !RefUnwindSafe for EntityDb
impl Send for EntityDb
impl Sync for EntityDb
impl Unpin for EntityDb
impl !UnwindSafe for EntityDb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more