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:08:17 UTC
[orc] branch branch-1.7 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.7
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/branch-1.7 by this push:
new c47f07b ORC-929: Fix NaN error at orc-tools meta command (#843)
c47f07b is described below
commit c47f07b492dce0da4d79355ea2e0c851f716a32c
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>
---
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");