You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2019/06/26 15:31:01 UTC
[incubator-iceberg] branch master updated: Replace hidden
dependency on commons-compress with JDK zip (#232)
This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new 37f6a20 Replace hidden dependency on commons-compress with JDK zip (#232)
37f6a20 is described below
commit 37f6a20f324b23c26773b24259ee78d067d41323
Author: David Phillips <da...@acz.org>
AuthorDate: Wed Jun 26 08:30:57 2019 -0700
Replace hidden dependency on commons-compress with JDK zip (#232)
---
core/src/main/java/org/apache/iceberg/TableMetadataParser.java | 8 ++++----
.../test/java/org/apache/iceberg/TableMetadataParserTest.java | 9 +++++----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/core/src/main/java/org/apache/iceberg/TableMetadataParser.java b/core/src/main/java/org/apache/iceberg/TableMetadataParser.java
index 79c695d..bf06c9e 100644
--- a/core/src/main/java/org/apache/iceberg/TableMetadataParser.java
+++ b/core/src/main/java/org/apache/iceberg/TableMetadataParser.java
@@ -34,8 +34,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
-import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
-import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
import org.apache.hadoop.conf.Configuration;
import org.apache.iceberg.TableMetadata.SnapshotLogEntry;
import org.apache.iceberg.exceptions.RuntimeIOException;
@@ -66,7 +66,7 @@ public class TableMetadataParser {
public static void write(TableMetadata metadata, OutputFile outputFile) {
try (OutputStreamWriter writer = new OutputStreamWriter(
outputFile.location().endsWith(".gz") ?
- new GzipCompressorOutputStream(outputFile.create()) :
+ new GZIPOutputStream(outputFile.create()) :
outputFile.create())) {
JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
generator.useDefaultPrettyPrinter();
@@ -146,7 +146,7 @@ public class TableMetadataParser {
public static TableMetadata read(TableOperations ops, InputFile file) {
try {
InputStream is =
- file.location().endsWith("gz") ? new GzipCompressorInputStream(file.newStream()) : file.newStream();
+ file.location().endsWith("gz") ? new GZIPInputStream(file.newStream()) : file.newStream();
return fromJson(ops, file, JsonUtil.mapper().readValue(is, JsonNode.class));
} catch (IOException e) {
throw new RuntimeIOException(e, "Failed to read file: %s", file);
diff --git a/core/src/test/java/org/apache/iceberg/TableMetadataParserTest.java b/core/src/test/java/org/apache/iceberg/TableMetadataParserTest.java
index e4bfaed..7803877 100644
--- a/core/src/test/java/org/apache/iceberg/TableMetadataParserTest.java
+++ b/core/src/test/java/org/apache/iceberg/TableMetadataParserTest.java
@@ -25,7 +25,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Paths;
-import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.ZipException;
import org.apache.hadoop.conf.Configuration;
import org.apache.iceberg.io.OutputFile;
import org.apache.iceberg.types.Types.BooleanType;
@@ -78,10 +79,10 @@ public class TableMetadataParserTest {
}
private boolean isCompressed(String path) throws IOException {
- try (InputStream ignored = new GzipCompressorInputStream(new FileInputStream(new File(path)))) {
+ try (InputStream ignored = new GZIPInputStream(new FileInputStream(new File(path)))) {
return true;
- } catch (IOException e) {
- if (e.getMessage().equals("Input is not in the .gz format")) {
+ } catch (ZipException e) {
+ if (e.getMessage().equals("Not in GZIP format")) {
return false;
} else {
throw e;