anoopj commented on code in PR #15049:
URL: https://github.com/apache/iceberg/pull/15049#discussion_r2991955407


##########
core/src/main/java/org/apache/iceberg/DeletionVector.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.iceberg.types.Types;
+
+/**
+ * Metadata about a deletion vector.
+ *
+ * <p>Tracks where a DV blob can be read. The DV blob follows the format 
defined by the
+ * deletion-vector-v1 blob type in the Puffin spec.
+ */
+interface DeletionVector {
+  Types.NestedField LOCATION =
+      Types.NestedField.required(
+          155, "location", Types.StringType.get(), "Location of the file 
containing the DV");
+  Types.NestedField OFFSET =

Review Comment:
   Field IDs 144 (OFFSET) and 145 (SIZE_IN_BYTES) are reused here. In the v4 
TrackedFile schema, CONTENT_OFFSET and CONTENT_SIZE from DataFile are not 
present at the  top level . The DV struct serves the same purpose, so the IDs 
are semantically aligned. Since 144 and 145 only appear once in the TrackedFile 
schema (inside the DV struct), there's no conflict.
   
   In v1-v3 manifests, these IDs are used by DataFile. In v4 manifests, they're 
used by DeletionVector. The two schemas don't coexist in the same manifest 
format.
   
   Did that make sense?



##########
core/src/main/java/org/apache/iceberg/DeletionVector.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.iceberg.types.Types;
+
+/**
+ * Metadata about a deletion vector (DV) associated with a data file entry.
+ *
+ * <p>In the combined entry model, each DATA entry may optionally carry DV 
information. The DV
+ * content is stored at the specified location, offset, and size.
+ *
+ * <p>This struct may only be defined when content_type is DATA (0), and must 
be null for all other
+ * content types.
+ */
+interface DeletionVector {
+  Types.NestedField LOCATION =
+      Types.NestedField.required(
+          155, "location", Types.StringType.get(), "Location of the file 
containing the DV");

Review Comment:
   Agreed that having a single source of truth for field IDs and a uniqueness 
test would be useful. I think that's better as a follow-up though. 
Consolidating all existing field ID definitions (from DataFile, ManifestFile, 
ManifestEntry, etc.) is a broader refactor.



##########
core/src/main/java/org/apache/iceberg/ManifestInfo.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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;
+
+/** Summary information about a manifest referenced by a v4 root manifest 
entry. */
+interface ManifestInfo {
+  Types.NestedField ADDED_FILES_COUNT =

Review Comment:
    The field IDs are deliberately aligned with ManifestFile for fields that 
represent the same concept (504=added_files_count, 505=existing_files_count, 
etc.). We could reference `ManifestFile`'s constants for the shared fields to 
reduce duplication. However, `ManifestInfo` also has v4-specific fields that 
don't exist in ManifestFile (`replaced_files_count`, `replaced_rows_count` etc, 
which we recently added), and the nullability differs.
   
   I recommend keeping them separate.



##########
core/src/main/java/org/apache/iceberg/TrackedFile.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * 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.Collections;
+import java.util.List;
+import java.util.Set;
+import org.apache.iceberg.stats.ContentStats;
+import org.apache.iceberg.types.Types;
+
+/** A file tracked by a v4 manifest. */
+interface TrackedFile {
+  Types.NestedField TRACKING =
+      Types.NestedField.required(
+          147, "tracking", Tracking.schema(), "Tracking information for this 
entry");
+  Types.NestedField CONTENT_TYPE =
+      Types.NestedField.required(
+          134,
+          "content_type",
+          Types.IntegerType.get(),
+          "Type of content: 0=DATA, 2=EQUALITY_DELETES, 3=DATA_MANIFEST, 
4=DELETE_MANIFEST");
+  Types.NestedField LOCATION =
+      Types.NestedField.required(100, "location", Types.StringType.get(), 
"Location of the file");
+  Types.NestedField FILE_FORMAT =
+      Types.NestedField.required(
+          101,
+          "file_format",
+          Types.StringType.get(),
+          "String file format name: avro, orc, or parquet");
+  Types.NestedField RECORD_COUNT =
+      Types.NestedField.required(
+          103, "record_count", Types.LongType.get(), "Number of records in 
this file");
+  Types.NestedField FILE_SIZE_IN_BYTES =
+      Types.NestedField.required(
+          104, "file_size_in_bytes", Types.LongType.get(), "Total file size in 
bytes");
+  Types.NestedField SPEC_ID =
+      Types.NestedField.optional(
+          141, "spec_id", Types.IntegerType.get(), "Spec ID used to partition 
the file");
+
+  int CONTENT_STATS_ID = 146;
+  String CONTENT_STATS_NAME = "content_stats";
+  String CONTENT_STATS_DOC = "Content statistics for this entry";
+
+  Types.NestedField SORT_ORDER_ID =
+      Types.NestedField.optional(
+          140, "sort_order_id", Types.IntegerType.get(), "ID of the sort order 
for this file");
+  Types.NestedField DELETION_VECTOR =
+      Types.NestedField.optional(
+          148, "deletion_vector", DeletionVector.schema(), "Deletion vector 
for the data file");
+  Types.NestedField MANIFEST_INFO =
+      Types.NestedField.optional(
+          150,
+          "manifest_info",
+          ManifestInfo.schema(),
+          "Metadata fields specific to manifest files");
+  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");
+  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");
+
+  static Types.StructType schemaWithContentStats(Types.StructType 
contentStatsType) {

Review Comment:
   Yes, that's correct. `content_stats` is for the base data file only. When 
column files are added in the future, I would imagine that each column file 
would carry its own stats as part of its metadata within the entry.



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