rdblue commented on code in PR #16092:
URL: https://github.com/apache/iceberg/pull/16092#discussion_r3244794437


##########
core/src/main/java/org/apache/iceberg/ManifestInfoStruct.java:
##########
@@ -224,4 +255,130 @@ public String toString() {
         .add("dv_cardinality", dvCardinality == null ? "null" : dvCardinality)
         .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 byte[] dv = null;
+    private Long dvCardinality = null;
+
+    Builder addedFilesCount(int count) {
+      this.addedFilesCount = count;
+      return this;
+    }
+
+    Builder existingFilesCount(int count) {
+      this.existingFilesCount = count;
+      return this;
+    }
+
+    Builder deletedFilesCount(int count) {
+      this.deletedFilesCount = count;
+      return this;
+    }
+
+    Builder replacedFilesCount(int count) {
+      this.replacedFilesCount = count;
+      return this;
+    }
+
+    Builder addedRowsCount(long count) {
+      this.addedRowsCount = count;
+      return this;
+    }
+
+    Builder existingRowsCount(long count) {
+      this.existingRowsCount = count;
+      return this;
+    }
+
+    Builder deletedRowsCount(long count) {
+      this.deletedRowsCount = count;
+      return this;
+    }
+
+    Builder replacedRowsCount(long count) {
+      this.replacedRowsCount = count;
+      return this;
+    }
+
+    Builder minSequenceNumber(long 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;
+      return this;
+    }
+
+    Builder dvCardinality(Long cardinality) {
+      this.dvCardinality = cardinality;
+      return this;
+    }
+
+    ManifestInfoStruct build() {
+      Preconditions.checkArgument(
+          addedFilesCount >= 0, "Invalid added files count: %s (must be >= 
0)", addedFilesCount);
+      Preconditions.checkArgument(
+          existingFilesCount >= 0,
+          "Invalid existing files count: %s (must be >= 0)",
+          existingFilesCount);
+      Preconditions.checkArgument(
+          deletedFilesCount >= 0,
+          "Invalid deleted files count: %s (must be >= 0)",
+          deletedFilesCount);
+      Preconditions.checkArgument(
+          replacedFilesCount >= 0,
+          "Invalid replaced files count: %s (must be >= 0)",
+          replacedFilesCount);
+      Preconditions.checkArgument(
+          addedRowsCount >= 0, "Invalid added rows count: %s (must be >= 0)", 
addedRowsCount);
+      Preconditions.checkArgument(
+          existingRowsCount >= 0,
+          "Invalid existing rows count: %s (must be >= 0)",
+          existingRowsCount);
+      Preconditions.checkArgument(
+          deletedRowsCount >= 0, "Invalid deleted rows count: %s (must be >= 
0)", deletedRowsCount);
+      Preconditions.checkArgument(
+          replacedRowsCount >= 0,
+          "Invalid replaced rows count: %s (must be >= 0)",
+          replacedRowsCount);
+      Preconditions.checkArgument(
+          minSequenceNumber >= 0,
+          "Invalid min sequence number: %s (must be >= 0)",
+          minSequenceNumber);
+      Preconditions.checkArgument(
+          (dv == null) == (dvCardinality == null),
+          "Invalid DV and cardinality: must both be null or non-null");

Review Comment:
   This is the kind of consistency check that belongs in the builder.
   
   Is it okay to set cardinality to 0?
   
   Maybe it doesn't matter because I think we're removing the MDV cardinality.



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