kennknowles commented on code in PR #38230:
URL: https://github.com/apache/beam/pull/38230#discussion_r3130513851
##########
runners/core-java/src/main/java/org/apache/beam/runners/core/ReduceFnRunner.java:
##########
@@ -590,6 +595,17 @@ private void processElement(Map<W, W> windowToMergeResult,
WindowedValue<InputT>
value.getTimestamp(),
StateStyle.DIRECT,
value.causedByDrain());
+
+ ValueState<CombinedMetadata> metadataState =
directContext.state().access(METADATA_TAG);
+ CombinedMetadata currentMetadata = metadataState.read();
+ if (currentMetadata == null) {
+ currentMetadata = CombinedMetadata.createDefault();
+ }
+ CombinedMetadata inputMetadata =
CombinedMetadata.create(value.causedByDrain());
+ CombinedMetadata newMetadata =
+ CombinedMetadataCombiner.of().addInput(currentMetadata,
inputMetadata);
+ metadataState.write(newMetadata);
Review Comment:
Yes, this is correct. With a combining state, you would do write (without
reads) of each thing into a bag, and they are combined on read. It would be a a
blocker if we had to read-modify-write on each element.
--
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]