pub struct RawRecord {
    primary_key: RawRecordPrimaryKey,
    version: RecordVersion,
    record_bytes: Bytes,
}
Expand description

A wrapper around all information that can be determined about a record before serializing and deserializing it.

Primary key schema constraint

In Java Record Layer, by default all record types within a record store are interleaved within the same record extent. This behavior can be changed using RecordTypeKeyExpression Java class, which indicates that record type identifier should be contained at the start of the primary key, thereby partitioning the record extent by record type.

In our implementation, we require that all record types within a record store have the same RawRecordPrimaryKeySchema. While it is not handled by RawRecord type, our record extent will be also be partitioned by record type and that information would be contained at the beginning of RawRecordPrimaryKeySchema.

Additionally, using RawRecordPrimaryKeySchema constraints the flexibility of primary key schema for record types within a record store. It will require all record types to have the same primary key schema.

There are two workarounds possible here. One is to setup a unique secondary index for a particular field of the record type, effectively minicking primary key behavior. Another is to use a different record store altogether.

The motivation for choosing this approach is two fold.

Firstly, it avoids edge cases with split_helper where integer values are a part of a primary key tuple.

Assume that we allowed record types to have multiple primary key schemas.

Suppose we have two record types with primary key schemas of (int, ) and (int, int,). Given the way split_helper works, their split suffixes (-1, 0, etc.,) would overlap. Now if we had to delete a record with primary key of (1, ) we simply cannot issue a clear range on prefix (1, ) without verifying if key of the form (1, ..., ) exists. If any key of the form (1, ..., ) exists, then deleting key (1, ) would accidentally delete that key too.

Hence, we do not permit record types with multiple primary key schemas to avoid this class of problems.

Secondly, the RawRecordCursor implementation is aware of RawRecordPrimaryKeySchema. This means any RawRecord value returned by the cursor will always be well formed and any errors can be identified at the lowest level of abstraction.

Warning: This type is not meant to be public. We need to make this type public to support integration tests. Do not use this type in your code.

Fields§

§primary_key: RawRecordPrimaryKey§version: RecordVersion§record_bytes: Bytes

Implementations§

source§

impl RawRecord

source

pub fn into_parts(self) -> (RawRecordPrimaryKey, RecordVersion, Bytes)

Extract primary key, record version and record bytes from RawRecord.

Trait Implementations§

source§

impl Clone for RawRecord

source§

fn clone(&self) -> RawRecord

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 Cursor<RawRecord> for RawRecordCursor

source§

async fn next(&mut self) -> CursorResult<RawRecord>

Return the next RawRecord.

In regular state machines, where transitions are represented using event [guard] / action and we directly send the event to the state machine.

However, in this case, all side effect of reading from the database is managed by the driver loop (below) and we only use the state machine to manage state data.

When we are in a state where we can return data (or error), we exit the loop and return the data. This is managed by returning a Some(_: CursorResult<RawRecord>) value.

source§

fn collect(self) -> impl Future<Output = (Vec<T>, CursorError)> + Sendwhere Self: Sized + Send,

Drain the cursor pushing all emitted values into a collection.
source§

fn filter<F, Fut>( self, f: F ) -> impl Future<Output = CursorFilter<T, Self, F>> + Sendwhere Self: Sized + Send, F: FnMut(&T) -> Fut + Send, Fut: Future<Output = bool>,

Filters the values produced by this cursor according to the provided predicate. Read more
source§

fn map<U, F, Fut>( self, f: F ) -> impl Future<Output = CursorMap<T, Self, F>> + Sendwhere U: Send, Self: Sized + Send, F: FnMut(T) -> Fut + Send, Fut: Future<Output = U>,

Map this cursor’s items to a different type, returning a new cursor of the resulting type. Read more
source§

impl Debug for RawRecord

source§

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

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

impl From<(RawRecordPrimaryKey, RecordVersion, Bytes)> for RawRecord

source§

fn from( (primary_key, version, record_bytes): (RawRecordPrimaryKey, RecordVersion, Bytes) ) -> RawRecord

Converts to this type from the input type.
source§

impl PartialEq<RawRecord> for RawRecord

source§

fn eq(&self, other: &RawRecord) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for RawRecord

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.