diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java index 2b97504..323f2c5 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java @@ -18,9 +18,10 @@ package org.apache.hadoop.hive.ql.exec.vector.expressions; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector; import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor; import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch; @@ -38,17 +39,8 @@ private int startIdx; - private transient static byte[] EMPTY_STRING; - - // Populating the Empty string bytes. Putting it as static since it should be immutable and can - // be shared. - static { - try { - EMPTY_STRING = "".getBytes("UTF-8"); - } catch(UnsupportedEncodingException e) { - e.printStackTrace(); - } - } + private transient static byte[] EMPTY_STRING = + StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8); public StringSubstrColStart(int colNum, int startIdx, int outputColumnNum) { super(outputColumnNum); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java index fff3032..da0516c 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java @@ -18,9 +18,10 @@ package org.apache.hadoop.hive.ql.exec.vector.expressions; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector; import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor; import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch; @@ -42,17 +43,8 @@ private final int length; private final int[] offsetArray; - private transient static byte[] EMPTY_STRING; - - // Populating the Empty string bytes. Putting it as static since it should be immutable and can be - // shared - static { - try { - EMPTY_STRING = "".getBytes("UTF-8"); - } catch(UnsupportedEncodingException e) { - e.printStackTrace(); - } - } + private transient static byte[] EMPTY_STRING = + StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8); public StringSubstrColStartLen(int colNum, int startIdx, int length, int outputColumnNum) { super(outputColumnNum);