[ 
https://issues.apache.org/jira/browse/BEAM-12370?focusedWorklogId=602606&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-602606
 ]

ASF GitHub Bot logged work on BEAM-12370:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/May/21 22:04
            Start Date: 26/May/21 22:04
    Worklog Time Spent: 10m 
      Work Description: xinyuiscool commented on a change in pull request 
#14883:
URL: https://github.com/apache/beam/pull/14883#discussion_r640152071



##########
File path: 
runners/samza/src/main/java/org/apache/beam/runners/samza/translation/ParDoBoundMultiTranslator.java
##########
@@ -368,6 +405,80 @@ public void translatePortable(
     return Collections.emptyMap();
   }
 
+  @SuppressWarnings("unchecked")
+  private static final ViewFn<Iterable<WindowedValue<?>>, ?> VIEW_FN =
+      (ViewFn)
+          new PCollectionViews.MultimapViewFn<>(
+              
(PCollectionViews.TypeDescriptorSupplier<Iterable<WindowedValue<Void>>>)
+                  () -> TypeDescriptors.iterables(new 
TypeDescriptor<WindowedValue<Void>>() {}),
+              (PCollectionViews.TypeDescriptorSupplier<Void>) 
TypeDescriptors::voids);
+
+  // This method follows the same way in Flink to create a runner-side Java
+  // PCollectionView to represent a portable side input.
+  private static PCollectionView<?> createPCollectionView(
+      SideInputId sideInputId,
+      WindowedValue.WindowedValueCoder<?> coder,
+      WindowingStrategy<?, BoundedWindow> windowingStrategy) {
+
+    return new RunnerPCollectionView<>(
+        null,
+        new TupleTag<>(sideInputId.getLocalName()),
+        VIEW_FN,
+        // TODO: support custom mapping fn
+        windowingStrategy.getWindowFn().getDefaultWindowMappingFn(),
+        windowingStrategy,
+        coder.getValueCoder());
+  }
+
+  // Group the side input globally with a null key and then broadcast it
+  // to all tasks.
+  private static <SideInputT>
+      MessageStream<OpMessage<Iterable<SideInputT>>> 
groupAndBroadcastSideInput(
+          SideInputId sideInputId,
+          String sideInputCollectionId,
+          RunnerApi.PCollection sideInputPCollection,
+          WindowingStrategy<SideInputT, BoundedWindow> windowingStrategy,
+          WindowedValue.WindowedValueCoder<SideInputT> coder,
+          PortableTranslationContext ctx) {
+    final MessageStream<OpMessage<SideInputT>> sideInput =
+        ctx.getMessageStreamById(sideInputCollectionId);
+    final MessageStream<OpMessage<KV<Void, SideInputT>>> keyedSideInput =
+        sideInput.map(
+            opMessage -> {
+              WindowedValue<SideInputT> wv = opMessage.getElement();
+              return OpMessage.ofElement(wv.withValue(KV.of(null, 
wv.getValue())));

Review comment:
       Yup, null value is commonly used in beam to do global combine, as we do 
it in java translation too. It's the same as placeholder, but I guess it's more 
efficient (no key bytes).




-- 
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 602606)
    Time Spent: 40m  (was: 0.5h)

> Support side input in Samza portable runner
> -------------------------------------------
>
>                 Key: BEAM-12370
>                 URL: https://issues.apache.org/jira/browse/BEAM-12370
>             Project: Beam
>          Issue Type: Improvement
>          Components: runner-samza
>            Reporter: Xinyu Liu
>            Assignee: Xinyu Liu
>            Priority: P2
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Add support of side input inside Samza portable runner.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to