kbendick commented on a change in pull request #1430:
URL: https://github.com/apache/iceberg/pull/1430#discussion_r487587290



##########
File path: api/src/main/java/org/apache/iceberg/Metrics.java
##########
@@ -120,4 +124,90 @@ public Long recordCount() {
   public Map<Integer, ByteBuffer> upperBounds() {
     return upperBounds;
   }
+
+  /**
+   * Implemented the method to enable serialization of ByteBuffers.
+   * @param out The stream where to write
+   * @throws IOException On serialization error
+   */
+  private void writeObject(ObjectOutputStream out) throws IOException {
+    out.writeObject(rowCount);
+    out.writeObject(columnSizes);
+    out.writeObject(valueCounts);
+    out.writeObject(nullValueCounts);
+
+    writeByteBufferMap(out, lowerBounds);
+    writeByteBufferMap(out, upperBounds);
+  }

Review comment:
       Is this serialization format, e.g. `rowCount, columnSizes, valueCounts, 
nullValueCounts` and then the `lowerBounds` followed by `upperBounds` currently 
used anywhere else?
   
   If so, perhaps there's a utility class that can be used?
   
   If not, I personally think that this serialization format should be  
documented somewhere. We might need to include the format version in it as 
well, like we do for other places (where the new v2 format specification will 
be what is used to support row level deletes).
   
   Additionally, would it make sense to move this serialization logic into a 
utility class if there's nothing that currently meets this need?
   
   For example, type conversions to get the lower bounds value from the 
ByteBuffer are currently done in 
`org.apache.iceberg.types.Conversion#fromByteBuffer` as mentioned elsehwere in 
this file. Here's a link to the code, perhaps something there might make this 
task easier / more standardized: 
https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/types/Conversions.java
   
   And if there's not a utility class, would it make sense to add one (like how 
the actual conversion of `upperBounds` and `lowerBounds` from their ByteBuffers 
is deletegated to the `Conversions` class?




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to