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


##########
core/src/main/java/org/apache/iceberg/V4ManifestWriter.java:
##########
@@ -0,0 +1,393 @@
+/*
+ * 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.Closeable;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.Map;
+import org.apache.iceberg.encryption.EncryptedOutputFile;
+import org.apache.iceberg.encryption.EncryptionKeyMetadata;
+import org.apache.iceberg.encryption.NativeEncryptionOutputFile;
+import org.apache.iceberg.io.FileAppender;
+import org.apache.iceberg.io.OutputFile;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.types.Types;
+
+abstract class V4ManifestWriter implements Closeable {
+  private static final int FORMAT_VERSION = 4;
+  private static final long UNASSIGNED_SEQ = -1L;
+
+  // TODO:
+  // - Relativize paths
+
+  static V4ManifestWriter createRoot(
+      EncryptedOutputFile file,
+      Map<Integer, PartitionSpec> specsById,
+      Types.StructType contentStatsType,
+      Map<String, String> writerProperties,
+      int tableSchemaId,
+      long snapshotId,
+      long sequenceNumber,
+      long firstRowId) {
+    Types.StructType partitionType = 
Partitioning.unionPartitionTypes(specsById.values());
+    return new V4ManifestWriter.RootWriter(
+        file,
+        specsById,
+        partitionType,
+        contentStatsType,
+        writerProperties,
+        tableSchemaId,
+        snapshotId,
+        sequenceNumber,
+        firstRowId);
+  }
+
+  static V4ManifestWriter createLeaf(
+      EncryptedOutputFile file,
+      Map<Integer, PartitionSpec> specsById,
+      Types.StructType contentStatsType,
+      Map<String, String> writerProperties,
+      int tableSchemaId,
+      Long snapshotId) {
+    Types.StructType partitionType = 
Partitioning.unionPartitionTypes(specsById.values());
+    return new V4ManifestWriter.LeafWriter(
+        file,
+        specsById,
+        partitionType,
+        contentStatsType,
+        writerProperties,
+        tableSchemaId,
+        snapshotId);
+  }
+
+  private final OutputFile output;
+  private final EncryptionKeyMetadata keyMetadata;
+  private final Schema manifestSchema;
+  private final Long snapshotId;
+  private final FileAppender<StructLike> writer;
+
+  private boolean closed = false;
+  private int recordCount = 0;
+  private int addedFiles = 0;
+  private int existingFiles = 0;
+  private int deletedFiles = 0;
+  private int replacedFiles = 0;
+  private int modifiedFiles = 0;
+  private long addedRows = 0L;
+  private long existingRows = 0L;
+  private long deletedRows = 0L;
+  private long replacedRows = 0L;
+  private long modifiedRows = 0L;
+  private long minDataSequenceNumber = UNASSIGNED_SEQ;
+  private long unassignedRows = 0L;
+
+  private V4ManifestWriter(
+      EncryptedOutputFile output,
+      Schema manifestSchema,
+      Map<String, String> fileMetadata,
+      Map<String, String> writerProperties,
+      Long snapshotId) {
+    this.output = outputFile(output);
+    this.manifestSchema = manifestSchema;
+    this.keyMetadata = output.keyMetadata();
+    this.snapshotId = snapshotId;
+    this.writer = newAppender(this.output, fileMetadata, writerProperties);
+  }
+
+  protected abstract StructLike prepare(TrackedFile file, Tracking tracking);
+
+  // TODO: add row ID space to spec and ManifestInfo
+  public long assignedRowIds() {

Review Comment:
   I'm going to leaf this as-is for now. The next PR is going to test manifest 
cases in the root and I think it may be useful to have `unassignedRows`. I'll 
either move it or use it in the next commit.



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