Struct mz_persist::indexed::columnar::ColumnarRecords
source · pub struct ColumnarRecords {
len: usize,
key_data: BinaryArray,
val_data: BinaryArray,
timestamps: Int64Array,
diffs: Int64Array,
}
Expand description
A set of ((Key, Val), Time, Diff) records stored in a columnar representation.
Note that the data are unsorted, and unconsolidated (so there may be multiple instances of the same ((Key, Val), Time), and some Diffs might be zero, or add up to zero).
Both Time and Diff are presented externally to persist users as a type parameter that implements mz_persist_types::Codec64. Our columnar format intentionally stores them both as i64 columns (as opposed to something like a fixed width binary column) because this allows us additional compression options.
Also note that we intentionally use an i64 over a u64 for Time. Over the
range [0, i64::MAX]
, the bytes are the same and we’ve talked at various
times about changing Time in mz to an i64. Both millis since unix epoch and
nanos since unix epoch easily fit into this range (the latter until some
time after year 2200). Using a i64 might be a pessimization for a
non-realtime mz source with u64 timestamps in the range (i64::MAX, u64::MAX]
, but realtime sources are overwhelmingly the common case.
Invariants:
- len <= u32::MAX (since we use arrow’s
BinaryArray
for our binary data) - the length of all arrays should == len
- all entries should be non-null
Fields§
§len: usize
§key_data: BinaryArray
§val_data: BinaryArray
§timestamps: Int64Array
§diffs: Int64Array
Implementations§
source§impl ColumnarRecords
impl ColumnarRecords
sourcepub fn new(
key_data: BinaryArray,
val_data: BinaryArray,
timestamps: Int64Array,
diffs: Int64Array,
) -> Self
pub fn new( key_data: BinaryArray, val_data: BinaryArray, timestamps: Int64Array, diffs: Int64Array, ) -> Self
Construct a columnar records instance from the given arrays, checking invariants.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The number of (potentially duplicated) ((Key, Val), Time, i64) records stored in Self.
sourcepub fn keys(&self) -> &BinaryArray
pub fn keys(&self) -> &BinaryArray
The keys in this columnar records as an array.
sourcepub fn vals(&self) -> &BinaryArray
pub fn vals(&self) -> &BinaryArray
The vals in this columnar records as an array.
sourcepub fn timestamps(&self) -> &Int64Array
pub fn timestamps(&self) -> &Int64Array
The timestamps in this columnar records as an array.
sourcepub fn diffs(&self) -> &Int64Array
pub fn diffs(&self) -> &Int64Array
The diffs in this columnar records as an array.
sourcepub fn goodbytes(&self) -> usize
pub fn goodbytes(&self) -> usize
The number of logical bytes in the represented data, excluding offsets and lengths.
sourcepub fn get<'a>(
&'a self,
idx: usize,
) -> Option<((&'a [u8], &'a [u8]), [u8; 8], [u8; 8])>
pub fn get<'a>( &'a self, idx: usize, ) -> Option<((&'a [u8], &'a [u8]), [u8; 8], [u8; 8])>
Read the record at idx
, if there is one.
Returns None if idx >= self.len()
.
sourcefn borrow<'a>(&'a self) -> ColumnarRecordsRef<'a>
fn borrow<'a>(&'a self) -> ColumnarRecordsRef<'a>
Borrow Self as a ColumnarRecordsRef.
sourcepub fn iter<'a>(&'a self) -> ColumnarRecordsIter<'a> ⓘ
pub fn iter<'a>(&'a self) -> ColumnarRecordsIter<'a> ⓘ
Iterate through the records in Self.
sourcepub fn concat(
records: &[ColumnarRecords],
metrics: &ColumnarMetrics,
) -> ColumnarRecords
pub fn concat( records: &[ColumnarRecords], metrics: &ColumnarMetrics, ) -> ColumnarRecords
Concatenate the given records together, column-by-column.
source§impl ColumnarRecords
impl ColumnarRecords
sourcepub fn from_proto(
lgbytes: &ColumnarMetrics,
proto: ProtoColumnarRecords,
) -> Result<(Self, Option<ColumnarRecordsStructuredExt>), TryFromProtoError>
pub fn from_proto( lgbytes: &ColumnarMetrics, proto: ProtoColumnarRecords, ) -> Result<(Self, Option<ColumnarRecordsStructuredExt>), TryFromProtoError>
See RustType::from_proto.
Trait Implementations§
source§impl Clone for ColumnarRecords
impl Clone for ColumnarRecords
source§fn clone(&self) -> ColumnarRecords
fn clone(&self) -> ColumnarRecords
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ColumnarRecords
impl Debug for ColumnarRecords
source§impl Default for ColumnarRecords
impl Default for ColumnarRecords
source§impl PartialEq for ColumnarRecords
impl PartialEq for ColumnarRecords
impl StructuralPartialEq for ColumnarRecords
Auto Trait Implementations§
impl Freeze for ColumnarRecords
impl RefUnwindSafe for ColumnarRecords
impl Send for ColumnarRecords
impl Sync for ColumnarRecords
impl Unpin for ColumnarRecords
impl UnwindSafe for ColumnarRecords
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> 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
)source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> 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<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ProgressEventTimestamp for T
impl<T> ProgressEventTimestamp for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.