Gopal V created HIVE-12827:
------------------------------

             Summary: Vectorization: 
VectorCopyRow/VectorAssignRow/VectorDeserializeRow assign needs explicit 
isNull[offset] modification
                 Key: HIVE-12827
                 URL: https://issues.apache.org/jira/browse/HIVE-12827
             Project: Hive
          Issue Type: Bug
            Reporter: Gopal V


Some scenarios do set Double.NaN instead of isNull=true, but all types aren't 
consistent.

Examples of un-set isNull for the valid values are 

{code}
  private class FloatReader extends AbstractDoubleReader {

    FloatReader(int columnIndex) {
      super(columnIndex);
    }

    @Override
    void apply(VectorizedRowBatch batch, int batchIndex) throws IOException {
      DoubleColumnVector colVector = (DoubleColumnVector) 
batch.cols[columnIndex];

      if (deserializeRead.readCheckNull()) {
        VectorizedBatchUtil.setNullColIsNullValue(colVector, batchIndex);
      } else {
        float value = deserializeRead.readFloat();
        colVector.vector[batchIndex] = (double) value;
      }
    }
  }
{code}

{code}
  private class DoubleCopyRow extends CopyRow {

    DoubleCopyRow(int inColumnIndex, int outColumnIndex) {
      super(inColumnIndex, outColumnIndex);
    }

    @Override
    void copy(VectorizedRowBatch inBatch, int inBatchIndex, VectorizedRowBatch 
outBatch, int outBatchIndex) {
      DoubleColumnVector inColVector = (DoubleColumnVector) 
inBatch.cols[inColumnIndex];
      DoubleColumnVector outColVector = (DoubleColumnVector) 
outBatch.cols[outColumnIndex];

      if (inColVector.isRepeating) {
        if (inColVector.noNulls || !inColVector.isNull[0]) {
          outColVector.vector[outBatchIndex] = inColVector.vector[0];
        } else {
          VectorizedBatchUtil.setNullColIsNullValue(outColVector, 
outBatchIndex);
        }
      } else {
        if (inColVector.noNulls || !inColVector.isNull[inBatchIndex]) {
          outColVector.vector[outBatchIndex] = inColVector.vector[inBatchIndex];
        } else {
          VectorizedBatchUtil.setNullColIsNullValue(outColVector, 
outBatchIndex);
        }
      }
    }
  }
{code}

{code}
 private static abstract class VectorDoubleColumnAssign
    extends VectorColumnAssignVectorBase<DoubleColumnVector> {

    protected void assignDouble(double value, int destIndex) {
      outCol.vector[destIndex] = value;
    }
  }
{code}

The pattern to imitate would be the earlier code from VectorBatchUtil

{code}
    case DOUBLE: {
      DoubleColumnVector dcv = (DoubleColumnVector) batch.cols[offset + 
colIndex];
      if (writableCol != null) {
        dcv.vector[rowIndex] = ((DoubleWritable) writableCol).get();
        dcv.isNull[rowIndex] = false;
      } else {
        dcv.vector[rowIndex] = Double.NaN;
        setNullColIsNullValue(dcv, rowIndex);
      }
    }
      break;
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to