Struct re_log_types::DataRow

source ·
pub struct DataRow {
    pub row_id: RowId,
    pub timepoint: TimePoint,
    pub entity_path: EntityPath,
    pub cells: DataCellRow,
}
Expand description

A row’s worth of data, i.e. an event: a list of DataCells associated with an auto-generated RowId, a user-specified TimePoint and EntityPath, and an expected number of instances. This is the middle layer in our data model.

Behind the scenes, a DataRow is backed by a collection of independent DataCells which likely refer to unrelated/non-contiguous parts of the heap. Cloning a DataRow is not too costly but needs to be avoided on the happy path.

§Field visibility

To facilitate destructuring (let DataRow { .. } = row), all the fields in DataRow are public.

Modifying any of these fields from outside this crate is considered undefined behavior. Use the appropriate getters and setters instead.

§Layout

A row is a collection of cells where each cell can have an arbitrary number of instances: [[C1, C1, C1], [], [C3], [C4, C4, C4], …].

Consider this example:

let points: &[MyPoint] = &[[10.0, 10.0].into(), [20.0, 20.0].into()];
let colors: &[_] = &[MyColor::from_rgb(128, 128, 128)];
let labels: &[MyLabel] = &[];
let row = DataRow::from_cells3(row_id, timepoint, ent_path, (points, colors, labels));

A row has no arrow representation nor datatype of its own, as it is merely a collection of independent cells.

Visualized in the context of a larger table, it is simply a row of cells:

┌──────────────────────────────────┬─────────────────┬───────┐
│ Point2D                          ┆ Color           ┆ Text  │
╞══════════════════════════════════╪═════════════════╪═══════╡
│ [{x: 10, y: 10}, {x: 20, y: 20}] ┆ [2155905279]    ┆ []    │
└──────────────────────────────────┴─────────────────┴───────┘

§Example

let points: &[MyPoint] = &[MyPoint { x: 10.0, y: 10.0}, MyPoint { x: 20.0, y: 20.0 }];
let colors: &[_] = &[MyColor(0xff7f7f7f)];
let labels: &[MyLabel] = &[];

let row = DataRow::from_cells3(
    row_id,
    "a/b/c",
    timepoint,
    (points, colors, labels),
).unwrap();
eprintln!("{row}");

Fields§

§row_id: RowId

Auto-generated TUID, uniquely identifying this event and keeping track of the client’s wall-clock.

§timepoint: TimePoint

User-specified TimePoint for this event.

§entity_path: EntityPath

User-specified EntityPath for this event.

§cells: DataCellRow

The actual cells (== columns, == components).

Implementations§

source§

impl DataRow

source

pub fn from_archetype( row_id: RowId, timepoint: TimePoint, entity_path: EntityPath, as_components: &dyn AsComponents ) -> Result<Self>

Builds a new DataRow from anything implementing AsComponents.

source

pub fn from_component_batches<'a>( row_id: RowId, timepoint: TimePoint, entity_path: EntityPath, comp_batches: impl IntoIterator<Item = &'a dyn ComponentBatch> ) -> Result<Self>

Builds a new DataRow from anything implementing AsComponents.

source

pub fn from_cells( row_id: RowId, timepoint: impl Into<TimePoint>, entity_path: impl Into<EntityPath>, cells: impl IntoIterator<Item = DataCell> ) -> DataReadResult<Self>

Builds a new DataRow from an iterable of DataCells.

Fails if two or more cells share the same component type.

source

pub fn next(self) -> Self

Consumes the DataRow and returns a new one with an incremented RowId.

source

pub fn into_table(self) -> DataTable

Turns the DataRow into a single-row DataTable.

source§

impl DataRow

source

pub fn row_id(&self) -> RowId

source

pub fn timepoint(&self) -> &TimePoint

source

pub fn entity_path(&self) -> &EntityPath

source

pub fn num_cells(&self) -> usize

source

pub fn component_names( &self ) -> impl ExactSizeIterator<Item = ComponentName> + '_

source

pub fn cells(&self) -> &DataCellRow

source

pub fn into_cells(self) -> DataCellRow

source

pub fn find_cell(&self, component: &ComponentName) -> Option<usize>

Returns the index of the cell with the given component type in the row, if it exists.

This is O(n).

source

pub fn compute_all_size_bytes(&mut self)

Compute and cache the total (heap) allocated size of each individual underlying DataCell. This does nothing for cells whose size has already been computed and cached before.

Beware: this is very costly!

source§

impl DataRow

source

pub fn from_cells1_sized<C0>( row_id: RowId, entity_path: impl Into<EntityPath>, timepoint: impl Into<TimePoint>, into_cells: C0 ) -> DataReadResult<DataRow>
where C0: Into<DataCell>,

A helper that combines Self::from_cells1 followed by Self::compute_all_size_bytes.

See respective documentations for more information.

Beware: this is costly!

source

pub fn from_cells1<C0>( row_id: RowId, entity_path: impl Into<EntityPath>, timepoint: impl Into<TimePoint>, into_cells: C0 ) -> DataRowResult<DataRow>

source

pub fn from_cells2_sized<C0, C1>( row_id: RowId, entity_path: impl Into<EntityPath>, timepoint: impl Into<TimePoint>, into_cells: (C0, C1) ) -> DataRowResult<DataRow>
where C0: Into<DataCell>, C1: Into<DataCell>,

A helper that combines Self::from_cells2 followed by Self::compute_all_size_bytes.

See respective documentations for more information.

Beware: this is costly!

source

pub fn from_cells2<C0, C1>( row_id: RowId, entity_path: impl Into<EntityPath>, timepoint: impl Into<TimePoint>, into_cells: (C0, C1) ) -> DataRowResult<DataRow>

source

pub fn from_cells3<C0, C1, C2>( row_id: RowId, entity_path: impl Into<EntityPath>, timepoint: impl Into<TimePoint>, into_cells: (C0, C1, C2) ) -> DataRowResult<DataRow>

Trait Implementations§

source§

impl Clone for DataRow

source§

fn clone(&self) -> DataRow

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DataRow

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for DataRow

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl SizeBytes for DataRow

source§

fn heap_size_bytes(&self) -> u64

Returns the total size of self on the heap, in bytes.
source§

fn total_size_bytes(&self) -> u64

Returns the total size of self in bytes, accounting for both stack and heap space.
source§

fn stack_size_bytes(&self) -> u64

Returns the total size of self on the stack, in bytes. Read more
source§

fn is_pod() -> bool

Is Self just plain old data? Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.