Repository: hive Updated Branches: refs/heads/branch-1 3208897f7 -> 78b17ae66
HIVE-14533: improve performance of enforceMaxLength in HiveCharWritable/HiveVarcharWritable (Thomas Friedrich reviewed by Prasanth Jayachandran) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/78b17ae6 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/78b17ae6 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/78b17ae6 Branch: refs/heads/branch-1 Commit: 78b17ae662d062c8c042ae57cfdfae6c666379a5 Parents: 3208897 Author: Prasanth Jayachandran <prasan...@apache.org> Authored: Mon Aug 15 14:28:29 2016 -0700 Committer: Prasanth Jayachandran <prasan...@apache.org> Committed: Mon Aug 15 14:29:05 2016 -0700 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hive/serde2/io/HiveCharWritable.java | 3 ++- .../org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/78b17ae6/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveCharWritable.java ---------------------------------------------------------------------- diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveCharWritable.java b/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveCharWritable.java index 2aaa90c..2236a87 100644 --- a/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveCharWritable.java +++ b/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveCharWritable.java @@ -73,7 +73,8 @@ public class HiveCharWritable extends HiveBaseCharWritable } public void enforceMaxLength(int maxLength) { - set(getHiveChar(), maxLength); + if (getCharacterLength()!=maxLength) + set(getHiveChar(), maxLength); } public Text getStrippedValue() { http://git-wip-us.apache.org/repos/asf/hive/blob/78b17ae6/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java ---------------------------------------------------------------------- diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java b/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java index 2e24730..ae53bec 100644 --- a/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java +++ b/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java @@ -65,7 +65,8 @@ public class HiveVarcharWritable extends HiveBaseCharWritable public void enforceMaxLength(int maxLength) { // Might be possible to truncate the existing Text value, for now just do something simple. - set(getHiveVarchar(), maxLength); + if (value.getLength()>maxLength && getCharacterLength()>maxLength) + set(getHiveVarchar(), maxLength); } @Override