ajantha-bhat commented on code in PR #9170:
URL: https://github.com/apache/iceberg/pull/9170#discussion_r1441749823


##########
core/src/main/java/org/apache/iceberg/PartitionEntry.java:
##########
@@ -0,0 +1,361 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+import java.util.Objects;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.iceberg.avro.AvroSchemaUtil;
+import org.apache.iceberg.types.Types;
+
+public class PartitionEntry implements IndexedRecord {
+  private PartitionData partitionData;
+  private int specId;
+  private long dataRecordCount;
+  private int dataFileCount;
+  private long dataFileSizeInBytes;
+  private long posDeleteRecordCount;
+  private int posDeleteFileCount;
+  private long eqDeleteRecordCount;
+  private int eqDeleteFileCount;
+  // Optional accurate count of records in a partition after applying the 
delete files if any
+  private long totalRecordCount;
+  // Commit time of snapshot that last updated this partition
+  private long lastUpdatedAt;
+  // ID of snapshot that last updated this partition
+  private long lastUpdatedSnapshotId;
+
+  public enum Column {
+    PARTITION_DATA,
+    SPEC_ID,
+    DATA_RECORD_COUNT,
+    DATA_FILE_COUNT,
+    DATA_FILE_SIZE_IN_BYTES,
+    POSITION_DELETE_RECORD_COUNT,
+    POSITION_DELETE_FILE_COUNT,
+    EQUALITY_DELETE_RECORD_COUNT,
+    EQUALITY_DELETE_FILE_COUNT,
+    TOTAL_RECORD_COUNT,
+    LAST_UPDATED_AT,
+    LAST_UPDATED_SNAPSHOT_ID
+  }
+
+  private PartitionEntry() {}
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public PartitionData partitionData() {
+    return partitionData;
+  }
+
+  public int specId() {
+    return specId;
+  }
+
+  public long dataRecordCount() {
+    return dataRecordCount;
+  }
+
+  public int dataFileCount() {
+    return dataFileCount;
+  }
+
+  public long dataFileSizeInBytes() {
+    return dataFileSizeInBytes;
+  }
+
+  public long posDeleteRecordCount() {
+    return posDeleteRecordCount;
+  }
+
+  public int posDeleteFileCount() {
+    return posDeleteFileCount;
+  }
+
+  public long eqDeleteRecordCount() {
+    return eqDeleteRecordCount;
+  }
+
+  public int eqDeleteFileCount() {
+    return eqDeleteFileCount;
+  }
+
+  public long totalRecordCount() {
+    return totalRecordCount;
+  }
+
+  public long lastUpdatedAt() {
+    return lastUpdatedAt;
+  }
+
+  public long lastUpdatedSnapshotId() {
+    return lastUpdatedSnapshotId;
+  }
+
+  @Override
+  public void put(int i, Object v) {
+    switch (i) {
+      case 0:
+        this.partitionData = (PartitionData) v;
+        return;
+      case 1:
+        this.specId = (int) v;
+        return;
+      case 2:
+        this.dataRecordCount = (long) v;
+        return;
+      case 3:
+        this.dataFileCount = (int) v;
+        return;
+      case 4:
+        this.dataFileSizeInBytes = (long) v;
+        return;
+      case 5:
+        this.posDeleteRecordCount = (long) v;
+        return;
+      case 6:
+        this.posDeleteFileCount = (int) v;
+        return;
+      case 7:
+        this.eqDeleteRecordCount = (long) v;
+        return;
+      case 8:
+        this.eqDeleteFileCount = (int) v;
+        return;
+      case 9:
+        this.totalRecordCount = (long) v;
+        return;
+      case 10:
+        this.lastUpdatedAt = (long) v;
+        return;
+      case 11:
+        this.lastUpdatedSnapshotId = (long) v;
+        return;
+      default:
+        throw new UnsupportedOperationException("Unknown field ordinal: " + i);
+    }
+  }
+
+  @Override
+  public Object get(int i) {
+    switch (i) {
+      case 0:
+        return partitionData;
+      case 1:
+        return specId;
+      case 2:
+        return dataRecordCount;
+      case 3:
+        return dataFileCount;
+      case 4:
+        return dataFileSizeInBytes;
+      case 5:
+        return posDeleteRecordCount;
+      case 6:
+        return posDeleteFileCount;
+      case 7:
+        return eqDeleteRecordCount;
+      case 8:
+        return eqDeleteFileCount;
+      case 9:
+        return totalRecordCount;
+      case 10:
+        return lastUpdatedAt;
+      case 11:
+        return lastUpdatedSnapshotId;
+      default:
+        throw new UnsupportedOperationException("Unknown field ordinal: " + i);
+    }
+  }
+
+  @Override
+  public Schema getSchema() {
+    return prepareAvroSchema(partitionData.getPartitionType());
+  }
+
+  @Override
+  @SuppressWarnings("checkstyle:CyclomaticComplexity")
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    } else if (!(o instanceof PartitionEntry)) {
+      return false;
+    }
+
+    PartitionEntry that = (PartitionEntry) o;
+    return partitionData.equals(that.partitionData)
+        && specId == that.specId
+        && dataRecordCount == that.dataRecordCount
+        && dataFileCount == that.dataFileCount
+        && dataFileSizeInBytes == that.dataFileSizeInBytes
+        && posDeleteRecordCount == that.posDeleteRecordCount
+        && posDeleteFileCount == that.posDeleteFileCount
+        && eqDeleteRecordCount == that.eqDeleteRecordCount
+        && eqDeleteFileCount == that.eqDeleteFileCount
+        && totalRecordCount == that.totalRecordCount
+        && lastUpdatedAt == that.lastUpdatedAt
+        && lastUpdatedSnapshotId == that.lastUpdatedSnapshotId;
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(
+        partitionData,
+        specId,
+        dataRecordCount,
+        dataFileCount,
+        dataFileSizeInBytes,
+        posDeleteRecordCount,
+        posDeleteFileCount,
+        eqDeleteRecordCount,
+        eqDeleteFileCount,
+        totalRecordCount,
+        lastUpdatedAt,
+        lastUpdatedSnapshotId);
+  }
+
+  public static org.apache.iceberg.Schema icebergSchema(Types.StructType 
partitionType) {
+    if (partitionType.fields().isEmpty()) {
+      throw new IllegalArgumentException("getting schema for an unpartitioned 
table");
+    }
+
+    return new org.apache.iceberg.Schema(

Review Comment:
   Note: Even the `optional` and `required` fields decision is based on the 
spec. 



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to