Struct rerun::sdk::log::TransportChunk
source · pub struct TransportChunk {
batch: RecordBatch,
}
Expand description
A Chunk
that is ready for transport. Obtained by calling Chunk::to_transport
.
It contains a schema with a matching number of columns, all of the same length.
This is just a wrapper around an ArrowRecordBatch
, with some helper functions on top.
It can be converted to and from ArrowRecordBatch
without overhead.
Use the Display
implementation to dump the chunk as a nicely formatted table.
This has a stable ABI! The entire point of this type is to allow users to send raw arrow data into Rerun. This means we have to be very careful when checking the validity of the data: slipping corrupt data into the store could silently break all the index search logic (e.g. think of a chunk claiming to be sorted while it is in fact not).
Fields§
§batch: RecordBatch
Implementations§
source§impl TransportChunk
impl TransportChunk
sourcepub const CHUNK_METADATA_KEY_ID: &'static str = "rerun.id"
pub const CHUNK_METADATA_KEY_ID: &'static str = "rerun.id"
The key used to identify a Rerun ChunkId
in chunk-level ArrowSchema
metadata.
sourcepub const CHUNK_METADATA_KEY_ENTITY_PATH: &'static str = "rerun.entity_path"
pub const CHUNK_METADATA_KEY_ENTITY_PATH: &'static str = "rerun.entity_path"
The key used to identify a Rerun EntityPath
in chunk-level ArrowSchema
metadata.
sourcepub const CHUNK_METADATA_KEY_HEAP_SIZE_BYTES: &'static str = "rerun.heap_size_bytes"
pub const CHUNK_METADATA_KEY_HEAP_SIZE_BYTES: &'static str = "rerun.heap_size_bytes"
The key used to identify the size in bytes of the data, once loaded in memory, in chunk-level
ArrowSchema
metadata.
sourcepub const CHUNK_METADATA_MARKER_IS_SORTED_BY_ROW_ID: &'static str = "rerun.is_sorted"
pub const CHUNK_METADATA_MARKER_IS_SORTED_BY_ROW_ID: &'static str = "rerun.is_sorted"
The marker used to identify whether a chunk is sorted in chunk-level ArrowSchema
metadata.
The associated value is irrelevant – if this marker is present, then it is true.
Chunks are ascendingly sorted by their RowId
column.
sourcepub const FIELD_METADATA_KEY_KIND: &'static str = "rerun.kind"
pub const FIELD_METADATA_KEY_KIND: &'static str = "rerun.kind"
The key used to identify the kind of a Rerun column in field-level ArrowSchema
metadata.
That is: control columns (e.g. row_id
), time columns or component columns.
sourcepub const FIELD_METADATA_VALUE_KIND_TIME: &'static str = "time"
pub const FIELD_METADATA_VALUE_KIND_TIME: &'static str = "time"
The value used to identify a Rerun time column in field-level ArrowSchema
metadata.
sourcepub const FIELD_METADATA_VALUE_KIND_CONTROL: &'static str = "control"
pub const FIELD_METADATA_VALUE_KIND_CONTROL: &'static str = "control"
The value used to identify a Rerun control column in field-level ArrowSchema
metadata.
sourcepub const FIELD_METADATA_VALUE_KIND_DATA: &'static str = "data"
pub const FIELD_METADATA_VALUE_KIND_DATA: &'static str = "data"
The value used to identify a Rerun data column in field-level ArrowSchema
metadata.
sourcepub const FIELD_METADATA_KEY_ARCHETYPE_NAME: &'static str = "rerun.archetype_name"
pub const FIELD_METADATA_KEY_ARCHETYPE_NAME: &'static str = "rerun.archetype_name"
The key used to identify the crate::ArchetypeName
in field-level ArrowSchema
metadata.
sourcepub const FIELD_METADATA_KEY_ARCHETYPE_FIELD_NAME: &'static str = "rerun.archetype_field_name"
pub const FIELD_METADATA_KEY_ARCHETYPE_FIELD_NAME: &'static str = "rerun.archetype_field_name"
The key used to identify the crate::ArchetypeFieldName
in field-level ArrowSchema
metadata.
sourcepub const FIELD_METADATA_MARKER_IS_SORTED_BY_TIME: &'static str = Self::CHUNK_METADATA_MARKER_IS_SORTED_BY_ROW_ID
pub const FIELD_METADATA_MARKER_IS_SORTED_BY_TIME: &'static str = Self::CHUNK_METADATA_MARKER_IS_SORTED_BY_ROW_ID
The marker used to identify whether a column is sorted in field-level ArrowSchema
metadata.
The associated value is irrelevant – if this marker is present, then it is true.
Chunks are ascendingly sorted by their RowId
column but, depending on whether the data
was logged out of order or not for a given time column, that column might follow the global
RowId
while still being unsorted relative to its own time order.
sourcepub fn chunk_metadata_id(id: ChunkId) -> HashMap<String, String>
pub fn chunk_metadata_id(id: ChunkId) -> HashMap<String, String>
Returns the appropriate chunk-level ArrowSchema
metadata for a Rerun ChunkId
.
sourcepub fn chunk_metadata_heap_size_bytes(
heap_size_bytes: u64,
) -> HashMap<String, String>
pub fn chunk_metadata_heap_size_bytes( heap_size_bytes: u64, ) -> HashMap<String, String>
Returns the appropriate chunk-level ArrowSchema
metadata for the in-memory size in bytes.
sourcepub fn chunk_metadata_entity_path(
entity_path: &EntityPath,
) -> HashMap<String, String>
pub fn chunk_metadata_entity_path( entity_path: &EntityPath, ) -> HashMap<String, String>
Returns the appropriate chunk-level ArrowSchema
metadata for a Rerun EntityPath
.
sourcepub fn chunk_metadata_is_sorted() -> HashMap<String, String>
pub fn chunk_metadata_is_sorted() -> HashMap<String, String>
Returns the appropriate chunk-level ArrowSchema
metadata for an IS_SORTED
marker.
sourcepub fn field_metadata_time_column() -> HashMap<String, String>
pub fn field_metadata_time_column() -> HashMap<String, String>
Returns the appropriate field-level ArrowSchema
metadata for a Rerun time column.
sourcepub fn field_metadata_control_column() -> HashMap<String, String>
pub fn field_metadata_control_column() -> HashMap<String, String>
Returns the appropriate field-level ArrowSchema
metadata for a Rerun control column.
sourcepub fn field_metadata_data_column() -> HashMap<String, String>
pub fn field_metadata_data_column() -> HashMap<String, String>
Returns the appropriate field-level ArrowSchema
metadata for a Rerun data column.
sourcepub fn field_metadata_is_sorted() -> HashMap<String, String>
pub fn field_metadata_is_sorted() -> HashMap<String, String>
Returns the appropriate field-level ArrowSchema
metadata for an IS_SORTED
marker.
pub fn field_metadata_component_descriptor( component_desc: &ComponentDescriptor, ) -> HashMap<String, String>
pub fn component_descriptor_from_field(field: &Field) -> ComponentDescriptor
source§impl TransportChunk
impl TransportChunk
pub fn id(&self) -> Result<ChunkId, ChunkError>
pub fn entity_path(&self) -> Result<EntityPath, ChunkError>
sourcepub fn heap_size_bytes(&self) -> Option<u64>
pub fn heap_size_bytes(&self) -> Option<u64>
The size in bytes of the data, once loaded in memory, in chunk-level.
This is stored in the metadata. Returns None
if that key is not set.
pub fn fields(&self) -> &Fields
pub fn metadata(&self) -> &HashMap<String, String>
sourcepub fn is_sorted(&self) -> bool
pub fn is_sorted(&self) -> bool
Looks in the chunk metadata for the IS_SORTED
marker.
It is possible that a chunk is sorted but didn’t set that marker. This is fine, although wasteful.
sourcepub fn controls(&self) -> impl Iterator<Item = (&Field, &Arc<dyn Array>)>
pub fn controls(&self) -> impl Iterator<Item = (&Field, &Arc<dyn Array>)>
Iterates all control columns present in this chunk.
sourcepub fn components(&self) -> impl Iterator<Item = (&Field, &Arc<dyn Array>)>
pub fn components(&self) -> impl Iterator<Item = (&Field, &Arc<dyn Array>)>
Iterates all data columns present in this chunk.
sourcepub fn timelines(&self) -> impl Iterator<Item = (&Field, &Arc<dyn Array>)>
pub fn timelines(&self) -> impl Iterator<Item = (&Field, &Arc<dyn Array>)>
Iterates all timeline columns present in this chunk.
pub fn num_controls(&self) -> usize
pub fn num_timelines(&self) -> usize
pub fn num_components(&self) -> usize
Methods from Deref<Target = RecordBatch>§
pub fn schema_ref(&self) -> &Arc<Schema>
pub fn schema_ref(&self) -> &Arc<Schema>
Returns a reference to the Schema
of the record batch.
pub fn project(&self, indices: &[usize]) -> Result<RecordBatch, ArrowError>
pub fn project(&self, indices: &[usize]) -> Result<RecordBatch, ArrowError>
Projects the schema onto the specified columns
pub fn num_columns(&self) -> usize
pub fn num_columns(&self) -> usize
Returns the number of columns in the record batch.
§Example
let id_array = Int32Array::from(vec![1, 2, 3, 4, 5]);
let schema = Schema::new(vec![
Field::new("id", DataType::Int32, false)
]);
let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(id_array)]).unwrap();
assert_eq!(batch.num_columns(), 1);
pub fn num_rows(&self) -> usize
pub fn num_rows(&self) -> usize
Returns the number of rows in each column.
§Example
let id_array = Int32Array::from(vec![1, 2, 3, 4, 5]);
let schema = Schema::new(vec![
Field::new("id", DataType::Int32, false)
]);
let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(id_array)]).unwrap();
assert_eq!(batch.num_rows(), 5);
pub fn column_by_name(&self, name: &str) -> Option<&Arc<dyn Array>>
pub fn column_by_name(&self, name: &str) -> Option<&Arc<dyn Array>>
Get a reference to a column’s array by name.
pub fn slice(&self, offset: usize, length: usize) -> RecordBatch
pub fn slice(&self, offset: usize, length: usize) -> RecordBatch
Return a new RecordBatch where each column is sliced
according to offset
and length
§Panics
Panics if offset
with length
is greater than column length.
pub fn get_array_memory_size(&self) -> usize
pub fn get_array_memory_size(&self) -> usize
Returns the total number of bytes of memory occupied physically by this batch.
Note that this does not always correspond to the exact memory usage of a
RecordBatch
(might overestimate), since multiple columns can share the same
buffers or slices thereof, the memory used by the shared buffers might be
counted multiple times.
Trait Implementations§
source§impl AsRef<RecordBatch> for TransportChunk
impl AsRef<RecordBatch> for TransportChunk
source§fn as_ref(&self) -> &RecordBatch
fn as_ref(&self) -> &RecordBatch
source§impl Clone for TransportChunk
impl Clone for TransportChunk
source§fn clone(&self) -> TransportChunk
fn clone(&self) -> TransportChunk
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TransportChunk
impl Debug for TransportChunk
source§impl Deref for TransportChunk
impl Deref for TransportChunk
§type Target = RecordBatch
type Target = RecordBatch
source§fn deref(&self) -> &RecordBatch
fn deref(&self) -> &RecordBatch
source§impl Display for TransportChunk
impl Display for TransportChunk
source§impl From<RecordBatch> for TransportChunk
impl From<RecordBatch> for TransportChunk
source§fn from(batch: RecordBatch) -> TransportChunk
fn from(batch: RecordBatch) -> TransportChunk
source§impl From<TransportChunk> for RecordBatch
impl From<TransportChunk> for RecordBatch
source§fn from(chunk: TransportChunk) -> RecordBatch
fn from(chunk: TransportChunk) -> RecordBatch
Auto Trait Implementations§
impl Freeze for TransportChunk
impl !RefUnwindSafe for TransportChunk
impl Send for TransportChunk
impl Sync for TransportChunk
impl Unpin for TransportChunk
impl !UnwindSafe for TransportChunk
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.