You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2017/06/18 05:59:00 UTC

[jira] [Updated] (DRILL-5592) BitVector has out-of-date methods from when it was a bit vector

     [ https://issues.apache.org/jira/browse/DRILL-5592?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Rogers updated DRILL-5592:
-------------------------------
    Description: 
Drill contains a vector class called {{BitVector}} that, apparently, at one time used bits to indicate the set (i.e. not null) state of a nullable vector. At some point in time, the vector because a byte vector (though it retained the original name.)

It seems some methods were never updated and continue to assume 8 values per byte:

{code}
  private int getSizeFromCount(int valueCount) {
    return (int) Math.ceil(valueCount / 8.0);
  }

  @Override
  public int getValueCapacity() {
    return (int) Math.min((long)Integer.MAX_VALUE, data.capacity() * 8L);
  }

  private int getByteIndex(int index) {
    return (int) Math.floor(index / 8.0);
  }
{code}

As a result of this old code, certain other methods don't work as expected:

{code}
  @Override
  public void allocateNew(int valueCount) {
    final int size = getSizeFromCount(valueCount);
    allocateBytes(size);
  }
{code}

The bug causes the above to allocate room for only 1/8 the values expected. While the mistake is benign, {setSafe}} will have to do three unnecessary doublings to compensate for the error.

  was:
Drill contains a vector class called {{BitVector}} that, apparently, at one time used bits to indicate the set (i.e. not null) state of a nullable vector. At some point in time, the vector because a byte vector (though it retained the original name.)

It seems some methods were never updated and continue to assume 8 values per byte:

{code}
  private int getSizeFromCount(int valueCount) {
    return (int) Math.ceil(valueCount / 8.0);
  }

  @Override
  public int getValueCapacity() {
    return (int) Math.min((long)Integer.MAX_VALUE, data.capacity() * 8L);
  }

  private int getByteIndex(int index) {
    return (int) Math.floor(index / 8.0);
  }
{code}

As a result of this old code, certain other methods don't work as expected:

{code}
  @Override
  public void allocateNew(int valueCount) {
    final int size = getSizeFromCount(valueCount);
    allocateBytes(size);
  }
{code}

The bug causes the above to allocate room for only 1/8 the values expected.


> BitVector has out-of-date methods from when it was a bit vector
> ---------------------------------------------------------------
>
>                 Key: DRILL-5592
>                 URL: https://issues.apache.org/jira/browse/DRILL-5592
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 1.8.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>             Fix For: 1.11.0
>
>
> Drill contains a vector class called {{BitVector}} that, apparently, at one time used bits to indicate the set (i.e. not null) state of a nullable vector. At some point in time, the vector because a byte vector (though it retained the original name.)
> It seems some methods were never updated and continue to assume 8 values per byte:
> {code}
>   private int getSizeFromCount(int valueCount) {
>     return (int) Math.ceil(valueCount / 8.0);
>   }
>   @Override
>   public int getValueCapacity() {
>     return (int) Math.min((long)Integer.MAX_VALUE, data.capacity() * 8L);
>   }
>   private int getByteIndex(int index) {
>     return (int) Math.floor(index / 8.0);
>   }
> {code}
> As a result of this old code, certain other methods don't work as expected:
> {code}
>   @Override
>   public void allocateNew(int valueCount) {
>     final int size = getSizeFromCount(valueCount);
>     allocateBytes(size);
>   }
> {code}
> The bug causes the above to allocate room for only 1/8 the values expected. While the mistake is benign, {setSafe}} will have to do three unnecessary doublings to compensate for the error.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)