Repository: hive Updated Branches: refs/heads/master 653b85899 -> fb86e89a1
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/fb86e89a Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/fb86e89a Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/fb86e89a Branch: refs/heads/master Commit: fb86e89a15db784fb60d090a50562cdb5776786a Parents: 653b858 Author: Prasanth Jayachandran <[email protected]> Authored: Mon Aug 15 14:28:29 2016 -0700 Committer: Prasanth Jayachandran <[email protected]> Committed: Mon Aug 15 14:28:29 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/fb86e89a/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/fb86e89a/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
