anoopj commented on code in PR #16408:
URL: https://github.com/apache/iceberg/pull/16408#discussion_r3304769695


##########
core/src/main/java/org/apache/iceberg/ManifestInfoStruct.java:
##########
@@ -257,116 +257,135 @@ public String toString() {
   }
 
   static class Builder {
-    private int addedFilesCount = -1;
-    private int existingFilesCount = -1;
-    private int deletedFilesCount = -1;
-    private int replacedFilesCount = -1;
-    private long addedRowsCount = -1L;
-    private long existingRowsCount = -1L;
-    private long deletedRowsCount = -1L;
-    private long replacedRowsCount = -1L;
-    private long minSequenceNumber = -1L;
+    private Integer addedFilesCount = null;
+    private Integer existingFilesCount = null;
+    private Integer deletedFilesCount = null;
+    private Integer replacedFilesCount = null;
+    private Long addedRowsCount = null;
+    private Long existingRowsCount = null;
+    private Long deletedRowsCount = null;
+    private Long replacedRowsCount = null;
+    private Long minSequenceNumber = null;
     private byte[] dv = null;
     private Long dvCardinality = null;
 
     Builder addedFilesCount(int count) {
+      Preconditions.checkArgument(
+          count >= 0, "Invalid added files count: %s (must be >= 0)", count);
       this.addedFilesCount = count;
       return this;
     }
 
     Builder existingFilesCount(int count) {
+      Preconditions.checkArgument(
+          count >= 0, "Invalid existing files count: %s (must be >= 0)", 
count);
       this.existingFilesCount = count;
       return this;
     }
 
     Builder deletedFilesCount(int count) {
+      Preconditions.checkArgument(
+          count >= 0, "Invalid deleted files count: %s (must be >= 0)", count);
       this.deletedFilesCount = count;
       return this;
     }
 
     Builder replacedFilesCount(int count) {
+      Preconditions.checkArgument(
+          count >= 0, "Invalid replaced files count: %s (must be >= 0)", 
count);
       this.replacedFilesCount = count;
       return this;
     }
 
     Builder addedRowsCount(long count) {
+      Preconditions.checkArgument(count >= 0, "Invalid added rows count: %s 
(must be >= 0)", count);
       this.addedRowsCount = count;
       return this;
     }
 
     Builder existingRowsCount(long count) {
+      Preconditions.checkArgument(
+          count >= 0, "Invalid existing rows count: %s (must be >= 0)", count);
       this.existingRowsCount = count;
       return this;
     }
 
     Builder deletedRowsCount(long count) {
+      Preconditions.checkArgument(
+          count >= 0, "Invalid deleted rows count: %s (must be >= 0)", count);
       this.deletedRowsCount = count;
       return this;
     }
 
     Builder replacedRowsCount(long count) {
+      Preconditions.checkArgument(
+          count >= 0, "Invalid replaced rows count: %s (must be >= 0)", count);
       this.replacedRowsCount = count;
       return this;
     }
 
     Builder minSequenceNumber(long sequenceNumber) {
+      Preconditions.checkArgument(
+          sequenceNumber >= 0, "Invalid min sequence number: %s (must be >= 
0)", sequenceNumber);
       this.minSequenceNumber = sequenceNumber;
       return this;
     }
 
     Builder dv(ByteBuffer buffer) {
-      this.dv = buffer != null ? ByteBuffers.toByteArray(buffer) : null;
-      return this;
-    }
-
-    Builder dv(byte[] buffer) {
-      this.dv = buffer;
+      Preconditions.checkArgument(buffer != null, "Invalid DV: null");
+      this.dv = ByteBuffers.toByteArray(buffer);

Review Comment:
   This is not guaranteed to be a deep copy, but consistent with `BaseFile`, 
and it would be unusual for DV arrays to be mutated



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


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

Reply via email to