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 7566d57 ORC-833: Calculate nextVector Batch Size Once (#738)
7566d57 is described below
commit 7566d57e8a71eed8f802026c84be734e9152f565
Author: belugabehr <[email protected]>
AuthorDate: Wed Jul 7 17:18:38 2021 -0400
ORC-833: Calculate nextVector Batch Size Once (#738)
### What changes were proposed in this pull request?
The number of iterations of the loops in RunLengthIntegerReaderV2
nextVector look at two distinct, but known, values. Instead of check each value
in each loop, pre-compute the batch size.
### Why are the changes needed?
Code clarity, and if the optimizer doesn't already do it automagically,
saves a few branches.
### How was this patch tested?
No changes in functionality. Uses existing unit tests.
---
.../org/apache/orc/impl/RunLengthIntegerReaderV2.java | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git
a/java/core/src/java/org/apache/orc/impl/RunLengthIntegerReaderV2.java
b/java/core/src/java/org/apache/orc/impl/RunLengthIntegerReaderV2.java
index aaed5db..bf96d2b 100644
--- a/java/core/src/java/org/apache/orc/impl/RunLengthIntegerReaderV2.java
+++ b/java/core/src/java/org/apache/orc/impl/RunLengthIntegerReaderV2.java
@@ -390,20 +390,15 @@ public class RunLengthIntegerReaderV2 implements
IntegerReader {
}
@Override
- public void nextVector(ColumnVector vector,
- int[] data,
- int size) throws IOException {
+ public void nextVector(ColumnVector vector, int[] data, int size) throws
IOException {
+ final int batchSize = Math.min(data.length, size);
if (vector.noNulls) {
- for(int r=0; r < data.length && r < size; ++r) {
+ for (int r = 0; r < batchSize; ++r) {
data[r] = (int) next();
}
} else if (!(vector.isRepeating && vector.isNull[0])) {
- for(int r=0; r < data.length && r < size; ++r) {
- if (!vector.isNull[r]) {
- data[r] = (int) next();
- } else {
- data[r] = 1;
- }
+ for (int r = 0; r < batchSize; ++r) {
+ data[r] = (vector.isNull[r]) ? 1 : (int) next();
}
}
}