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


##########
core/src/main/java/org/apache/iceberg/TrackingStruct.java:
##########
@@ -0,0 +1,235 @@
+/*
+ * 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.io.Serializable;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.apache.iceberg.avro.SupportsIndexProjection;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.types.Types;
+import org.apache.iceberg.util.ByteBuffers;
+
+/** Mutable {@link StructLike} implementation of {@link Tracking}. */
+class TrackingStruct extends SupportsIndexProjection implements Tracking, 
Serializable {
+  private static final Types.StructType BASE_TYPE =
+      Types.StructType.of(
+          Tracking.STATUS,
+          Tracking.SNAPSHOT_ID,
+          Tracking.SEQUENCE_NUMBER,
+          Tracking.FILE_SEQUENCE_NUMBER,
+          Tracking.DV_SNAPSHOT_ID,
+          Tracking.FIRST_ROW_ID,
+          Tracking.DELETED_POSITIONS,
+          Tracking.REPLACED_POSITIONS,
+          MetadataColumns.ROW_POSITION);
+
+  private EntryStatus status = null;
+  private Long snapshotId = null;
+  private Long dataSequenceNumber = null;
+  private Long fileSequenceNumber = null;
+  private Long dvSnapshotId = null;
+  private Long firstRowId = null;
+  private byte[] deletedPositions = null;
+  private byte[] replacedPositions = null;
+
+  // not serialized, set by manifest readers
+  private String manifestLocation = null;
+  private long manifestPos = -1L;
+
+  TrackingStruct(Types.StructType type) {
+    super(BASE_TYPE, type);
+  }
+
+  private TrackingStruct(TrackingStruct toCopy) {
+    super(toCopy);
+    this.status = toCopy.status;
+    this.snapshotId = toCopy.snapshotId;
+    this.dataSequenceNumber = toCopy.dataSequenceNumber;
+    this.fileSequenceNumber = toCopy.fileSequenceNumber;
+    this.dvSnapshotId = toCopy.dvSnapshotId;
+    this.firstRowId = toCopy.firstRowId;
+    this.deletedPositions =
+        toCopy.deletedPositions != null
+            ? Arrays.copyOf(toCopy.deletedPositions, 
toCopy.deletedPositions.length)
+            : null;
+    this.replacedPositions =
+        toCopy.replacedPositions != null
+            ? Arrays.copyOf(toCopy.replacedPositions, 
toCopy.replacedPositions.length)
+            : null;
+    this.manifestLocation = toCopy.manifestLocation;
+    this.manifestPos = toCopy.manifestPos;
+  }
+
+  void inheritFrom(Tracking manifestTracking) {
+    if (manifestTracking != null) {
+      if (snapshotId == null) {
+        this.snapshotId = manifestTracking.snapshotId();
+      }
+
+      if (status == EntryStatus.ADDED) {
+        if (dataSequenceNumber == null) {
+          this.dataSequenceNumber = manifestTracking.dataSequenceNumber();
+        }
+
+        if (fileSequenceNumber == null) {
+          this.fileSequenceNumber = manifestTracking.dataSequenceNumber();

Review Comment:
   [So I modeled this out on the doc originally (in the description tab of 
sequence_number/file_sequence_number)](https://docs.google.com/document/d/1k4x8utgh41Sn1tr98eynDKCWq035SV_f75rtNHcerVw/edit?tab=t.wd1z5eeup025#heading=h.7uag9iyn76pd)
 and the requirement that I proposed was that the data sequence number must be 
equal to the file sequence number in leaf manifests. 
   
   I can't see a reason why they would ever be different for leaf manifests. 
The sequence # in which we'd add a manifest should remain fixed, and that's 
also the same sequence number for the physical manifest file as well. Even if 
manifest DVs get added, we'd never resequence the data sequence of the manifest 
file as well (at least I wouldn't expect that).
   
   So both of the fields can be present but they must never be different for 
leaf manifests. As far as inheritance goes, I think I agree with inheriting 
file sequence since conceptually that works for both leaf manifests and regular 
file entries.
   
   Not sure if this answers your question @rdblue ? cc @anoopj @stevenzwu 



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