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

Paul Rogers updated DRILL-5597:
-------------------------------
    Description: 
Consider the following code in a generated nullable vector, such as 
{{NullableBigIntVector}}:

{code}
  public void allocateNew(int valueCount) {
    try {
      values.allocateNew(valueCount);
      bits.allocateNew(valueCount+1);
{code}

There are as may "bits" entries as data entries, no need to allocate an extra 
1. When the {{valueCount}} is a power of two, the error will cause the 
allocation of twice as large a vector as necessary. (128K, say, instead of 64K, 
since 64K+1 power-of-two rounds to 128K.)

By contrast the +1 correction is needed for offset vectors, but the "bits" 
vector is not an offset vector.

By contrast, another variation of the same method is correct:

{code}
  public void allocateNew(int totalBytes, int valueCount) {
    try {
      values.allocateNew(totalBytes, valueCount);
      bits.allocateNew(valueCount);
{code}

  was:
Consider the following code in a generated nullable vector, such as 
{{NullableBigIntVector}}:

{code}
  public void allocateNew(int valueCount) {
    try {
      values.allocateNew(valueCount);
      bits.allocateNew(valueCount+1);
{code}

There are as may "bits" entries as data entries, no need to allocate an extra 
1. When the {{valueCount}} is a power of two, the error will cause the 
allocation of twice as large a vector as necessary. (128K, say, instead of 64K, 
since 64K+1 power-of-two rounds to 128K.)

By contrast the +1 correction is needed for offset vectors, but the "bits" 
vector is not an offset vector.


> Incorrect "bits" vector allocation in nullable vectors allocateNew()
> --------------------------------------------------------------------
>
>                 Key: DRILL-5597
>                 URL: https://issues.apache.org/jira/browse/DRILL-5597
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 1.10.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Minor
>             Fix For: 1.11.0
>
>
> Consider the following code in a generated nullable vector, such as 
> {{NullableBigIntVector}}:
> {code}
>   public void allocateNew(int valueCount) {
>     try {
>       values.allocateNew(valueCount);
>       bits.allocateNew(valueCount+1);
> {code}
> There are as may "bits" entries as data entries, no need to allocate an extra 
> 1. When the {{valueCount}} is a power of two, the error will cause the 
> allocation of twice as large a vector as necessary. (128K, say, instead of 
> 64K, since 64K+1 power-of-two rounds to 128K.)
> By contrast the +1 correction is needed for offset vectors, but the "bits" 
> vector is not an offset vector.
> By contrast, another variation of the same method is correct:
> {code}
>   public void allocateNew(int totalBytes, int valueCount) {
>     try {
>       values.allocateNew(totalBytes, valueCount);
>       bits.allocateNew(valueCount);
> {code}



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

Reply via email to