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


##########
api/src/main/java/org/apache/iceberg/TrackedFile.java:
##########
@@ -0,0 +1,268 @@
+/*
+ * 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 java.util.List;
+import org.apache.iceberg.types.Types;
+
+/**
+ * Represents a V4 content entry in a manifest file.
+ *
+ * <p>TrackedFile is the V4 equivalent of ContentFile. It provides a unified 
representation for all
+ * entry types in a V4 manifest: data files, delete files, manifests, and 
deletion vectors.
+ *
+ * @param <F> the concrete class of a TrackedFile instance
+ */
+public interface TrackedFile<F> {
+  // Field IDs from V4 specification
+  Types.NestedField CONTENT_TYPE =
+      Types.NestedField.required(
+          134,
+          "content_type",
+          Types.IntegerType.get(),
+          "Type of content: 0=DATA, 1=POSITION_DELETES, 2=EQUALITY_DELETES, 
3=DATA_MANIFEST, 4=DELETE_MANIFEST, 5=MANIFEST_DV");
+  Types.NestedField LOCATION =
+      Types.NestedField.optional(
+          100,
+          "location",
+          Types.StringType.get(),
+          "Location of the file. Optional if content_type is 5 and 
deletion_vector.inline_content is not null");
+  Types.NestedField FILE_FORMAT =
+      Types.NestedField.required(
+          101,
+          "file_format",
+          Types.StringType.get(),
+          "String file format name: avro, orc, parquet, or puffin");
+  Types.NestedField PARTITION_SPEC_ID =
+      Types.NestedField.required(
+          148,
+          "partition_spec_id",
+          Types.IntegerType.get(),
+          "ID of partition spec used to write manifest or data/delete files");
+  Types.NestedField SORT_ORDER_ID =
+      Types.NestedField.optional(
+          140,
+          "sort_order_id",
+          Types.IntegerType.get(),
+          "ID representing sort order for this file. Can only be set if 
content_type is 0");
+  Types.NestedField RECORD_COUNT =
+      Types.NestedField.required(
+          103,
+          "record_count",
+          Types.LongType.get(),
+          "Number of records in this file, or the cardinality of a deletion 
vector");
+  Types.NestedField FILE_SIZE_IN_BYTES =
+      Types.NestedField.optional(
+          104,
+          "file_size_in_bytes",
+          Types.LongType.get(),
+          "Total file size in bytes. Must be defined if location is defined");
+  Types.NestedField KEY_METADATA =
+      Types.NestedField.optional(
+          131,
+          "key_metadata",
+          Types.BinaryType.get(),
+          "Implementation-specific key metadata for encryption");
+  Types.NestedField SPLIT_OFFSETS =
+      Types.NestedField.optional(
+          132,
+          "split_offsets",
+          Types.ListType.ofRequired(133, Types.LongType.get()),
+          "Split offsets for the data file. Must be sorted ascending");
+  Types.NestedField EQUALITY_IDS =
+      Types.NestedField.optional(
+          135,
+          "equality_ids",
+          Types.ListType.ofRequired(136, Types.IntegerType.get()),
+          "Field ids used to determine row equality in equality delete files. 
Required when content=2");
+  Types.NestedField REFERENCED_FILE =
+      Types.NestedField.optional(
+          143,
+          "referenced_file",
+          Types.StringType.get(),
+          "Location of data file that a DV references if content_type is 1 or 
5."
+              + " Location of affiliated data manifest if content_type is 4 or 
null if delete manifest is unaffiliated");
+
+  /**
+   * Returns the path of the manifest which this file is referenced in or null 
if it was not read
+   * from a manifest.
+   */
+  String manifestLocation();
+
+  /**
+   * Returns the tracking information for this entry.
+   *
+   * <p>Contains status, snapshot ID, sequence numbers, and first-row-id. 
Optional - may be null if
+   * tracking info is inherited.
+   */
+  TrackingInfo trackingInfo();

Review Comment:
   Let's just assign it now and update the proposal. I also have example 
assignments in my exploration if you want to be consistent:
   
   ```rust
   fn tracked_file_write_schema(
       table_schema: &Schema,
       stats_modes: Option<&HashMap<FieldId, StatsMode>>,
   ) -> Schema {
       let default = HashMap::from_iter((0..=32).into_iter().map(|id| (id, 
DEFAULT_STATS_MODE)));
       let modes: &HashMap<FieldId, StatsMode> = stats_modes.unwrap_or_else(|| 
&default);
   
       StructType::new([
           required("tracking_info", tracking_info_schema(), 147), // TODO: 
assigned ID
           required("content", DataType::INTEGER, 134),            // now 
required!
           required("location", DataType::STRING, 100),
           required("file_format", DataType::STRING, 101),
           required("record_count", DataType::LONG, 103),
           required("file_size_in_bytes", DataType::LONG, 104),
           required(
               "content_stats",
               content_stats_schema(table_schema, modes),
               146,
           ), // TODO: ID is from stats proposal
           optional("key_metadata", DataType::BINARY, 131),
           optional("split_offsets", ArrayType::new(DataType::LONG, false), 
132), // TODO: missing element ID (133)
           optional("content_slice", slice_schema(), 148),                      
  // TODO: assigned ID
           optional("referenced_file", DataType::STRING, 143),
           optional("manifest_stats", manifest_stats_schema(), 149), // TODO: 
assigned ID
           optional("min_sequence_number", DataType::LONG, 516),
       ])
   }
   ```



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