You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Parth Chandra (JIRA)" <ji...@apache.org> on 2014/07/23 22:40:38 UTC

[jira] [Created] (DRILL-1178) Double copy in setSafe for VariableLengthVectors

Parth Chandra created DRILL-1178:
------------------------------------

             Summary: Double copy in setSafe for VariableLengthVectors
                 Key: DRILL-1178
                 URL: https://issues.apache.org/jira/browse/DRILL-1178
             Project: Apache Drill
          Issue Type: Bug
          Components: Execution - Codegen
    Affects Versions: 1.0.0-milestone-1
            Reporter: Parth Chandra
             Fix For: 1.0.0-BETA1


In the code generated for the VariableLengthVectors there appears to be a double copy in the setSafe function that takes a Holder as a parameter. Snippet below is for the VarBinaryVector class.

public boolean setSafe(int index, VarBinaryHolder holder){
      int start = holder.start;
      int end =   holder.end;
      int len = end - start;
      
      int outputStart = offsetVector.data.getInt(index * 4);
      
      if(data.capacity() < outputStart + len) {
        decrementAllocationMonitor();
        return false;
      }
      
      holder.buffer.getBytes(start, data, outputStart, len);   // COPY 1
      if (!offsetVector.getMutator().setSafe( index+1,  outputStart + len)) {
        return false;
      }

      set(index, holder); // COPY 2 

      return true;
    }
      if (!offsetVector.getMutator().setSafe( index+1,  outputStart + len)) {
        return false;
      }

      set(index, holder);

      return true;
    }
    protected void set(int index, VarBinaryHolder holder){
      int length = holder.end - holder.start;
      int currentOffset = offsetVector.getAccessor().get(index);
      offsetVector.getMutator().set(index + 1, currentOffset + length);
      data.setBytes(currentOffset, holder.buffer, holder.start, length); // COPY 2
    }

The line holder.buffer.getBytes copies from the holder into 'data'. 
Then in the set function, the data.setBytes call  copies again. 




--
This message was sent by Atlassian JIRA
(v6.2#6252)