scwhittle commented on code in PR #37762:
URL: https://github.com/apache/beam/pull/37762#discussion_r2910821030


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WindmillKeyedWorkItem.java:
##########
@@ -113,39 +137,45 @@ public Iterable<TimerData> timersIterable() {
             });
   }
 
+  private @Nullable WindowedValue<ElemT> parseElem(Windmill.Message message) {
+    try {
+      Instant timestamp = 
WindmillTimeUtils.windmillToHarnessTimestamp(message.getTimestamp());
+      Collection<? extends BoundedWindow> windows =
+          WindmillSink.decodeMetadataWindows(windowsCoder, 
message.getMetadata());
+      PaneInfo paneInfo = 
WindmillSink.decodeMetadataPane(message.getMetadata());
+      /**
+       * https://s.apache.org/beam-drain-mode - propagate drain bit if 
aggregation/expiry induced by
+       * drain happened upstream
+       */
+      CausedByDrain drainingValueFromUpstream = CausedByDrain.NORMAL;
+      if (WindowedValues.WindowedValueCoder.isMetadataSupported()) {
+        BeamFnApi.Elements.ElementMetadata elementMetadata =
+            WindmillSink.decodeAdditionalMetadata(windowsCoder, 
message.getMetadata());
+        drainingValueFromUpstream =
+            elementMetadata.getDrain() == 
BeamFnApi.Elements.DrainMode.Enum.DRAINING
+                ? CausedByDrain.CAUSED_BY_DRAIN
+                : CausedByDrain.NORMAL;
+      }
+      InputStream inputStream = message.getData().newInput();
+      ElemT value = valueCoder.decode(inputStream, Coder.Context.OUTER);
+      return WindowedValues.of(
+          value, timestamp, windows, paneInfo, null, null, 
drainingValueFromUpstream);
+    } catch (RuntimeException | IOException e) {
+      if (!skipUndecodableElements) {
+        throw new RuntimeException(e);
+      }
+      LOG.error("Skipping input element due to decoding error", e);

Review Comment:
   done



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to