Paul Rogers created DRILL-5308:
----------------------------------

             Summary: Asking an sv2 for its buffer clears the sv2
                 Key: DRILL-5308
                 URL: https://issues.apache.org/jira/browse/DRILL-5308
             Project: Apache Drill
          Issue Type: Bug
    Affects Versions: 1.9.0
            Reporter: Paul Rogers


Consider the following code:

{code}
      SelectionVector2 sv2 = va.getSelectionVector2();
      sv2Size = sv2.getBuffer().capacity();
{code}

When similar code is called for a value vector, we simply get the buffer 
capacity. When called for an sv2, we get the capacity *after* clearing the sv2! 
The code in question:

{code}
  public DrillBuf getBuffer() {
    return getBuffer(true);
  }

  public DrillBuf getBuffer(boolean clear) {
    DrillBuf bufferHandle = this.buffer;

    if (clear) {
      /* Increment the ref count for this buffer */
      bufferHandle.retain(1);

      /* We are passing ownership of the buffer to the
       * caller. clear the buffer from within our selection vector
       */
      clear();
    }

    return bufferHandle;
  }
{code}

That is, for a value vector, {{getBuffer()}} simply gets the buffer. For an 
sv2, {{getBuffer()}} clears the buffer, then returns it.




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to