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

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

                Author: ASF GitHub Bot
            Created on: 02/Jul/18 18:06
            Start Date: 02/Jul/18 18:06
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on a change in pull request #5795: 
[BEAM-3708] Adding grouping table to Precombine step.
URL: https://github.com/apache/beam/pull/5795#discussion_r199303580
 
 

 ##########
 File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/CombineRunners.java
 ##########
 @@ -51,17 +71,120 @@
     }
   }
 
-  static <KeyT, InputT, AccumT>
-      ThrowingFunction<KV<KeyT, InputT>, KV<KeyT, AccumT>> 
createPrecombineMapFunction(
-          String pTransformId, PTransform pTransform) throws IOException {
-    CombinePayload combinePayload = 
CombinePayload.parseFrom(pTransform.getSpec().getPayload());
-    CombineFn<InputT, AccumT, ?> combineFn =
-        (CombineFn)
-            SerializableUtils.deserializeFromByteArray(
-                
combinePayload.getCombineFn().getSpec().getPayload().toByteArray(), 
"CombineFn");
+  private static class PrecombineRunner<KeyT, InputT, AccumT> {
+    private PipelineOptions options;
+    private CombineFn<InputT, AccumT, ?> combineFn;
+    private FnDataReceiver<WindowedValue<KV<KeyT, AccumT>>> output;
+    private Coder<KeyT> keyCoder;
+    private GroupingTable<WindowedValue<KeyT>, InputT, AccumT> groupingTable;
+    private Coder<AccumT> accumCoder;
+
+    PrecombineRunner(
+        PipelineOptions options,
+        CombineFn<InputT, AccumT, ?> combineFn,
+        FnDataReceiver<WindowedValue<KV<KeyT, AccumT>>> output,
+        Coder<KeyT> keyCoder,
+        Coder<AccumT> accumCoder) {
+      this.options = options;
+      this.combineFn = combineFn;
+      this.output = output;
+      this.keyCoder = keyCoder;
+      this.accumCoder = accumCoder;
+    }
+
+    void startBundle() {
+      groupingTable =
+          PrecombineGroupingTable.combiningAndSampling(
+              options, combineFn, keyCoder, accumCoder, 0.001 
/*sizeEstimatorSampleRate*/);
+    }
+
+    void processElement(WindowedValue<KV<KeyT, InputT>> elem) throws Exception 
{
+      groupingTable.put(
+          elem, (Object outputElem) -> output.accept((WindowedValue<KV<KeyT, 
AccumT>>) outputElem));
+    }
+
+    void finishBundle() throws Exception {
+      groupingTable.flush(
+          (Object outputElem) -> output.accept((WindowedValue<KV<KeyT, 
AccumT>>) outputElem));
 
 Review comment:
   ditto here, if you use a cast, you should be able to pass this in as a 
method reference instead of using a lambda

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

    Worklog Id:     (was: 118313)
    Time Spent: 4h 50m  (was: 4h 40m)

> Implement the portable lifted Combiner transforms in Java SDK
> -------------------------------------------------------------
>
>                 Key: BEAM-3708
>                 URL: https://issues.apache.org/jira/browse/BEAM-3708
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core, sdk-java-harness
>            Reporter: Daniel Oliveira
>            Assignee: Daniel Oliveira
>            Priority: Major
>              Labels: portability
>          Time Spent: 4h 50m
>  Remaining Estimate: 0h
>
> Lifted combines are split into separate parts with different URNs. These 
> parts need to be implemented in the Java SDK harness so that the SDK can 
> actually execute them when receiving Combine transforms with the 
> corresponding URNs.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to