orc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject orc git commit: ORC-223: FileDump utility should print user metadata
Date Tue, 15 Aug 2017 18:39:25 GMT
Repository: orc
Updated Branches:
  refs/heads/branch-1.4 3efeca3ea -> 719ec5992


ORC-223: FileDump utility should print user metadata

Fixed #157

Signed-off-by: Owen O'Malley <omalley@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/719ec599
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/719ec599
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/719ec599

Branch: refs/heads/branch-1.4
Commit: 719ec599291db746e778d595337ca32f1daba826
Parents: 3efeca3
Author: Eugene Koifman <ekoifman@hortonworks.com>
Authored: Mon Aug 14 15:51:25 2017 -0700
Committer: Owen O'Malley <omalley@apache.org>
Committed: Tue Aug 15 11:34:51 2017 -0700

----------------------------------------------------------------------
 java/tools/src/java/org/apache/orc/tools/FileDump.java | 13 ++++++++++---
 .../src/test/org/apache/orc/tools/TestFileDump.java    |  5 +++++
 java/tools/src/test/resources/orc-file-dump.out        |  6 +++++-
 3 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/719ec599/java/tools/src/java/org/apache/orc/tools/FileDump.java
----------------------------------------------------------------------
diff --git a/java/tools/src/java/org/apache/orc/tools/FileDump.java b/java/tools/src/java/org/apache/orc/tools/FileDump.java
index e187d7e..dc89a31 100644
--- a/java/tools/src/java/org/apache/orc/tools/FileDump.java
+++ b/java/tools/src/java/org/apache/orc/tools/FileDump.java
@@ -18,6 +18,7 @@
 package org.apache.orc.tools;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
@@ -404,9 +405,15 @@ public final class FileDump {
     System.out.println("\nFile length: " + fileLen + " bytes");
     System.out.println("Padding length: " + paddedBytes + " bytes");
     System.out.println("Padding ratio: " + format.format(percentPadding) + "%");
-    AcidStats acidStats = OrcAcidUtils.parseAcidStats(reader);
-    if (acidStats != null) {
-      System.out.println("ACID stats:" + acidStats);
+    //print out any user metadata properties
+    List<String> keys = reader.getMetadataKeys();
+    for(int i = 0; i < keys.size(); i++) {
+      if(i == 0) {
+        System.out.println("\nUser Metadata:");
+      }
+      ByteBuffer byteBuffer = reader.getMetadataValue(keys.get(i));
+      System.out.println("  " + keys.get(i) + "="
+        + StandardCharsets.UTF_8.decode(byteBuffer));
     }
     rows.close();
   }

http://git-wip-us.apache.org/repos/asf/orc/blob/719ec599/java/tools/src/test/org/apache/orc/tools/TestFileDump.java
----------------------------------------------------------------------
diff --git a/java/tools/src/test/org/apache/orc/tools/TestFileDump.java b/java/tools/src/test/org/apache/orc/tools/TestFileDump.java
index 1556ab4..3559b6d 100644
--- a/java/tools/src/test/org/apache/orc/tools/TestFileDump.java
+++ b/java/tools/src/test/org/apache/orc/tools/TestFileDump.java
@@ -28,6 +28,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.sql.Date;
 import java.sql.Timestamp;
 import java.util.Arrays;
@@ -237,6 +238,10 @@ public class TestFileDump {
     if (batch.size > 0) {
       writer.addRowBatch(batch);
     }
+    writer.addUserMetadata("hive.acid.key.index",
+      StandardCharsets.UTF_8.encode("1,1,1;2,3,5;"));
+    writer.addUserMetadata("some.user.property",
+      StandardCharsets.UTF_8.encode("foo#bar$baz&"));
     writer.close();
     assertEquals(2079000, writer.getRawDataSize());
     assertEquals(21000, writer.getNumberOfRows());

http://git-wip-us.apache.org/repos/asf/orc/blob/719ec599/java/tools/src/test/resources/orc-file-dump.out
----------------------------------------------------------------------
diff --git a/java/tools/src/test/resources/orc-file-dump.out b/java/tools/src/test/resources/orc-file-dump.out
index 51105f0..cd4bd23 100644
--- a/java/tools/src/test/resources/orc-file-dump.out
+++ b/java/tools/src/test/resources/orc-file-dump.out
@@ -188,8 +188,12 @@ Stripes:
     Row group indices for column 3:
       Entry 0: count: 1000 hasNull: false min: Darkness, max: worst sum: 3866 positions:
0,0,0
 
-File length: 270923 bytes
+File length: 270994 bytes
 Padding length: 0 bytes
 Padding ratio: 0%
+
+User Metadata:
+  hive.acid.key.index=1,1,1;2,3,5;
+  some.user.property=foo#bar$baz&
 ________________________________________________________________________________________________________________________
 


Mime
View raw message