Struct re_data_store::DataStore
source · pub struct DataStore { /* private fields */ }
Expand description
A complete data store: covers all timelines, all entities, everything.
§Debugging
DataStore
provides a very thorough Display
implementation that makes it manageable to
know what’s going on internally.
For even more information, you can set RERUN_DATA_STORE_DISPLAY_SCHEMAS=1
in your
environment, which will result in additional schema information being printed out.
Implementations§
source§impl DataStore
impl DataStore
pub fn new(id: StoreId, config: DataStoreConfig) -> Self
pub fn id(&self) -> &StoreId
sourcepub fn insert_id_component_name() -> ComponentName
pub fn insert_id_component_name() -> ComponentName
The column name used for storing insert requests’ IDs alongside the data when manipulating dataframes.
sourcepub fn generation(&self) -> StoreGeneration
pub fn generation(&self) -> StoreGeneration
Return the current StoreGeneration
. This can be used to determine whether the
database has been modified since the last time it was queried.
sourcepub fn config(&self) -> &DataStoreConfig
pub fn config(&self) -> &DataStoreConfig
See DataStoreConfig
for more information about configuration.
sourcepub fn lookup_datatype(&self, component: &ComponentName) -> Option<&DataType>
pub fn lookup_datatype(&self, component: &ComponentName) -> Option<&DataType>
Lookup the arrow DataType
of a re_types_core::Component
in the internal
DataTypeRegistry
.
sourcepub fn oldest_time_per_timeline(&self) -> BTreeMap<Timeline, TimeInt>
pub fn oldest_time_per_timeline(&self) -> BTreeMap<Timeline, TimeInt>
The oldest time for which we have any data.
Ignores static data.
Useful to call after a gc.
sourcepub fn iter_indices(
&self
) -> impl ExactSizeIterator<Item = ((EntityPath, Timeline), &IndexedTable)>
pub fn iter_indices( &self ) -> impl ExactSizeIterator<Item = ((EntityPath, Timeline), &IndexedTable)>
Returns a read-only iterator over the raw indexed tables.
Do not use this to try and assert the internal state of the datastore.
source§impl DataStore
impl DataStore
sourcepub fn to_rows(&self) -> DataReadResult<Vec<DataRow>>
pub fn to_rows(&self) -> DataReadResult<Vec<DataRow>>
Serializes the entire datastore into one big sorted list of DataRow
.
Individual re_log_types::DataRow
s that were split apart due to bucketing are merged back together.
Beware: this is extremely costly, don’t use this in hot paths.
sourcepub fn to_data_table(&self) -> DataReadResult<DataTable>
pub fn to_data_table(&self) -> DataReadResult<DataTable>
Serializes the entire datastore into one big sorted DataTable
.
Individual re_log_types::DataRow
s that were split apart due to bucketing are merged back together.
Beware: this is extremely costly, don’t use this in hot paths.
sourcepub fn to_data_tables(
&self,
time_filter: Option<(Timeline, ResolvedTimeRange)>
) -> impl Iterator<Item = DataTable> + '_
pub fn to_data_tables( &self, time_filter: Option<(Timeline, ResolvedTimeRange)> ) -> impl Iterator<Item = DataTable> + '_
Serializes the entire datastore into an iterator of DataTable
s, where each table
corresponds 1-to-1 to an internal bucket.
source§impl DataStore
impl DataStore
sourcepub fn gc(
&mut self,
options: &GarbageCollectionOptions
) -> (Vec<StoreEvent>, DataStoreStats)
pub fn gc( &mut self, options: &GarbageCollectionOptions ) -> (Vec<StoreEvent>, DataStoreStats)
Triggers a garbage collection according to the desired target
.
Garbage collection’s performance is bounded by the number of buckets in each table (for
each RowId
, we have to find the corresponding bucket, which is roughly O(log(n))
) as
well as the number of rows in each of those buckets (for each RowId
, we have to sort the
corresponding bucket (roughly O(n*log(n))
) and then find the corresponding row (roughly
O(log(n))
.
The size of the data itself has no impact on performance.
Returns the list of RowId
s that were purged from the store.
§Semantics
Garbage collection works on a row-level basis and is driven by RowId
order,
i.e. the order defined by the clients’ wall-clocks, allowing it to drop data across
the different timelines in a fair, deterministic manner.
Similarly, out-of-order data is supported out of the box.
The garbage collector doesn’t deallocate data in and of itself: all it does is drop the
store’s internal references to that data (the DataCell
s), which will be deallocated once
their reference count reaches 0.
§Limitations
The garbage collector has limited support for latest-at semantics. The configuration option:
GarbageCollectionOptions::protect_latest
will protect the N latest values of each
component on each timeline. The only practical guarantee this gives is that a latest-at query
with a value of max-int will be unchanged. However, latest-at queries from other arbitrary
points in time may provide different results pre- and post- GC.
source§impl DataStore
impl DataStore
sourcepub fn insert_component<'a, C>(
&mut self,
entity_path: &EntityPath,
timepoint: &TimePoint,
component: C
)
pub fn insert_component<'a, C>( &mut self, entity_path: &EntityPath, timepoint: &TimePoint, component: C )
Stores a single value for a given re_types_core::Component
.
This is a best-effort helper, it will merely log errors on failure.
sourcepub fn insert_empty_component(
&mut self,
entity_path: &EntityPath,
timepoint: &TimePoint,
component: ComponentName
)
pub fn insert_empty_component( &mut self, entity_path: &EntityPath, timepoint: &TimePoint, component: ComponentName )
Stores a single empty value for a given re_types_core::ComponentName
.
This is a best-effort helper, it will merely log errors on failure.
source§impl DataStore
impl DataStore
sourcepub fn all_components(
&self,
timeline: &Timeline,
entity_path: &EntityPath
) -> Option<ComponentNameSet>
pub fn all_components( &self, timeline: &Timeline, entity_path: &EntityPath ) -> Option<ComponentNameSet>
Retrieve all the ComponentName
s that have been written to for a given EntityPath
on
the specified Timeline
.
Static components are always included in the results.
Returns None
if the entity doesn’t exist at all on this timeline
.
sourcepub fn entity_has_component(
&self,
timeline: &Timeline,
entity_path: &EntityPath,
component_name: &ComponentName
) -> bool
pub fn entity_has_component( &self, timeline: &Timeline, entity_path: &EntityPath, component_name: &ComponentName ) -> bool
Check whether a given entity has a specific ComponentName
either on the specified
timeline, or in its static data.
sourcepub fn entity_min_time(
&self,
timeline: &Timeline,
entity_path: &EntityPath
) -> Option<TimeInt>
pub fn entity_min_time( &self, timeline: &Timeline, entity_path: &EntityPath ) -> Option<TimeInt>
Find the earliest time at which something was logged for a given entity on the specified timeline.
Ignores static data.
sourcepub fn latest_at<const N: usize>(
&self,
query: &LatestAtQuery,
entity_path: &EntityPath,
primary: ComponentName,
component_names: &[ComponentName; N]
) -> Option<(TimeInt, RowId, [Option<DataCell>; N])>
pub fn latest_at<const N: usize>( &self, query: &LatestAtQuery, entity_path: &EntityPath, primary: ComponentName, component_names: &[ComponentName; N] ) -> Option<(TimeInt, RowId, [Option<DataCell>; N])>
Queries the datastore for the cells of the specified component_names
, as seen from the point
of view of the so-called primary
component.
Returns an array of DataCell
s (as well as the associated data time and RowId
, if
the data is temporal) on success.
Success is defined by one thing and one thing only: whether a cell could be found for the
primary
component.
The presence or absence of secondary components has no effect on the success criteria.
If the entity has static component data associated with it, it will unconditionally override any temporal component data.
sourcepub fn range<'a, const N: usize>(
&'a self,
query: &RangeQuery,
entity_path: &EntityPath,
component_names: [ComponentName; N]
) -> impl Iterator<Item = (TimeInt, RowId, [Option<DataCell>; N])> + 'a
pub fn range<'a, const N: usize>( &'a self, query: &RangeQuery, entity_path: &EntityPath, component_names: [ComponentName; N] ) -> impl Iterator<Item = (TimeInt, RowId, [Option<DataCell>; N])> + 'a
Iterates the datastore in order to return the cells of the specified component_names
for
the given time range.
For each and every relevant row that is found, the returned iterator will yield an array
that is filled with the cells of each and every component in component_names
, or None
if
said component is not available in that row.
This method cannot fail! If there’s no data to return, an empty iterator is returned.
⚠ Contrary to latest-at queries, range queries can and will yield multiple rows for a single timestamp if it happens to hold multiple entries.
If the entity has static component data associated with it, it will unconditionally override any temporal component data.
pub fn row_metadata( &self, row_id: &RowId ) -> Option<&(TimePoint, EntityPathHash)>
sourcepub fn sort_indices_if_needed(&self)
pub fn sort_indices_if_needed(&self)
Sort all unsorted indices in the store.
source§impl DataStore
impl DataStore
sourcepub fn sanity_check(&self) -> Result<(), SanityError>
pub fn sanity_check(&self) -> Result<(), SanityError>
Runs the sanity check suite for the entire datastore.
Returns an error if anything looks wrong.
source§impl DataStore
impl DataStore
sourcepub fn num_static_rows(&self) -> u64
pub fn num_static_rows(&self) -> u64
Returns the number of static rows stored across this entire store.
sourcepub fn static_size_bytes(&self) -> u64
pub fn static_size_bytes(&self) -> u64
Returns the size of the static data stored across this entire store.
sourcepub fn num_temporal_rows(&self) -> u64
pub fn num_temporal_rows(&self) -> u64
Returns the number of temporal index rows stored across this entire store, i.e. the sum of the number of rows across all of its temporal indexed tables.
sourcepub fn temporal_size_bytes(&self) -> u64
pub fn temporal_size_bytes(&self) -> u64
Returns the size of the temporal index data stored across this entire store, i.e. the sum of the size of the data stored across all of its temporal indexed tables, in bytes.
sourcepub fn num_temporal_buckets(&self) -> u64
pub fn num_temporal_buckets(&self) -> u64
Returns the number of temporal indexed buckets stored across this entire store.
sourcepub fn entity_stats(
&self,
timeline: Timeline,
entity_path_hash: EntityPathHash
) -> EntityStats
pub fn entity_stats( &self, timeline: Timeline, entity_path_hash: EntityPathHash ) -> EntityStats
Stats for a specific entity path on a specific timeline
source§impl DataStore
impl DataStore
sourcepub fn register_subscriber(
subscriber: Box<dyn StoreSubscriber>
) -> StoreSubscriberHandle
pub fn register_subscriber( subscriber: Box<dyn StoreSubscriber> ) -> StoreSubscriberHandle
Registers a StoreSubscriber
so it gets automatically notified when data gets added and/or
removed to/from a DataStore
.
Refer to StoreEvent
’s documentation for more information about these events.
§Scope
Registered StoreSubscriber
s are global scope: they get notified of all events from all
existing DataStore
s, including DataStore
s created after the subscriber was registered.
Use StoreEvent::store_id
to identify the source of an event.
§Late registration
Subscribers must be registered before a store gets created to guarantee that no events were missed.
StoreEvent::event_id
can be used to identify missing events.
§Ordering
The order in which registered subscribers are notified is undefined and will likely become concurrent in the future.
If you need a specific order across multiple subscribers, embed them into an orchestrating subscriber.
sourcepub fn with_subscriber<V: StoreSubscriber, T, F: FnMut(&V) -> T>(
StoreSubscriberHandle: StoreSubscriberHandle,
f: F
) -> Option<T>
pub fn with_subscriber<V: StoreSubscriber, T, F: FnMut(&V) -> T>( StoreSubscriberHandle: StoreSubscriberHandle, f: F ) -> Option<T>
Passes a reference to the downcasted subscriber to the given FnMut
callback.
Returns None
if the subscriber doesn’t exist or downcasting failed.
sourcepub fn with_subscriber_once<V: StoreSubscriber, T, F: FnOnce(&V) -> T>(
StoreSubscriberHandle: StoreSubscriberHandle,
f: F
) -> Option<T>
pub fn with_subscriber_once<V: StoreSubscriber, T, F: FnOnce(&V) -> T>( StoreSubscriberHandle: StoreSubscriberHandle, f: F ) -> Option<T>
Passes a reference to the downcasted subscriber to the given FnOnce
callback.
Returns None
if the subscriber doesn’t exist or downcasting failed.
sourcepub fn with_subscriber_mut<V: StoreSubscriber, T, F: FnMut(&mut V) -> T>(
StoreSubscriberHandle: StoreSubscriberHandle,
f: F
) -> Option<T>
pub fn with_subscriber_mut<V: StoreSubscriber, T, F: FnMut(&mut V) -> T>( StoreSubscriberHandle: StoreSubscriberHandle, f: F ) -> Option<T>
Passes a mutable reference to the downcasted subscriber to the given callback.
Returns None
if the subscriber doesn’t exist or downcasting failed.
source§impl DataStore
impl DataStore
sourcepub fn insert_row(&mut self, row: &DataRow) -> WriteResult<StoreEvent>
pub fn insert_row(&mut self, row: &DataRow) -> WriteResult<StoreEvent>
Inserts a DataRow
’s worth of components into the datastore.
Trait Implementations§
source§impl SizeBytes for DataStore
impl SizeBytes for DataStore
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 DataStore
impl !RefUnwindSafe for DataStore
impl Send for DataStore
impl Sync for DataStore
impl Unpin for DataStore
impl !UnwindSafe for DataStore
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