wypoon commented on code in PR #6799:
URL: https://github.com/apache/iceberg/pull/6799#discussion_r1107805999


##########
core/src/test/java/org/apache/iceberg/TestManifestListWriter.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.IOException;
+import java.util.Map;
+import org.apache.iceberg.avro.AvroIterable;
+import org.apache.iceberg.io.InputFile;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class TestManifestListWriter extends TableTestBase {
+
+  @Parameterized.Parameters(name = "formatVersion = {0}")
+  public static Object[] parameters() {
+    return new Object[] {1, 2};
+  }
+
+  public TestManifestListWriter(int formatVersion) {
+    super(formatVersion);
+  }
+
+  @Test
+  public void testWriteManifestListWithCompression() throws IOException {
+    validateManifestListCompressionCodec(
+        compressionCodec -> {
+          ManifestFile manifest = writeManifest(SNAPSHOT_ID, compressionCodec, 
FILE_A);
+          return writeManifestList(compressionCodec, manifest);
+        });
+  }
+
+  @Test
+  public void testWriteDeleteManifestListWithCompression() throws IOException {
+    Assume.assumeTrue("delete files are only written for format version > 1", 
formatVersion > 1);
+    validateManifestListCompressionCodec(
+        compressionCodec -> {
+          ManifestFile manifest = writeManifest(SNAPSHOT_ID, compressionCodec, 
FILE_A);
+          ManifestFile deleteManifest =
+              writeDeleteManifest(formatVersion, SNAPSHOT_ID, 
compressionCodec, FILE_A_DELETES);
+          return writeManifestList(compressionCodec, manifest, deleteManifest);
+        });
+  }
+
+  void validateManifestListCompressionCodec(
+      CheckedFunction<String, InputFile> createManifestListFunc) throws 
IOException {
+    for (Map.Entry<String, String> entry : CODEC_METADATA_MAPPING.entrySet()) {
+      String codec = entry.getKey();
+      String expectedCodecValue = entry.getValue();
+
+      InputFile manifestList = createManifestListFunc.apply(codec);
+      try (AvroIterable<ManifestFile> reader = 
ManifestLists.manifestFileIterable(manifestList)) {
+        Map<String, String> metadata = reader.getMetadata();
+        Assert.assertEquals(

Review Comment:
   Adopted.



##########
core/src/test/java/org/apache/iceberg/TestManifestWriter.java:
##########
@@ -234,4 +251,24 @@ private DataFile newFile(long recordCount, StructLike 
partition) {
     }
     return builder.build();
   }
+
+  <F extends ContentFile<F>> void validateManifestCompressionCodec(
+      CheckedFunction<String, ManifestFile> createManifestFunc,
+      CheckedFunction<ManifestFile, ManifestReader<F>> manifestReaderFunc)
+      throws IOException {
+    for (Map.Entry<String, String> entry : CODEC_METADATA_MAPPING.entrySet()) {
+      String codec = entry.getKey();
+      String expectedCodecValue = entry.getValue();
+
+      ManifestFile manifest = createManifestFunc.apply(codec);
+
+      try (ManifestReader<F> reader = manifestReaderFunc.apply(manifest)) {
+        Map<String, String> metadata = reader.metadata();
+        Assert.assertEquals(

Review Comment:
   Adopted.



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