amogh-jahagirdar commented on code in PR #15049:
URL: https://github.com/apache/iceberg/pull/15049#discussion_r2897767063


##########
api/src/main/java/org/apache/iceberg/FileContent.java:
##########
@@ -18,11 +18,18 @@
  */
 package org.apache.iceberg;
 
-/** Content type stored in a file, one of DATA, POSITION_DELETES, or 
EQUALITY_DELETES. */
+/** Content type stored in a file. */
 public enum FileContent {
+  /** Data file content. Stored in data manifests since v1. */
   DATA(0),
+  /** Position delete file content. Added in v2. */
   POSITION_DELETES(1),
-  EQUALITY_DELETES(2);
+  /** Equality delete file content. Added in v2. */
+  EQUALITY_DELETES(2),
+  /** Data manifest content, referencing data files in a root manifest. Added 
in v4. */

Review Comment:
   `Manifests that contain data files. Added in v4`? The current wording makes 
it seem like the manifest entries themselves reference files in the root



##########
core/src/main/java/org/apache/iceberg/ManifestEntryStatus.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * Status of an entry in a manifest file.
+ *
+ * <p>This is a top-level enum to avoid duplication across manifest entry 
types (v3 ManifestEntry
+ * and v4 TrackingInfo).
+ *
+ * <p>For v4: Only ADDED and EXISTING entries are considered live for scan 
planning. DELETED and
+ * REPLACED entries are used for change detection but are not live. REPLACED 
may only be used for
+ * entries that have had data column updates or deletion vector changes, and 
every REPLACED entry
+ * will have a corresponding EXISTING entry for the same location.
+ */
+public enum ManifestEntryStatus {

Review Comment:
   Does this need to be public for this PR? I agree with the modeling but it 
looks like it could be package private for now. I think that's especially 
important since we'll want to get others input on statuses before exposing 
stuff and avoiding potential deprecation churn. 



##########
api/src/main/java/org/apache/iceberg/FileContent.java:
##########
@@ -18,11 +18,18 @@
  */
 package org.apache.iceberg;
 
-/** Content type stored in a file, one of DATA, POSITION_DELETES, or 
EQUALITY_DELETES. */
+/** Content type stored in a file. */
 public enum FileContent {
+  /** Data file content. Stored in data manifests since v1. */
   DATA(0),
+  /** Position delete file content. Added in v2. */
   POSITION_DELETES(1),
-  EQUALITY_DELETES(2);
+  /** Equality delete file content. Added in v2. */
+  EQUALITY_DELETES(2),
+  /** Data manifest content, referencing data files in a root manifest. Added 
in v4. */
+  DATA_MANIFEST(3),
+  /** Delete manifest content, referencing delete files in a root manifest. 
Added in v4. */

Review Comment:
   Same suggestion as above, but with `delete files`?



##########
core/src/main/java/org/apache/iceberg/TrackingInfo.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.nio.ByteBuffer;
+import org.apache.iceberg.types.Types;
+
+/**
+ * Tracking information for a tracked file entry in a v4 manifest.
+ *
+ * <p>This groups the status, snapshot, and sequence number information for 
the entry. This enables
+ * accessing the fields for the entry and provides an isolated structure that 
can be modified.
+ */
+interface TrackingInfo {
+  Types.NestedField STATUS =
+      Types.NestedField.required(
+          0,
+          "status",
+          Types.IntegerType.get(),
+          "Entry status: 0=existing, 1=added, 2=deleted, 3=replaced");
+  Types.NestedField SNAPSHOT_ID =
+      Types.NestedField.optional(
+          1,
+          "snapshot_id",
+          Types.LongType.get(),
+          "Snapshot ID where the file was added or deleted");
+  Types.NestedField DV_SNAPSHOT_ID =
+      Types.NestedField.optional(
+          157,
+          "dv_snapshot_id",
+          Types.LongType.get(),
+          "Snapshot ID where the DV was added. May only be defined when a 
deletion vector is present");
+  Types.NestedField SEQUENCE_NUMBER =
+      Types.NestedField.optional(
+          3, "sequence_number", Types.LongType.get(), "Data sequence number of 
the file");
+  Types.NestedField FILE_SEQUENCE_NUMBER =
+      Types.NestedField.optional(
+          4,
+          "file_sequence_number",
+          Types.LongType.get(),
+          "File sequence number indicating when the file was added");
+  Types.NestedField FIRST_ROW_ID =
+      Types.NestedField.optional(
+          142, "first_row_id", Types.LongType.get(), "ID of the first row in 
the data file");
+
+  Types.NestedField CHANGED_POSITIONS_DELETED =
+      Types.NestedField.optional(
+          158,
+          "deleted",
+          Types.BinaryType.get(),
+          "Bitmap of positions deleted in this specific snapshot");
+  Types.NestedField CHANGED_POSITIONS_REPLACED =
+      Types.NestedField.optional(
+          159,
+          "replaced",
+          Types.BinaryType.get(),
+          "Bitmap of positions replaced in this specific snapshot");
+
+  Types.NestedField CHANGED_POSITIONS =
+      Types.NestedField.optional(
+          153,
+          "changed_positions",
+          Types.StructType.of(CHANGED_POSITIONS_DELETED, 
CHANGED_POSITIONS_REPLACED),
+          "Bitmaps of deleted and replaced positions in this specific 
snapshot");
+
+  static Types.StructType schema() {
+    return Types.StructType.of(
+        STATUS,
+        SNAPSHOT_ID,
+        DV_SNAPSHOT_ID,
+        SEQUENCE_NUMBER,
+        FILE_SEQUENCE_NUMBER,
+        FIRST_ROW_ID,
+        CHANGED_POSITIONS);
+  }
+
+  /**
+   * Returns the status of the entry.
+   *
+   * <p>Status values:
+   *
+   * <ul>
+   *   <li>0: EXISTING - file was already in the table
+   *   <li>1: ADDED - file newly added
+   *   <li>2: DELETED - file removed
+   *   <li>3: REPLACED - entry replaced by a column update or DV change (v4 
only)

Review Comment:
   Minor: I'm not sure we really need the (v4 only) in the comment considering 
this interface is only for V4 manifest entries anyways? 



##########
core/src/main/java/org/apache/iceberg/TrackingInfo.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.nio.ByteBuffer;
+import org.apache.iceberg.types.Types;
+
+/**
+ * Tracking information for a tracked file entry in a v4 manifest.
+ *
+ * <p>This groups the status, snapshot, and sequence number information for 
the entry. This enables
+ * accessing the fields for the entry and provides an isolated structure that 
can be modified.
+ */
+interface TrackingInfo {
+  Types.NestedField STATUS =
+      Types.NestedField.required(
+          0,
+          "status",
+          Types.IntegerType.get(),
+          "Entry status: 0=existing, 1=added, 2=deleted, 3=replaced");
+  Types.NestedField SNAPSHOT_ID =
+      Types.NestedField.optional(
+          1,
+          "snapshot_id",
+          Types.LongType.get(),
+          "Snapshot ID where the file was added or deleted");
+  Types.NestedField DV_SNAPSHOT_ID =
+      Types.NestedField.optional(
+          157,
+          "dv_snapshot_id",
+          Types.LongType.get(),
+          "Snapshot ID where the DV was added. May only be defined when a 
deletion vector is present");
+  Types.NestedField SEQUENCE_NUMBER =
+      Types.NestedField.optional(
+          3, "sequence_number", Types.LongType.get(), "Data sequence number of 
the file");
+  Types.NestedField FILE_SEQUENCE_NUMBER =
+      Types.NestedField.optional(
+          4,
+          "file_sequence_number",
+          Types.LongType.get(),
+          "File sequence number indicating when the file was added");
+  Types.NestedField FIRST_ROW_ID =
+      Types.NestedField.optional(
+          142, "first_row_id", Types.LongType.get(), "ID of the first row in 
the data file");
+
+  Types.NestedField CHANGED_POSITIONS_DELETED =
+      Types.NestedField.optional(
+          158,
+          "deleted",
+          Types.BinaryType.get(),
+          "Bitmap of positions deleted in this specific snapshot");
+  Types.NestedField CHANGED_POSITIONS_REPLACED =
+      Types.NestedField.optional(
+          159,
+          "replaced",
+          Types.BinaryType.get(),
+          "Bitmap of positions replaced in this specific snapshot");
+
+  Types.NestedField CHANGED_POSITIONS =
+      Types.NestedField.optional(
+          153,
+          "changed_positions",
+          Types.StructType.of(CHANGED_POSITIONS_DELETED, 
CHANGED_POSITIONS_REPLACED),
+          "Bitmaps of deleted and replaced positions in this specific 
snapshot");
+
+  static Types.StructType schema() {
+    return Types.StructType.of(
+        STATUS,
+        SNAPSHOT_ID,
+        DV_SNAPSHOT_ID,
+        SEQUENCE_NUMBER,
+        FILE_SEQUENCE_NUMBER,
+        FIRST_ROW_ID,
+        CHANGED_POSITIONS);
+  }
+
+  /**
+   * Returns the status of the entry.
+   *
+   * <p>Status values:
+   *
+   * <ul>
+   *   <li>0: EXISTING - file was already in the table
+   *   <li>1: ADDED - file newly added
+   *   <li>2: DELETED - file removed
+   *   <li>3: REPLACED - entry replaced by a column update or DV change (v4 
only)
+   * </ul>
+   *
+   * <p>Only ADDED and EXISTING entries are considered live for scan planning. 
DELETED and REPLACED
+   * entries are used for change detection but are not live.
+   */
+  ManifestEntryStatus status();
+
+  /** Returns the snapshot ID where the file was added or deleted. */
+  Long snapshotId();
+
+  /**
+   * Returns the snapshot ID where the DV was added.
+   *
+   * <p>Inherited when null. May only be defined when a deletion vector is 
present.
+   */
+  Long dvSnapshotId();
+
+  /** Returns the data sequence number of the file. */
+  Long dataSequenceNumber();
+
+  /** Returns the file sequence number indicating when the file was added. */
+  Long fileSequenceNumber();
+
+  /** Returns the ID of the first row in the data file. */
+  Long firstRowId();
+
+  /**
+   * Returns the bitmap of positions in the referenced manifest that were 
deleted in this specific
+   * snapshot.
+   *
+   * <p>If position at index i is set in this bitmap, it cannot be set in the 
replaced positions
+   * bitmap.
+   */
+  ByteBuffer deletedPositions();
+
+  /**
+   * Returns the bitmap of positions in the referenced manifest that were 
replaced in this specific
+   * snapshot.
+   *
+   * <p>If position at index i is set in this bitmap, it cannot be set in the 
deleted positions
+   * bitmap. Files that have been replaced will have a corresponding EXISTING 
entry for the same
+   * location.

Review Comment:
   Similar in theme to the other comments, I'm not sure we really need 
statements like "Files that have been replaced will have a corresponding 
EXISTING entry for the same location" in these java doc comments. Those are 
true from a proposed spec perspective but I don't think that at this level of 
abstraction in the code it's particularly useful context. 



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