Trait mz_repr::row::encoding::DatumToPersist

source ·
pub trait DatumToPersist {
    type Data: Data<Cfg = Self::Cfg>;
    type Cfg: ColumnCfg<Self::Data>;

    const CFG: Self::Cfg;
    const STATS_FN: StatsFn;

    // Required methods
    fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>);
    fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>);

    // Provided method
    fn encode_default(col: &mut <Self::Data as Data>::Mut) { ... }
}
Expand description

Implementation of mapping between mz Datum and persist Data.

This always maps to and from a single persist columnar type, but it maps a set of Datum types. For example: any nullable ColumnType will map Datum::Null along with the type(s) corresponding to the ScalarType. Similarly, ScalarType::Jsonb maps to several Datum types.

See ColumnType::to_persist to map a ColumnType to this. There is a 1:N correspondence between DatumToPersist impls and ColumnTypes because a number of ScalarTypes map to the same set of Datums (e.g. String and VarChar).

TODO(parkmycar): Remove this once mz_persist_types::columnar::Schema2 and Stats are fully flushed out.

Required Associated Types§

source

type Data: Data<Cfg = Self::Cfg>

The persist columnar type we’re mapping to/from.

source

type Cfg: ColumnCfg<Self::Data>

Any information, in addition to the type of Self::Data, that is necessary to derive the columnar schema of this type. E.g. for ScalarType::Record, this will be the schema of the record.

Required Associated Constants§

source

const CFG: Self::Cfg

source

const STATS_FN: StatsFn

Which logic to use for computing aggregate stats.

Required Methods§

source

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

Encodes and pushes the given Datum into the persist column.

Panics if the Datum doesn’t match the persist column type.

source

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

Decodes the data with the given reference into a Datum. This Datum is returned by pushing it in to the given RowPacker.

Provided Methods§

source

fn encode_default(col: &mut <Self::Data as Data>::Mut)

Pushes the default value for this type into the column.

NB: This is because Arrow’s optional struct array representation is “dense”. Even for entries in where the struct’s validity bit is false, we still have to encode some ignored value. Unfortunately, we can’t just call Self::encode with a Datum::Null without tripping up some (useful) debug assertions. Feel free to remove this method if you can find a nice way to do it.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl DatumToPersist for Option<bool>

§

type Data = Option<bool>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<f32>

§

type Data = Option<f32>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<f64>

§

type Data = Option<f64>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<i16>

§

type Data = Option<i16>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<i32>

§

type Data = Option<i32>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<i64>

§

type Data = Option<i64>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<u8>

§

type Data = Option<u8>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<u16>

§

type Data = Option<u16>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<u32>

§

type Data = Option<u32>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<u64>

§

type Data = Option<u64>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<Date>

§

type Data = Option<i32>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<Jsonb>

§

type Data = <NullableProtoDatumToPersist as DatumToPersist>::Data

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = _

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<Timestamp>

§

type Data = Option<u64>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<String>

§

type Data = Option<String>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Option<Vec<u8>>

§

type Data = Option<Vec<u8>>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for bool

§

type Data = bool

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for f32

§

type Data = f32

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for f64

§

type Data = f64

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for i16

§

type Data = i16

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for i32

§

type Data = i32

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for i64

§

type Data = i64

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for u8

§

type Data = u8

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for u16

§

type Data = u16

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for u32

§

type Data = u32

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for u64

§

type Data = u64

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for String

§

type Data = String

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

source§

impl DatumToPersist for Vec<u8>

§

type Data = Vec<u8>

§

type Cfg = ()

source§

const CFG: Self::Cfg = ()

source§

const STATS_FN: StatsFn = StatsFn::Default

source§

fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)

source§

fn decode(val: <Self::Data as Data>::Ref<'_>, row: &mut RowPacker<'_>)

Implementors§