aboutsummaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorRajesh Balamohan <rbalamohan@apache.org>2016-03-04 10:59:40 +0000
committerSean Owen <sowen@cloudera.com>2016-03-04 10:59:40 +0000
commit204b02b56afe358b7f2d403fb6e2b9e8a7122798 (patch)
treeb04f7f3caeddf1a84568c6f1da6ac80d3892f1bc /sql
parentc04dc27cedd3d75781fda4c24da16b6ada44d3e4 (diff)
downloadspark-204b02b56afe358b7f2d403fb6e2b9e8a7122798.tar.gz
spark-204b02b56afe358b7f2d403fb6e2b9e8a7122798.tar.bz2
spark-204b02b56afe358b7f2d403fb6e2b9e8a7122798.zip
[SPARK-12925] Improve HiveInspectors.unwrap for StringObjectInspector.…
Earlier fix did not copy the bytes and it is possible for higher level to reuse Text object. This was causing issues. Proposed fix now copies the bytes from Text. This still avoids the expensive encoding/decoding Author: Rajesh Balamohan <rbalamohan@apache.org> Closes #11477 from rajeshbalamohan/SPARK-12925.2.
Diffstat (limited to 'sql')
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala
index 3e91569109..589862c7c0 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala
@@ -320,9 +320,10 @@ private[hive] trait HiveInspectors {
case hvoi: HiveCharObjectInspector =>
UTF8String.fromString(hvoi.getPrimitiveJavaObject(data).getValue)
case x: StringObjectInspector if x.preferWritable() =>
- // Text is in UTF-8 already. No need to convert again via fromString
+ // Text is in UTF-8 already. No need to convert again via fromString. Copy bytes
val wObj = x.getPrimitiveWritableObject(data)
- UTF8String.fromBytes(wObj.getBytes, 0, wObj.getLength)
+ val result = wObj.copyBytes()
+ UTF8String.fromBytes(result, 0, result.length)
case x: StringObjectInspector =>
UTF8String.fromString(x.getPrimitiveJavaObject(data))
case x: IntObjectInspector if x.preferWritable() => x.get(data)