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


##########
core/src/main/java/org/apache/iceberg/TrackedFileStruct.java:
##########
@@ -0,0 +1,354 @@
+/*
+ * 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 java.util.List;
+import java.util.Locale;
+import java.util.Set;
+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.ArrayUtil;
+import org.apache.iceberg.util.ByteBuffers;
+
+/** Mutable {@link StructLike} implementation of {@link TrackedFile}. */
+class TrackedFileStruct extends SupportsIndexProjection implements 
TrackedFile, Serializable {
+  private static final Types.StructType EMPTY_STRUCT_TYPE = 
Types.StructType.of();
+
+  private static final Types.StructType BASE_TYPE =
+      Types.StructType.of(
+          TrackedFile.TRACKING,
+          TrackedFile.CONTENT_TYPE,
+          TrackedFile.LOCATION,
+          TrackedFile.FILE_FORMAT,
+          TrackedFile.RECORD_COUNT,
+          TrackedFile.FILE_SIZE_IN_BYTES,
+          TrackedFile.SPEC_ID,
+          Types.NestedField.optional(
+              TrackedFile.CONTENT_STATS_ID,
+              TrackedFile.CONTENT_STATS_NAME,
+              EMPTY_STRUCT_TYPE,
+              TrackedFile.CONTENT_STATS_DOC),
+          TrackedFile.SORT_ORDER_ID,
+          TrackedFile.DELETION_VECTOR,
+          TrackedFile.MANIFEST_INFO,
+          TrackedFile.KEY_METADATA,
+          TrackedFile.SPLIT_OFFSETS,
+          TrackedFile.EQUALITY_IDS,
+          MetadataColumns.ROW_POSITION);
+
+  private FileContent contentType = null;
+  private String location = null;
+  private FileFormat fileFormat = null;
+  private long recordCount = -1L;
+  private long fileSizeInBytes = -1L;
+  private Integer specId = null;
+
+  // optional fields
+  private Tracking tracking = null;
+  private ContentStats contentStats = null;
+  private Integer sortOrderId = null;
+  private DeletionVector deletionVector = null;
+  private ManifestInfo manifestInfo = null;
+  private byte[] keyMetadata = null;
+  private long[] splitOffsets = null;
+  private int[] equalityIds = null;
+
+  // not serialized to manifest, set by manifest readers
+  private transient TrackedFile manifestContext = null;
+  private long manifestPos = 0L;
+
+  /** Used by internal readers to instantiate this class with a projection 
schema. */
+  TrackedFileStruct(Types.StructType projection) {
+    super(BASE_TYPE, projection);
+  }
+
+  /** No-projection constructor for direct construction. */
+  TrackedFileStruct() {
+    super(BASE_TYPE.fields().size());
+  }
+
+  /** Copy constructor. */
+  private TrackedFileStruct(TrackedFileStruct toCopy, boolean withStats, 
Set<Integer> statsIds) {
+    super(toCopy);
+    this.contentType = toCopy.contentType;
+    this.location = toCopy.location;
+    this.fileFormat = toCopy.fileFormat;
+    this.recordCount = toCopy.recordCount;
+    this.fileSizeInBytes = toCopy.fileSizeInBytes;
+    this.specId = toCopy.specId;
+
+    this.manifestContext = toCopy.manifestContext;
+    this.manifestPos = toCopy.manifestPos;
+
+    this.tracking = toCopy.tracking != null ? ((TrackingStruct) 
toCopy.tracking).copy() : null;
+    if (tracking != null && manifestContext != null) {
+      ((TrackingStruct) tracking).setManifestContext(manifestContext);
+    }
+
+    this.sortOrderId = toCopy.sortOrderId;
+    this.deletionVector =
+        toCopy.deletionVector != null
+            ? ((DeletionVectorStruct) toCopy.deletionVector).copy()
+            : null;
+
+    if (withStats && toCopy.contentStats != null) {
+      ContentStats filtered = BaseContentStats.buildFrom(toCopy.contentStats, 
statsIds).build();
+      this.contentStats = filtered.fieldStats().isEmpty() ? null : filtered;
+    } else {
+      this.contentStats = null;
+    }
+
+    this.manifestInfo =
+        toCopy.manifestInfo != null ? ((ManifestInfoStruct) 
toCopy.manifestInfo).copy() : null;
+    this.keyMetadata =
+        toCopy.keyMetadata != null
+            ? Arrays.copyOf(toCopy.keyMetadata, toCopy.keyMetadata.length)
+            : null;
+    this.splitOffsets =
+        toCopy.splitOffsets != null
+            ? Arrays.copyOf(toCopy.splitOffsets, toCopy.splitOffsets.length)
+            : null;
+    this.equalityIds =
+        toCopy.equalityIds != null
+            ? Arrays.copyOf(toCopy.equalityIds, toCopy.equalityIds.length)
+            : null;
+  }
+
+  void setManifestContext(TrackedFile manifest) {

Review Comment:
   I think this should be removed (see comment above).



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