-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-27370: support 4 bytes characters #5624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@difin, please take a look when you have time |
@deniskuzZ Sorry, I also overlooked this comments. I fixed it. |
|
return b; | ||
} | ||
|
||
private int craetePos(int pos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: createPos()
, maybe better rename to adjustStartPos()
} | ||
|
||
@Override | ||
public StatEstimator getStatEstimator() { | ||
return new SubStrStatEstimator(); | ||
} | ||
|
||
private byte[] arrayCopy(byte[] src, int pos, int len) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use Arrays.copyOfRange(T[] original, int from, int to)
?
if (len <= 0) { | ||
return new BytesWritable(); | ||
} | ||
|
||
int[] index = makeIndex(pos, len, bw.getLength()); | ||
if (index == null) { | ||
byte[] b = Arrays.copyOf(bw.getBytes(), bw.getLength()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to create copy of bw?
} | ||
|
||
private BytesWritable evaluateInternal(BytesWritable bw, int pos) { | ||
byte[] b = Arrays.copyOf(bw.getBytes(), bw.getLength()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, why do we need copy?
} | ||
|
||
private final IntWritable maxValue = new IntWritable(Integer.MAX_VALUE); | ||
|
||
// Even though we are using longs, substr can only deal with ints, so we use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep this comment where you check the range
What changes were proposed in this pull request?
If a
SUBSTR
UDF has a 4-byte characters in its parameter, the behavior is different between vectorized and non-vectorized. The vectorized version handles 4-byte characters properly, but the non-vectorized version does not, so similar logic is needed.And these fixes use vectorized logic:
https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java#L89-L130
https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java#L78-L109
Why are the changes needed?
Vectorized and non-vectorized have different results.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added pattern tests to itest for these to work correctly.