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/30 04:01:44 UTC
[orc] branch main updated: ORC-975: Avoid double counting
closestFixedBits (#886)
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 fbc223c ORC-975: Avoid double counting closestFixedBits (#886)
fbc223c is described below
commit fbc223cf668a9591eed81932a9ebe7a1f25752c3
Author: guiyanakaung <gu...@gmail.com>
AuthorDate: Mon Aug 30 12:01:34 2021 +0800
ORC-975: Avoid double counting closestFixedBits (#886)
### What changes were proposed in this pull request?
```
310 int idx = encodeBitWidth(findClosestNumBits(data[i]));
```
```
public int encodeBitWidth(int n) {
n = getClosestFixedBits(n);
.....
}
```
```
public int findClosestNumBits(long value) {
final int numBits = 64 - Long.numberOfLeadingZeros(value);
return getClosestFixedBits(numBits);
}
```
getClosestFixedBits is called twice.
Extracts the new method findNumBits from findClosestNumBits. Avoid double counting closestFixedBits.
### Why are the changes needed?
Avoid redundant calls.
### How was this patch tested?
Pass the CIs.
---
java/core/src/java/org/apache/orc/impl/SerializationUtils.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/java/core/src/java/org/apache/orc/impl/SerializationUtils.java b/java/core/src/java/org/apache/orc/impl/SerializationUtils.java
index 50740ae..262a1e5 100644
--- a/java/core/src/java/org/apache/orc/impl/SerializationUtils.java
+++ b/java/core/src/java/org/apache/orc/impl/SerializationUtils.java
@@ -270,8 +270,11 @@ public final class SerializationUtils {
* @return bits required to store value
*/
public int findClosestNumBits(long value) {
- final int numBits = 64 - Long.numberOfLeadingZeros(value);
- return getClosestFixedBits(numBits);
+ return getClosestFixedBits(findNumBits(value));
+ }
+
+ private int findNumBits(long value) {
+ return 64 - Long.numberOfLeadingZeros(value);
}
/**
@@ -307,7 +310,7 @@ public final class SerializationUtils {
// compute the histogram
for(int i = offset; i < (offset + length); i++) {
- int idx = encodeBitWidth(findClosestNumBits(data[i]));
+ int idx = encodeBitWidth(findNumBits(data[i]));
this.histBuffer[idx] += 1;
}