Skip to content

Fuel flat_map #32410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
17 changes: 14 additions & 3 deletions src/compute/src/render/flat_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ where
let (ok_collection, err_collection) =
input.as_specific_collection(input_key.as_deref(), &self.config_set);
let stream = ok_collection.inner;
let (oks, errs) = stream.unary_fallible(Pipeline, "FlatMapStage", move |_, _| {
let scope = input.scope();
let (oks, errs) = stream.unary_fallible(Pipeline, "FlatMapStage", move |_, info| {
let activator = scope.activator_for(info.address);
Box::new(move |input, ok_output, err_output| {
let mut datums = DatumVec::new();
let mut datums_mfp = DatumVec::new();

// Buffer for extensions to `input_row`.
let mut table_func_output = Vec::new();

input.for_each(|cap, data| {
let mut budget = 1_000_000;

while let Some((cap, data)) = input.next() {
let mut ok_session = ok_output.session_with_builder(&cap);
let mut err_session = err_output.session_with_builder(&cap);

Expand Down Expand Up @@ -94,11 +98,16 @@ where
&until,
&mut ok_session,
&mut err_session,
&mut budget,
);
table_func_output.clear();
}
}
})
if budget == 0 {
activator.activate();
break;
}
}
})
});

Expand Down Expand Up @@ -131,6 +140,7 @@ fn drain_through_mfp<T>(
ConsolidatingContainerBuilder<Vec<(DataflowError, T, Diff)>>,
Counter<T, Vec<(DataflowError, T, Diff)>, Tee<T, Vec<(DataflowError, T, Diff)>>>,
>,
budget: &mut usize,
) where
T: crate::render::RenderTimestamp,
<T as Columnar>::Container: Clone + Send,
Expand Down Expand Up @@ -160,6 +170,7 @@ fn drain_through_mfp<T>(
);

for result in results {
*budget = budget.saturating_sub(1);
match result {
Ok((row, event_time, diff)) => {
// Copy the whole time, and re-populate event time.
Expand Down