You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2018/07/26 18:30:31 UTC

[GitHub] bitblender commented on a change in pull request #1395: DRILL-6629 BitVector split and transfer does not work correctly for transfer length < 8

bitblender commented on a change in pull request #1395: DRILL-6629 BitVector split and transfer does not work correctly for transfer length < 8
URL: https://github.com/apache/drill/pull/1395#discussion_r205559272
 
 

 ##########
 File path: exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java
 ##########
 @@ -323,7 +323,8 @@ public void splitAndTransferTo(int startIndex, int length, BitVector target) {
       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;
 
 Review comment:
   Yes. This can happen. Good observation!
   
   I did not handle it in the initial PR because this can happen only in the single-byte (length < 8) case, so there is always allocated memory available(at least 1 byte is alloced in the target vector) to write the extra bits and since valueCount of the target was being set correctly, this was not a concern. Writing the extra bits would have no observable impact if the buffer was not zero-initialized. 
   
   But since we are zero-initializing buffers, it makes sense to be precise and leave bits beyond valueCount as 0. I have made changes to mask off the extra bits.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services