Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 37 additions & 52 deletions src/compute/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ use crate::extensions::temporal_bucket::TemporalBucketing;
use crate::logging::compute::{
ComputeEvent, DataflowGlobal, LirMapping, LirMetadata, LogDataflowErrors, OperatorHydration,
};
use crate::render::columnar::{CollectionEdge, vec_to_columnar};
use crate::render::columnar::{
columnar_consolidate, columnar_negate, columnar_to_vec, concat_many, vec_to_columnar,
};
use crate::render::context::{ArrangementFlavor, Context};
use crate::render::errors::DataflowErrorSer;
use crate::typedefs::{ErrBatcher, ErrBuilder, ErrSpine, KeyBatcher, MzTimestamp};
Expand Down Expand Up @@ -379,7 +381,7 @@ pub fn build_compute_dataflow(
// columnar edge at the boundary. The batches are already
// consolidated, so this leaf-encode is non-consolidating.
let bundle = crate::render::CollectionBundle::from_edge(
CollectionEdge::Columnar(vec_to_columnar(oks.enter(region))),
vec_to_columnar(oks.enter(region)),
errs.enter(region),
);
// Associate collection bundle with the source identifier.
Expand Down Expand Up @@ -482,7 +484,7 @@ pub fn build_compute_dataflow(
// columnar edge at the boundary. The batches are already
// consolidated, so this leaf-encode is non-consolidating.
let bundle = crate::render::CollectionBundle::from_edge(
CollectionEdge::Columnar(vec_to_columnar(oks.enter_region(region))),
vec_to_columnar(oks.enter_region(region)),
errs.enter_region(region),
);
// Associate collection bundle with the source identifier.
Expand Down Expand Up @@ -677,10 +679,7 @@ where
// The filtered index collection is row-shaped. Encode it to
// the columnar edge at the boundary. It is already
// consolidated, so this leaf-encode is non-consolidating.
CollectionBundle::from_edge(
CollectionEdge::Columnar(vec_to_columnar(oks)),
errs,
)
CollectionBundle::from_edge(vec_to_columnar(oks), errs)
}
};
self.update_id(Id::Global(idx.on_id), bundle);
Expand Down Expand Up @@ -960,10 +959,7 @@ impl<'scope> Context<'scope, Product<mz_repr::Timestamp, PointStamp<u64>>> {
// iterative frontier or fixpoint behavior.
self.insert_id(
Id::Local(*id),
CollectionBundle::from_edge(
CollectionEdge::Columnar(vec_to_columnar(oks_collection)),
err_collection,
),
CollectionBundle::from_edge(vec_to_columnar(oks_collection), err_collection),
);
variables.insert(Id::Local(*id), (oks_v, err_v));
}
Expand All @@ -979,7 +975,7 @@ impl<'scope> Context<'scope, Product<mz_repr::Timestamp, PointStamp<u64>>> {
// We need to ensure that the raw collection exists, but do not have enough information
// here to cause that to happen.
let (oks, mut err) = bundle.collection.clone().unwrap();
let oks = oks.into_vec();
let oks = columnar_to_vec(oks);
decoded_oks.insert(id, oks.clone());
// Collapses what forward reads see. `err_v` below feeds reads rendered before this
// binding and is collapsed separately; without this, a `Get` in a later rec binding
Expand Down Expand Up @@ -1051,7 +1047,7 @@ impl<'scope> Context<'scope, Product<mz_repr::Timestamp, PointStamp<u64>>> {
self.insert_id(
Id::Local(id),
CollectionBundle::from_edge(
CollectionEdge::Columnar(vec_to_columnar(oks.leave_dynamic(level + 1))),
vec_to_columnar(oks.leave_dynamic(level + 1)),
err.leave_dynamic(level + 1),
),
);
Expand Down Expand Up @@ -1256,25 +1252,24 @@ impl<'scope, T: RenderTimestamp + MaybeBucketByTime> Context<'scope, T> {
// left distinct may become duplicates here; a
// `ConsolidatingColumnBuilder` folds those within the batch (the
// rows are already owned, so the give is a move into staging).
let ok_collection = CollectionEdge::Columnar(
rows.into_iter()
.filter_map(move |(row, mut time, diff)| {
time.advance_by(as_of_frontier.borrow());
if !until.less_equal(&time) {
Some((
row.0,
<T as Refines<mz_repr::Timestamp>>::to_inner(time),
diff,
))
} else {
None
}
})
.to_stream_with_builder::<_, ConsolidatingColumnBuilder<Row, T, Diff>>(
self.scope,
)
.as_collection(),
);
let ok_collection = rows
.into_iter()
.filter_map(move |(row, mut time, diff)| {
time.advance_by(as_of_frontier.borrow());
if !until.less_equal(&time) {
Some((
row.0,
<T as Refines<mz_repr::Timestamp>>::to_inner(time),
diff,
))
} else {
None
}
})
.to_stream_with_builder::<_, ConsolidatingColumnBuilder<Row, T, Diff>>(
self.scope,
)
.as_collection();

let mut error_time: mz_repr::Timestamp = Timestamp::minimum();
error_time.advance_by(self.as_of_frontier.borrow());
Expand Down Expand Up @@ -1397,7 +1392,7 @@ impl<'scope, T: RenderTimestamp + MaybeBucketByTime> Context<'scope, T> {
.collection
.clone()
.expect("Negate input must be an unarranged collection");
CollectionBundle::from_edge(oks.negate(), errs)
CollectionBundle::from_edge(columnar_negate(oks), errs)
}
Threshold {
input,
Expand Down Expand Up @@ -1431,23 +1426,21 @@ impl<'scope, T: RenderTimestamp + MaybeBucketByTime> Context<'scope, T> {
// Temporal bucketing operates on `Vec`: decode the edge
// into it, then re-encode the result so this Union input
// is a columnar edge like every other.
let os = os.into_vec();
CollectionEdge::Columnar(vec_to_columnar(
T::maybe_apply_temporal_bucketing(
os.inner,
self.as_of_frontier.clone(),
summary,
),
let os = columnar_to_vec(os);
vec_to_columnar(T::maybe_apply_temporal_bucketing(
os.inner,
self.as_of_frontier.clone(),
summary,
))
} else {
os
};
oks.push(os);
errs.push(es);
}
let oks = CollectionEdge::concat_many(self.scope, oks);
let oks = concat_many(self.scope, oks);
let oks = if consolidate_output {
oks.consolidate_named("UnionConsolidation")
columnar_consolidate(oks, "UnionConsolidation")
} else {
oks
};
Expand Down Expand Up @@ -1528,16 +1521,8 @@ impl<'scope, T: RenderTimestamp + MaybeBucketByTime> Context<'scope, T> {
.collection
.as_mut()
.expect("CollectionBundle invariant");
match oks {
CollectionEdge::Vec(c) => {
let stream = self.log_operator_hydration_inner(c.inner.clone(), lir_id);
*c = stream.as_collection();
}
CollectionEdge::Columnar(c) => {
let stream = self.log_operator_hydration_inner(c.inner.clone(), lir_id);
*c = stream.as_collection();
}
}
let stream = self.log_operator_hydration_inner(oks.inner.clone(), lir_id);
*oks = stream.as_collection();
}
}
}
Expand Down
Loading
Loading