Package org.apache.hadoop.hive.ql.exec.vector.expressions.gen

Examples of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.IfExprLongColumnLongColumn


  }

  @Test
  public void testLongColumnColumnIfExpr()  {
    VectorizedRowBatch batch = getBatch4LongVectors();
    VectorExpression expr = new IfExprLongColumnLongColumn(0, 1, 2, 3);
    expr.evaluate(batch);

    // get result vector
    LongColumnVector r = (LongColumnVector) batch.cols[3];

    // verify standard case
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(-3, r.vector[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(true, r.noNulls);
    assertEquals(false, r.isRepeating);

    // verify when first argument (boolean flags) is repeating
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[0].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(4, r.vector[3]);

    // verify when second argument is repeating
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[1].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(-1, r.vector[2]);
    assertEquals(-1, r.vector[3]);

    // verify when third argument is repeating
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[2].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(1, r.vector[1]);
    assertEquals(-3, r.vector[2]);
    assertEquals(-4, r.vector[3]);

    // test when first argument has nulls
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[0].noNulls = false;
    batch.cols[0].isNull[1] = true;
    batch.cols[0].isNull[2] = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(3, r.vector[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(true, r.noNulls);
    assertEquals(false, r.isRepeating);

    // test when second argument has nulls
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[1].noNulls = false;
    batch.cols[1].isNull[1] = true;
    batch.cols[1].isNull[2] = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(true, r.isNull[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(false, r.noNulls);
    assertEquals(false, r.isRepeating);

    // test when third argument has nulls
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[2].noNulls = false;
    batch.cols[2].isNull[1] = true;
    batch.cols[2].isNull[2] = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(true, r.isNull[1]);
    assertEquals(-3, r.vector[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(false, r.noNulls);
    assertEquals(false, r.isRepeating);


    // test when second argument has nulls and repeats
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[1].noNulls = false;
    batch.cols[1].isNull[0] = true;
    batch.cols[1].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(true, r.isNull[2]);
    assertEquals(true, r.isNull[3]);
    assertEquals(false, r.noNulls);
    assertEquals(false, r.isRepeating);

    // test when third argument has nulls and repeats
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[2].noNulls = false;
    batch.cols[2].isNull[0] = true;
    batch.cols[2].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(true, r.isNull[0]);
    assertEquals(true, r.isNull[1]);
    assertEquals(-3, r.vector[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(false, r.noNulls);
View Full Code Here


  }

  @Test
  public void testLongColumnColumnIfExpr()  {
    VectorizedRowBatch batch = getBatch4LongVectors();
    VectorExpression expr = new IfExprLongColumnLongColumn(0, 1, 2, 3);
    expr.evaluate(batch);

    // get result vector
    LongColumnVector r = (LongColumnVector) batch.cols[3];

    // verify standard case
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(-3, r.vector[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(true, r.noNulls);
    assertEquals(false, r.isRepeating);

    // verify when first argument (boolean flags) is repeating
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[0].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(4, r.vector[3]);

    // verify when second argument is repeating
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[1].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(-1, r.vector[2]);
    assertEquals(-1, r.vector[3]);

    // verify when third argument is repeating
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[2].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(1, r.vector[1]);
    assertEquals(-3, r.vector[2]);
    assertEquals(-4, r.vector[3]);

    // test when first argument has nulls
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[0].noNulls = false;
    batch.cols[0].isNull[1] = true;
    batch.cols[0].isNull[2] = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(3, r.vector[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(true, r.noNulls);
    assertEquals(false, r.isRepeating);

    // test when second argument has nulls
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[1].noNulls = false;
    batch.cols[1].isNull[1] = true;
    batch.cols[1].isNull[2] = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(true, r.isNull[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(false, r.noNulls);
    assertEquals(false, r.isRepeating);

    // test when third argument has nulls
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[2].noNulls = false;
    batch.cols[2].isNull[1] = true;
    batch.cols[2].isNull[2] = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(true, r.isNull[1]);
    assertEquals(-3, r.vector[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(false, r.noNulls);
    assertEquals(false, r.isRepeating);


    // test when second argument has nulls and repeats
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[1].noNulls = false;
    batch.cols[1].isNull[0] = true;
    batch.cols[1].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(1, r.vector[0]);
    assertEquals(2, r.vector[1]);
    assertEquals(true, r.isNull[2]);
    assertEquals(true, r.isNull[3]);
    assertEquals(false, r.noNulls);
    assertEquals(false, r.isRepeating);

    // test when third argument has nulls and repeats
    batch = getBatch4LongVectors();
    r = (LongColumnVector) batch.cols[3];
    batch.cols[2].noNulls = false;
    batch.cols[2].isNull[0] = true;
    batch.cols[2].isRepeating = true;
    expr.evaluate(batch);
    assertEquals(true, r.isNull[0]);
    assertEquals(true, r.isNull[1]);
    assertEquals(-3, r.vector[2]);
    assertEquals(-4, r.vector[3]);
    assertEquals(false, r.noNulls);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.IfExprLongColumnLongColumn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.