beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [beam] boyuanzz commented on a change in pull request #10897: [BEAM-2939] Java UnboundedSource SDF wrapper
Date Thu, 27 Feb 2020 00:27:34 GMT
boyuanzz commented on a change in pull request #10897: [BEAM-2939] Java UnboundedSource SDF
wrapper
URL: https://github.com/apache/beam/pull/10897#discussion_r384840768
 
 

 ##########
 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:
   I'm curious what `WindowingStrategy` is going to apply here. If it's using `GlobalWindow`,
will it work in streaming mode?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message