amogh-jahagirdar commented on code in PR #5893:
URL: https://github.com/apache/iceberg/pull/5893#discussion_r1012480060


##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -248,19 +270,26 @@ protected ManifestEntry<DeleteFile> 
prepare(ManifestEntry<DeleteFile> entry) {
 
     @Override
     protected FileAppender<ManifestEntry<DeleteFile>> newAppender(
-        PartitionSpec spec, OutputFile file) {
+        PartitionSpec spec, OutputFile file, String compressionCodec, Integer 
compressionLevel) {
       Schema manifestSchema = V2Metadata.entrySchema(spec.partitionType());
       try {
-        return Avro.write(file)
-            .schema(manifestSchema)
-            .named("manifest_entry")
-            .meta("schema", SchemaParser.toJson(spec.schema()))
-            .meta("partition-spec", PartitionSpecParser.toJsonFields(spec))
-            .meta("partition-spec-id", String.valueOf(spec.specId()))
-            .meta("format-version", "2")
-            .meta("content", "deletes")
-            .overwrite()
-            .build();
+        Avro.WriteBuilder builder =
+            Avro.write(file)
+                .schema(manifestSchema)
+                .named("manifest_entry")
+                .meta("schema", SchemaParser.toJson(spec.schema()))
+                .meta("partition-spec", PartitionSpecParser.toJsonFields(spec))
+                .meta("partition-spec-id", String.valueOf(spec.specId()))
+                .meta("format-version", "2")
+                .meta("content", "deletes")
+                .overwrite();
+        if (compressionCodec != null) {
+          builder.set(TableProperties.AVRO_COMPRESSION, compressionCodec);
+        }
+        if (compressionLevel != null) {
+          builder.set(TableProperties.AVRO_COMPRESSION_LEVEL, 
compressionLevel.toString());
+        }

Review Comment:
   Same new line



##########
core/src/main/java/org/apache/iceberg/util/NumberUtil.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.util;
+
+public class NumberUtil {
+
+  private NumberUtil() {}
+
+  /**
+   * @param value the string to convert, can be null
+   * @return parsed integer, returns null if the string is null
+   */
+  public static Integer createInteger(String value) {
+    if (value == null) {
+      return null;
+    }
+    return Integer.parseInt(value);
+  }

Review Comment:
   Do we actually need this or is there another util where the function can go? 
At minimum IMO shouldn't be public



##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -214,19 +224,26 @@ protected ManifestEntry<DataFile> 
prepare(ManifestEntry<DataFile> entry) {
 
     @Override
     protected FileAppender<ManifestEntry<DataFile>> newAppender(
-        PartitionSpec spec, OutputFile file) {
+        PartitionSpec spec, OutputFile file, String compressionCodec, Integer 
compressionLevel) {
       Schema manifestSchema = V2Metadata.entrySchema(spec.partitionType());
       try {
-        return Avro.write(file)
-            .schema(manifestSchema)
-            .named("manifest_entry")
-            .meta("schema", SchemaParser.toJson(spec.schema()))
-            .meta("partition-spec", PartitionSpecParser.toJsonFields(spec))
-            .meta("partition-spec-id", String.valueOf(spec.specId()))
-            .meta("format-version", "2")
-            .meta("content", "data")
-            .overwrite()
-            .build();
+        Avro.WriteBuilder builder =
+            Avro.write(file)
+                .schema(manifestSchema)
+                .named("manifest_entry")
+                .meta("schema", SchemaParser.toJson(spec.schema()))
+                .meta("partition-spec", PartitionSpecParser.toJsonFields(spec))
+                .meta("partition-spec-id", String.valueOf(spec.specId()))
+                .meta("format-version", "2")
+                .meta("content", "data")
+                .overwrite();
+        if (compressionCodec != null) {
+          builder.set(TableProperties.AVRO_COMPRESSION, compressionCodec);
+        }
+        if (compressionLevel != null) {
+          builder.set(TableProperties.AVRO_COMPRESSION_LEVEL, 
compressionLevel.toString());
+        }

Review Comment:
   Nit: new line between the if blocks and the next statement



##########
core/src/main/java/org/apache/iceberg/ManifestListWriter.java:
##########
@@ -126,15 +155,25 @@ protected ManifestFile prepare(ManifestFile manifest) {
     }
 
     @Override
-    protected FileAppender<ManifestFile> newAppender(OutputFile file, 
Map<String, String> meta) {
+    protected FileAppender<ManifestFile> newAppender(
+        OutputFile file,
+        Map<String, String> meta,
+        String compressionCodec,
+        Integer compressionLevel) {
       try {
-        return Avro.write(file)
-            .schema(V1Metadata.MANIFEST_LIST_SCHEMA)
-            .named("manifest_file")
-            .meta(meta)
-            .overwrite()
-            .build();
-
+        Avro.WriteBuilder builder =
+            Avro.write(file)
+                .schema(V1Metadata.MANIFEST_LIST_SCHEMA)
+                .named("manifest_file")
+                .meta(meta)
+                .overwrite();
+        if (compressionCodec != null) {
+          builder.set(TableProperties.AVRO_COMPRESSION, compressionCodec);
+        }
+        if (compressionLevel != null) {
+          builder.set(TableProperties.AVRO_COMPRESSION_LEVEL, 
compressionLevel.toString());
+        }

Review Comment:
   Nit: newline between blocks and the next statement
   
   ```
       if (compressionCodec != null) {
         builder.set(TableProperties.AVRO_COMPRESSION, compressionCodec);
       }
       
       if (compressionLevel != null) {
         builder.set(TableProperties.AVRO_COMPRESSION_LEVEL, 
compressionLevel.toString());
       }
       
       return builder.build();
   ```



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to