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/10 04:06:00 UTC

[orc] branch main 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 main
in repository https://gitbox.apache.org/repos/asf/orc.git


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

commit c6b10d2d1be71c2e4942f96d101664211491bc43
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
    ```
---
 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 74c3b40..771e60e 100644
--- a/java/tools/src/java/org/apache/orc/tools/FileDump.java
+++ b/java/tools/src/java/org/apache/orc/tools/FileDump.java
@@ -437,8 +437,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");