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

william 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 f89bf29  ORC-847: Do Not Create Empty Array in 
StringGroupFromBinaryTreeReader
f89bf29 is described below

commit f89bf29240d31d18ca880a4ed6fec33b2e488ec3
Author: David Mollitor <[email protected]>
AuthorDate: Tue Jul 13 22:24:12 2021 -0400

    ORC-847: Do Not Create Empty Array in StringGroupFromBinaryTreeReader
    
    Use a constant value in StringGroupFromBinaryTreeReader instead of 
instantiating new arrays.
    
    Nit performance.
    
    No changes to functionality. Use existing unit tests.
    
    Closes #750
    
    Signed-off-by: William Hyun <[email protected]>
---
 java/core/src/java/org/apache/orc/impl/ConvertTreeReaderFactory.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/java/core/src/java/org/apache/orc/impl/ConvertTreeReaderFactory.java 
b/java/core/src/java/org/apache/orc/impl/ConvertTreeReaderFactory.java
index 3e9906f..bfd51ea 100644
--- a/java/core/src/java/org/apache/orc/impl/ConvertTreeReaderFactory.java
+++ b/java/core/src/java/org/apache/orc/impl/ConvertTreeReaderFactory.java
@@ -33,6 +33,7 @@ import java.time.temporal.ChronoField;
 import java.util.EnumMap;
 import java.util.TimeZone;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.ColumnVector;
@@ -1397,7 +1398,7 @@ public class ConvertTreeReaderFactory extends 
TreeReaderFactory {
       byte[] bytes = inBytesColVector.vector[elementNum];
       int start = inBytesColVector.start[elementNum];
       int length = inBytesColVector.length[elementNum];
-      byte[] string = new byte[length == 0 ? 0 : 3 * length - 1];
+      final byte[] string = (length == 0) ? ArrayUtils.EMPTY_BYTE_ARRAY : new 
byte[3 * length - 1];
       for(int p = 0; p < string.length; p += 2) {
         if (p != 0) {
           string[p++] = ' ';

Reply via email to