parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject parquet-mr git commit: PARQUET-311: Fix NPE when debug logging metadata
Date Mon, 22 Jun 2015 21:28:46 GMT
Repository: parquet-mr
Updated Branches:
  refs/heads/master 29283b775 -> 89321a2de


PARQUET-311: Fix NPE when debug logging metadata

Fixes the issue reported at https://issues.apache.org/jira/browse/PARQUET-311

Author: Nezih Yigitbasi <nyigitbasi@netflix.com>

Closes #221 from nezihyigitbasi/debug-log-fix and squashes the following commits:

59129ed [Nezih Yigitbasi] PARQUET-311: Fix NPE when debug logging metadata


Project: http://git-wip-us.apache.org/repos/asf/parquet-mr/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-mr/commit/89321a2d
Tree: http://git-wip-us.apache.org/repos/asf/parquet-mr/tree/89321a2d
Diff: http://git-wip-us.apache.org/repos/asf/parquet-mr/diff/89321a2d

Branch: refs/heads/master
Commit: 89321a2dee438328e75a11954e972175c78f0a2a
Parents: 29283b7
Author: Nezih Yigitbasi <nyigitbasi@netflix.com>
Authored: Mon Jun 22 14:28:42 2015 -0700
Committer: Ryan Blue <blue@apache.org>
Committed: Mon Jun 22 14:28:42 2015 -0700

----------------------------------------------------------------------
 .../column/statistics/BinaryStatistics.java     |  4 +--
 .../converter/TestParquetMetadataConverter.java | 31 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/89321a2d/parquet-column/src/main/java/org/apache/parquet/column/statistics/BinaryStatistics.java
----------------------------------------------------------------------
diff --git a/parquet-column/src/main/java/org/apache/parquet/column/statistics/BinaryStatistics.java
b/parquet-column/src/main/java/org/apache/parquet/column/statistics/BinaryStatistics.java
index b2d9b55..6341f96 100644
--- a/parquet-column/src/main/java/org/apache/parquet/column/statistics/BinaryStatistics.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/statistics/BinaryStatistics.java
@@ -53,12 +53,12 @@ public class BinaryStatistics extends Statistics<Binary> {
 
   @Override
   public byte[] getMaxBytes() {
-    return max.getBytes();
+    return max == null ? null : max.getBytes();
   }
 
   @Override
   public byte[] getMinBytes() {
-    return min.getBytes();
+    return min == null ? null : min.getBytes();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/89321a2d/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
----------------------------------------------------------------------
diff --git a/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
b/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
index b4f56fa..1a740fe 100644
--- a/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
+++ b/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
@@ -19,6 +19,7 @@
 package org.apache.parquet.format.converter;
 
 import static java.util.Collections.emptyList;
+import static org.apache.parquet.schema.MessageTypeParser.parseMessageType;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 import static org.apache.parquet.format.CompressionCodec.UNCOMPRESSED;
@@ -34,11 +35,19 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Random;
 import java.util.Set;
 import java.util.TreeSet;
 
+import org.apache.parquet.column.statistics.BinaryStatistics;
+import org.apache.parquet.hadoop.metadata.BlockMetaData;
+import org.apache.parquet.hadoop.metadata.ColumnChunkMetaData;
+import org.apache.parquet.hadoop.metadata.ColumnPath;
+import org.apache.parquet.hadoop.metadata.CompressionCodecName;
+import org.apache.parquet.hadoop.metadata.ParquetMetadata;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -252,4 +261,26 @@ public class TestParquetMetadataConverter {
     }
   }
 
+  @Test
+  public void testNullFieldMetadataDebugLogging() throws NoSuchFieldException, IllegalAccessException,
IOException {
+    MessageType schema = parseMessageType("message test { optional binary some_null_field;
}");
+    org.apache.parquet.hadoop.metadata.FileMetaData fileMetaData = new org.apache.parquet.hadoop.metadata.FileMetaData(schema,
new HashMap<String, String>(), null);
+    List<BlockMetaData> blockMetaDataList = new ArrayList<BlockMetaData>();
+    BlockMetaData blockMetaData = new BlockMetaData();
+    blockMetaData.addColumn(createColumnChunkMetaData());
+    blockMetaDataList.add(blockMetaData);
+    ParquetMetadata metadata = new ParquetMetadata(fileMetaData, blockMetaDataList);
+    ParquetMetadata.toJSON(metadata);
+  }
+
+  private ColumnChunkMetaData createColumnChunkMetaData() {
+    Set<Encoding> e = new HashSet<Encoding>();
+    PrimitiveTypeName t = PrimitiveTypeName.BINARY;
+    ColumnPath p = ColumnPath.get("foo");
+    CompressionCodecName c = CompressionCodecName.GZIP;
+    BinaryStatistics s = new BinaryStatistics();
+    ColumnChunkMetaData md = ColumnChunkMetaData.get(p, t, c, e, s,
+            0, 0, 0, 0, 0);
+    return md;
+  }
 }


Mime
View raw message