nbali commented on code in PR #22953:
URL: https://github.com/apache/beam/pull/22953#discussion_r1024072638


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupIntoBatches.java:
##########
@@ -424,13 +465,40 @@ public void processElement(
         BoundedWindow window,
         OutputReceiver<KV<K, Iterable<InputT>>> receiver) {
       LOG.debug("*** BATCH *** Add element for window {} ", window);
+      if (shouldCareAboutWeight()) {
+        final long elementWeight = weigher.apply(element.getValue());
+        if (elementWeight + storedBatchSizeBytes.read() > batchSizeBytes) {

Review Comment:
   TBH I wasn't sure how `read()`/`readLater()` implementation works. Like if 
we read it once, then will it be cached for the whole duration already or will 
it fetch it again.. but I assumed `readLater()` - as every prefetching method 
should be - is already optimized to be noop for already present values, so 
worst case is that we have an unnecessary  noop call.
   
   So to sum things up does that mean that a value returned by a `read()` call 
will be always available from that point forward? Anyway modified the PR/code 
to reflect this.



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