MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / constant_diff

Method constant_diff

src/expr/src/relation.rs:1076–1092  ·  view source on GitHub ↗

Constructs a constant collection from specific rows and schema, where each row can have an arbitrary multiplicity.

(rows: Vec<(Vec<Datum>, Diff)>, typ: ReprRelationType)

Source from the content-addressed store, hash-verified

1074 /// Constructs a constant collection from specific rows and schema, where
1075 /// each row can have an arbitrary multiplicity.
1076 pub fn constant_diff(rows: Vec<(Vec<Datum>, Diff)>, typ: ReprRelationType) -> Self {
1077 for (row, _diff) in &rows {
1078 for (datum, column_typ) in row.iter().zip_eq(typ.column_types.iter()) {
1079 assert!(
1080 datum.is_instance_of(column_typ),
1081 "Expected datum of type {:?}, got value {:?}",
1082 column_typ,
1083 datum
1084 );
1085 }
1086 }
1087 let rows = Ok(rows
1088 .into_iter()
1089 .map(move |(row, diff)| (Row::pack_slice(&row), diff))
1090 .collect());
1091 MirRelationExpr::Constant { rows, typ }
1092 }
1093
1094 /// If self is a constant, return the value and the type, otherwise `None`.
1095 /// Looks behind `ArrangeBy`s.

Callers

nothing calls this directly

Calls 4

iterMethod · 0.45
collectMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected