diff options
author | karthik <kmanivannan@maprtech.com> | 2018-07-23 16:28:49 -0700 |
---|---|---|
committer | Timothy Farkas <timothyfarkas@apache.org> | 2018-08-03 23:42:16 -0700 |
commit | a5440331bcd87b6f6fc27e3202f95d8fdf0da5e1 (patch) | |
tree | 43528fc6da89a0e122944df5a72728bbf44d0fc0 /exec/vector | |
parent | d780820d9cf954f08992a2ec07ffdb8f09f482d1 (diff) |
DRILL-6629 BitVector split and transfer does not work correctly for transfer length < 8
closes #1395
Diffstat (limited to 'exec/vector')
-rw-r--r-- | exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java b/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java index 0dd34f51e..a6b87378d 100644 --- a/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java +++ b/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java @@ -323,8 +323,14 @@ public final class BitVector extends BaseDataValueVector implements FixedWidthVe if (length % 8 != 0) { // start is not byte aligned so we have to copy some bits from the last full byte read in the // previous loop - byte lastButOneByte = byteIPlus1; + // if numBytesHoldingSourceBits == 1, lastButOneByte is the first byte, but we have not read it yet, so read it + byte lastButOneByte = (numBytesHoldingSourceBits == 1) ? this.data.getByte(firstByteIndex) : byteIPlus1; byte bitsFromLastButOneByte = (byte)((lastButOneByte & 0xFF) >>> firstBitOffset); + // if last bit to be copied is before the end of the first byte, then mask of the trailing extra bits + if (8 > (length + firstBitOffset)) { + byte mask = (byte)((0x1 << length) - 1); + bitsFromLastButOneByte = (byte)((bitsFromLastButOneByte & mask)); + } // If we have to read more bits than what we have already read, read it into lastByte otherwise set lastByte to 0. // (length % 8) is num of remaining bits to be read. |