lukecwik commented on a change in pull request #10897: [BEAM-2939] Java
UnboundedSource SDF wrapper
URL: https://github.com/apache/beam/pull/10897#discussion_r384867042
##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/io/Read.java
##########
@@ -185,6 +200,37 @@ private Unbounded(@Nullable String name,
UnboundedSource<T, ?> source) {
@Override
public final PCollection<T> expand(PBegin input) {
source.validate();
+
+ if (ExperimentalOptions.hasExperiment(input.getPipeline().getOptions(),
"beam_fn_api")
+ && !ExperimentalOptions.hasExperiment(
+ input.getPipeline().getOptions(),
"beam_fn_api_use_deprecated_read")) {
+ // We don't use Create here since Create is defined as a BoundedSource
and using it would
+ // cause an infinite expansion loop. We can reconsider this if Create
is implemented
+ // directly as a SplittableDoFn.
+ PCollection<ValueWithRecordId<T>> outputWithIds =
+ input
+ .getPipeline()
+ .apply(Impulse.create())
+ .apply(
+ MapElements.into(new TypeDescriptor<UnboundedSource<T,
CheckpointMark>>() {})
+ .via(element -> (UnboundedSource<T, CheckpointMark>)
source))
+ .setCoder(
+ SerializableCoder.of(
+ new TypeDescriptor<UnboundedSource<T,
CheckpointMark>>() {}))
+ .apply(
+ ParDo.of(
+ new UnboundedSourceAsSDFWrapperFn<>(
+ (Coder<CheckpointMark>)
source.getCheckpointMarkCoder())))
+ .setCoder(ValueWithRecordIdCoder.of(source.getOutputCoder()));
+ if (source.requiresDeduping()) {
+ outputWithIds.apply(
+ Distinct.<ValueWithRecordId<T>, byte[]>withRepresentativeValueFn(
Review comment:
No it won't, this was for some testing of mine.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services