Skip to content

Add batch, conflate, expand, and extrapolate Flow operators#417

Merged
adamw merged 2 commits intomasterfrom
add-batch-conflate-expand-extrapolate-operators
Feb 19, 2026
Merged

Add batch, conflate, expand, and extrapolate Flow operators#417
adamw merged 2 commits intomasterfrom
add-batch-conflate-expand-extrapolate-operators

Conversation

@adamw
Copy link
Copy Markdown
Member

@adamw adamw commented Feb 19, 2026

Summary

  • Adds batchWeighted as the core batching operator (weighted cost function with configurable seed/aggregate)
  • Adds batch (count-based, delegates to batchWeighted), conflate/conflateWithSeed (unbounded aggregation when downstream is slow)
  • Adds expand (iterator-based element expansion with freshness bias) and extrapolate (emits upstream elements then fills gaps with generated values)
  • Includes deterministic tests using locks/semaphores (no wall-clock timing dependencies)

Test plan

  • FlowOpsBatchTest — verifies count-based aggregation and empty flow
  • FlowOpsBatchWeightedTest — verifies pass-through, aggregation, maximal batch creation with custom cost, oversized element handling, empty flow, and error propagation from upstream/costFn/seed/aggregate
  • FlowOpsConflateTest — verifies conflate aggregation, pass-through, empty flow, error propagation, and conflateWithSeed with custom seed
  • FlowOpsExpandTest — verifies infinite/finite expanders, iterator replacement, gated upstream, empty flow, and error propagation from upstream/expander/iterator
  • FlowOpsExtrapolateTest — verifies repetition, element switching, initial value, pass-through, multi-value extrapolation, empty flow (with/without initial), and error propagation

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 19, 2026 15:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds four new Flow operators for controlling element emission rates and handling backpressure scenarios: batch/batchWeighted for aggregating elements when downstream is slow, conflate/conflateWithSeed for unbounded aggregation, expand for expanding elements via iterators with freshness bias, and extrapolate for filling gaps between upstream elements.

Changes:

  • Adds batchWeighted as the core batching operator with weighted cost function and configurable seed/aggregate functions
  • Adds batch, conflate, and conflateWithSeed as specialized variants delegating to batchWeighted
  • Adds expand for iterator-based element expansion favoring freshness over completeness
  • Adds extrapolate for emitting upstream elements followed by generated values to fill gaps

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/src/main/scala/ox/flow/FlowOps.scala Implements batchWeighted, batch, conflate, conflateWithSeed, expand, and extrapolate operators with proper async boundaries and error handling
core/src/test/scala/ox/flow/FlowOpsBatchTest.scala Tests count-based batching and empty flow handling
core/src/test/scala/ox/flow/FlowOpsBatchWeightedTest.scala Tests weighted batching with custom cost functions, maximal batch creation, oversized elements, and error propagation from all components
core/src/test/scala/ox/flow/FlowOpsConflateTest.scala Tests unbounded aggregation when downstream is busy, pass-through behavior, and custom seed aggregation
core/src/test/scala/ox/flow/FlowOpsExpandTest.scala Tests iterator expansion with receive-first bias, infinite/finite iterators, and error propagation from upstream/expander/iterator
core/src/test/scala/ox/flow/FlowOpsExtrapolateTest.scala Tests element repetition, iterator switching, initial value emission, and error propagation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adamw adamw force-pushed the add-batch-conflate-expand-extrapolate-operators branch from e201d2c to 4be94d4 Compare February 19, 2026 16:02
…ators

Implements backpressure-aware operators for aggregating, conflating, expanding,
and extrapolating flow elements based on downstream demand:

- batchWeighted: core operator that batches by weighted cost function
- batch: count-based batching (delegates to batchWeighted)
- conflate/conflateWithSeed: unbounded aggregation when downstream is slow
- expand: iterator-based element expansion with freshness bias
- extrapolate: emits upstream elements then fills gaps with generated values

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adamw adamw force-pushed the add-batch-conflate-expand-extrapolate-operators branch from 4be94d4 to 073ab30 Compare February 19, 2026 16:22
The parent flow error could propagate to childOutputChannel before
value 10 was picked up by the main loop's select, causing receive()
to see the error instead of the value. Fix by gating the error on
the test having received the value from the output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adamw adamw mentioned this pull request Feb 19, 2026
16 tasks
@adamw adamw merged commit 30e9419 into master Feb 19, 2026
6 checks passed
@adamw adamw deleted the add-batch-conflate-expand-extrapolate-operators branch February 19, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants