You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2021/08/11 00:27:51 UTC

[orc] branch branch-1.6 updated: ORC-929: Fix NaN error at orc-tools meta command (#843)

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-1.6 by this push:
     new 6e29540  ORC-929: Fix NaN error at orc-tools meta command (#843)
6e29540 is described below

commit 6e29540fe2928e98f6b54ae1c5a607c6182b9cfd
Author: William Hyun <wi...@apache.org>
AuthorDate: Mon Aug 9 21:05:52 2021 -0700

    ORC-929: Fix NaN error at orc-tools meta command (#843)
    
    ### What changes were proposed in this pull request?
    
    This PR aims to fix NaN error at orc-tools `meta` command.
    
    ### Why are the changes needed?
    
    To fix invalid output
    
    ```
    $ orc-tools meta zero.orc 2> /dev/null | grep Padding
    Padding length: 0 bytes
    Padding ratio: �%
    ```
    
    ### How was this patch tested?
    Manual.
    
    ```
    $ java -jar tools/target/orc-tools-1.8.0-SNAPSHOT-uber.jar meta ../examples/zero.orc
    ```
    
    (cherry picked from commit c6b10d2d1be71c2e4942f96d101664211491bc43)
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
    (cherry picked from commit c47f07b492dce0da4d79355ea2e0c851f716a32c)
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 java/tools/src/java/org/apache/orc/tools/FileDump.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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 b0c8ecf..189c68a 100644
--- a/java/tools/src/java/org/apache/orc/tools/FileDump.java
+++ b/java/tools/src/java/org/apache/orc/tools/FileDump.java
@@ -436,8 +436,7 @@ public final class FileDump {
     FileSystem fs = file.getFileSystem(conf);
     long fileLen = fs.getFileStatus(file).getLen();
     long paddedBytes = getTotalPaddingSize(reader);
-    // empty ORC file is ~45 bytes. Assumption here is file length always >0
-    double percentPadding = ((double) paddedBytes / (double) fileLen) * 100;
+    double percentPadding = (fileLen == 0) ? 0.0d : 100.0d * paddedBytes / fileLen;
     DecimalFormat format = new DecimalFormat("##.##");
     System.out.println("\nFile length: " + fileLen + " bytes");
     System.out.println("Padding length: " + paddedBytes + " bytes");