You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ZhangXin (JIRA)" <ji...@apache.org> on 2019/02/24 07:33:00 UTC
[jira] [Updated] (HIVE-21313) Use faster function to prevent
copying immutable byte array twice
[ https://issues.apache.org/jira/browse/HIVE-21313?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ZhangXin updated HIVE-21313:
----------------------------
Description:
In file ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorAssignRow.java
We may find code like this:
```
Text text = (Text) convertTargetWritable;
if (text == null) {
text = new Text();
}
text.set(string);
((BytesColumnVector) columnVector).setVal(
batchIndex, text.getBytes(), 0, text.getLength());
```
Using `setVal` method can copy the bytes array generated by `text.getBytes()`. This is totally unnecessary at all. Since the bytes array is immutable, we can just use `setRef` method to point to the specific byte array, which will also lower the memory usage.
Summary: Use faster function to prevent copying immutable byte array twice (was: Use faster function to revent)
> Use faster function to prevent copying immutable byte array twice
> -----------------------------------------------------------------
>
> Key: HIVE-21313
> URL: https://issues.apache.org/jira/browse/HIVE-21313
> Project: Hive
> Issue Type: Improvement
> Reporter: ZhangXin
> Priority: Major
>
> In file ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorAssignRow.java
> We may find code like this:
> ```
> Text text = (Text) convertTargetWritable;
> if (text == null) {
> text = new Text();
> }
> text.set(string);
> ((BytesColumnVector) columnVector).setVal(
> batchIndex, text.getBytes(), 0, text.getLength());
> ```
>
> Using `setVal` method can copy the bytes array generated by `text.getBytes()`. This is totally unnecessary at all. Since the bytes array is immutable, we can just use `setRef` method to point to the specific byte array, which will also lower the memory usage.
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)