[CALCITE-3779] Implement bitand scalar function#1795
[CALCITE-3779] Implement bitand scalar function#1795wangxlong wants to merge 5 commits intoapache:mainfrom
Conversation
|
looks good to me |
hsyuan
left a comment
There was a problem hiding this comment.
@wangxlong Can you rebase on latest master?
| byte[] bytes1 = b1.getBytes(); | ||
| byte[] result = new byte[b0.length()]; | ||
|
|
||
| IntStream.range(0, bytes0.length).forEach(i -> { |
There was a problem hiding this comment.
Frankly speaking, a good old for loop would look better here, and it looks like streams add complexity without much benefits.
| IntStream.range(0, bytes0.length).forEach(i -> { | |
| for (int i = 0; i < bytes0.length; i++) { |
| public static final SqlReturnTypeInference INTEGER_QUOTIENT_NULLABLE = | ||
| chain(ARG0_INTERVAL_NULLABLE, LEAST_RESTRICTIVE); | ||
|
|
||
|
|
There was a problem hiding this comment.
Please refrain from altering non-related lines
| } | ||
| byte[] bytes0 = b0.getBytes(); | ||
| byte[] bytes1 = b1.getBytes(); | ||
| byte[] result = new byte[b0.length()]; |
There was a problem hiding this comment.
Technically speaking, b0.getBytes() clones the byte array, so there's no need to allocate new byte[...] for the result. I believe bytes0 would work just fine for the resulting array.
8764c72 to
2a70ad1
Compare
| } | ||
|
|
||
| /** Bitwise function <code>BIT_AND</code> applied to binary and long values. */ | ||
| public static ByteString bitAnd(ByteString b0, long b1) { |
| } | ||
| } | ||
|
|
||
| /** Implementor for bitwise scalar function. */ |
| */ | ||
| private static ByteString binaryOperator( | ||
| ByteString b0, long b1, BinaryOperator<Byte> bitOp) { | ||
| byte[] bytes0 = b0.getBytes(); |
|
@hsyuan Updated. |
| ByteString b0, long b1, BinaryOperator<Byte> bitOp) { | ||
| final byte[] bytes0 = b0.getBytes(); | ||
|
|
||
| final byte[] result = new byte[bytes0.length]; |
There was a problem hiding this comment.
Could you please remove result allocation and replace it with bytes0?
An alternative could be to use b0.byteAt(...)
8a5cf83 to
cf7f71b
Compare
|
What's the status of this PR? It looks like it's close to being ready for merging. |
|
Superseded by #3942 |
Implement bitand scalar function which support tinyint, smallint, int, bigint, binary and varbinary type.
Related issue: CALCITE-3779
Parent issue: CALCITE-3732