apache / apache/beam

Update Read PTransform to implicitly use maxNumRecords and maxReadTime

Open
#18,049 0 comments 0 reactions 0 assignees View on GitHub
core improvement java P3
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
205

Description

Today, almost all IOs `Read` `PTransform`, when using an `UnboundedSource`, do the following in the `apply()`:
```

org.apache.beam.sdk.io.Read.Unbounded unbounded =
org.apache.beam.sdk.io.Read.from(getSource());

PTransform> transform = unbounded;

if (maxNumRecords() < Long.MAX_VALUE
|| maxReadTime() != null) {
transform = unbounded.withMaxReadTime(maxReadTime()).withMaxNumRecords(maxNumRecords());

}

return input.getPipeline().apply(transform);

```

To avoid to duplicate this code bunch of time, it would make sense to do it by default in `org.apache.beam.sdk.io.Read`.

Imported from Jira [BEAM-671](https://issues.apache.org/jira/browse/BEAM-671). Original Jira may contain additional context.
Reported by: jbonofre.

Contributor guide

Open the contributing guide

Research direction

Start in org.apache.beam.sdk.io.Read and trace how UnboundedSource-based Read transforms are configured in apply(). Compare the repeated maxNumRecords and maxReadTime handling described in the issue, then verify that Read applies those limits by default without changing existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
data-engineering
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.