[ 
https://issues.apache.org/jira/browse/DRILL-6629?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16558725#comment-16558725
 ] 

ASF GitHub Bot commented on DRILL-6629:
---------------------------------------

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:
us...@infra.apache.org


> BitVector split and transfer does not work correctly for transfer length < 8
> ----------------------------------------------------------------------------
>
>                 Key: DRILL-6629
>                 URL: https://issues.apache.org/jira/browse/DRILL-6629
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Execution - Data Types
>         Environment: BitVector split and transfer does not work correctly for 
> transfer length < 8.
>            Reporter: Karthikeyan Manivannan
>            Assignee: Karthikeyan Manivannan
>            Priority: Major
>             Fix For: 1.15.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to