Skip to content

update transform catalogue docs#38457

Open
ganesh-skumar wants to merge 5 commits into
apache:masterfrom
ganesh-skumar:update-docs
Open

update transform catalogue docs#38457
ganesh-skumar wants to merge 5 commits into
apache:masterfrom
ganesh-skumar:update-docs

Conversation

@ganesh-skumar
Copy link
Copy Markdown
Contributor

@ganesh-skumar ganesh-skumar commented May 12, 2026

  1. Adds BatchElements transform to Beam website docs.
  2. Update fix for code that was overriding window in BatchElements

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@ganesh-skumar ganesh-skumar marked this pull request as ready for review May 12, 2026 11:33
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the documentation for the BatchElements transform by adding a dedicated page to the Apache Beam website and providing a clear, runnable Java example. These additions aim to improve user understanding and adoption of this transform. Additionally, a minor but important correction was made to the BatchElements SDK implementation to ensure correct windowing behavior by explicitly setting pane information when outputting batched elements.

Highlights

  • Documentation Update: Added a new documentation page for the BatchElements transform on the Beam website, including a practical Java example.
  • Example Code: Introduced a new Java example (BatchElementsExample.java) to demonstrate the usage of the BatchElements transform, configured with minimum and maximum batch sizes.
  • SDK Implementation Detail: Updated the internal implementation of the BatchElements transform in the Java SDK to correctly use outputWindowedValue with PaneInfo.NO_FIRING for proper windowing and pane information.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new BatchElements example and documentation to the Java SDK, along with a change to the core transform's output mechanism. The review identifies a potential compilation error in the core SDK where outputWindowedValue is called on an incompatible interface. Other feedback includes recommendations to use modern Beam practices like parameter injection and improved pipeline option initialization in the examples, as well as a minor typo fix in the documentation.

Comment on lines +574 to +578
receiver.outputWindowedValue(
targetBatch.elements,
targetWindow.maxTimestamp(),
singleton(targetWindow),
PaneInfo.NO_FIRING);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The OutputReceiver interface in the Apache Beam Java SDK does not currently have an outputWindowedValue method. This method is available on DoFn.ProcessContext, but using ProcessContext is generally deprecated in favor of parameter injection. If the intention is to explicitly set the window and pane info (which is necessary if the batch is being emitted for a window other than the one currently in context), you may need to use ProcessContext for this specific DoFn, or ensure that the OutputReceiver interface is updated to support this method. As it stands, this code will likely fail to compile.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


public class BatchElementsExample {
public static void main(String[] args) {
PipelineOptions options = PipelineOptionsFactory.create();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

It is recommended to use PipelineOptionsFactory.fromArgs(args).withValidation().create() instead of PipelineOptionsFactory.create(). This allows users to pass command-line arguments, such as --runner, to configure the pipeline execution when running the example.

Suggested change
PipelineOptions options = PipelineOptionsFactory.create();
PipelineOptions options = PipelineOptionsFactory.fromArgs(args).withValidation().create();

Comment on lines +71 to +79
public void processElement(ProcessContext c) throws Exception {
List<String> batch = c.element();

LOG.info("Batch Contents: {}", batch);

for (String element : batch) {
c.output(element);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

In modern Beam, it is preferred to use parameter injection (e.g., @Element and OutputReceiver) instead of the ProcessContext object. Additionally, the throws Exception clause is unnecessary here as no checked exceptions are thrown in the method body.

    public void processElement(@Element List<String> batch, OutputReceiver<String> receiver) {
      LOG.info("Batch Contents: {}", batch);

      for (String element : batch) {
        receiver.output(element);
      }
    }

ganesh-skumar and others added 2 commits May 12, 2026 17:29
…egation/batchelements.md

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.07%. Comparing base (a8e7ffa) to head (af1aa24).
⚠️ Report is 22 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #38457      +/-   ##
============================================
+ Coverage     55.76%   57.07%   +1.31%     
- Complexity     2095     3636    +1541     
============================================
  Files          1099     1185      +86     
  Lines        172277   189597   +17320     
  Branches       1350     3751    +2401     
============================================
+ Hits          96065   108208   +12143     
- Misses        73817    77924    +4107     
- Partials       2395     3465    +1070     
Flag Coverage Δ
java 72.63% <ø> (-3.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @ahmedabu98 for label java.
R: @kennknowles for label website.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Copy link
Copy Markdown
Contributor

@ahmedabu98 ahmedabu98 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just left one suggestion

Comment on lines +18 to +24
# BatchElements

BatchElements transform groups individual elements into batches before processing them downstream.
The transform takes a `PCollection<T>` as input and produces a `PCollection<List<T>>`, where each output element is a batch containing multiple input elements.
Batch sizes are chosen dynamically between the configured minimum and maximum values by measuring the execution time of downstream operations.

Batching is performed per window. Each emitted batch belongs to the same window as its input elements.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe include some motivation behind BatchElements? This is a good excerpt:

* <p>This transform is designed to precede operations whose processing cost is of the form:
*
* <pre>
* time = fixed_cost + num_elements * per_element_cost
* </pre>
*
* <p>When the per-element cost is significantly smaller than the fixed cost, batching multiple
* elements together can amortize that fixed cost and improve overall throughput.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants