Skip to content

Conversation

@featzhang
Copy link
Member

@featzhang featzhang commented Dec 21, 2025

What is the purpose of the change

This PR adds ordered semantics to the async batch operator, building on top of:
PR1: Size-based batching (AsyncBatchWaitOperator)
PR2: Time-based batching (timeout flush)

For AI inference workloads and other batch-oriented async operations, users may require that output records maintain the same order as input records, even when async batch invocations complete out of order. This is essential for downstream processing that depends on ordering guarantees.

Brief change log

  • Add OrderedAsyncBatchWaitOperator - maintains ordering by assigning monotonic sequence numbers to each batch and emitting results strictly in sequence order
  • Add OrderedAsyncBatchWaitOperatorFactory - creates ordered operator instances
  • Add AsyncDataStream.orderedWaitBatch() API methods as entry points
  • Add comprehensive unit tests in OrderedAsyncBatchWaitOperatorTest

Verifying this change

This change added tests and can be verified as follows:

  • OrderedAsyncBatchWaitOperatorTest#testStrictOrderingGuarantee - verifies batches completing out-of-order still produce ordered output
  • OrderedAsyncBatchWaitOperatorTest#testBatchAndTimeoutTriggerWithOrdering - verifies ordering preserved across size and time triggered batches
  • OrderedAsyncBatchWaitOperatorTest#testExceptionPropagation - verifies exceptions are propagated correctly
  • OrderedAsyncBatchWaitOperatorTest#testDelayedAsyncCompletion - verifies delayed completions are handled correctly
  • OrderedAsyncBatchWaitOperatorTest#testManyBatchesOrdering - verifies sequence number handling for many batches

Does this pull request potentially affect one of the following parts

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @public(Evolving): yes (new API methods)
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? JavaDocs

@flinkbot
Copy link
Collaborator

flinkbot commented Dec 21, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

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