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 Datum
s (e.g. String
and
VarChar
).
TODO(parkmycar): Remove this once mz_persist_types::columnar::Schema2
and Stats are fully flushed out.
Required Associated Types§
Required Associated Constants§
Required Methods§
Provided Methods§
sourcefn encode_default(col: &mut <Self::Data as Data>::Mut)
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.