robertwb commented on code in PR #33626:
URL: https://github.com/apache/beam/pull/33626#discussion_r1920923244


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/CombineFns.java:
##########
@@ -674,6 +674,26 @@ public void encode(Object[] value, OutputStream outStream, 
Coder.Context context
       coders.get(lastIndex).encode(value[lastIndex], outStream, context);
     }
 
+    @Override
+    public long getEncodedElementByteSize(Object[] value) throws Exception {
+      if (value.length == 0) {
+        return 0;
+      }
+      long size = 0;
+      for (int i = 0; i < value.length; ++i) {
+        Coder<Object> objectCoder = coders.get(i);
+        if (objectCoder instanceof StructuredCoder) {

Review Comment:
   I would remove the typecheck on StructuredCoder, just loop and add for every 
coder. The only downside is that there may be overhead constructing multiple 
CountingOutputStreams rather than creating one, but as you say there's no 
contract between StructuredCoder and implementing getEncodedElementByteSize. 
   
   Go ahead and remove the check in LengthPrefixCoder too, there's no benefit 
for ever skipping this attempt. 



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