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

Examples of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector


    // test basic case
    VectorizedRowBatch b = getBatchDecimalLong();
    VectorExpression expr = new CastDecimalToLong(0, 1);
    expr.evaluate(b);
    LongColumnVector r = (LongColumnVector) b.cols[1];
    assertEquals(1, r.vector[0]);
    assertEquals(-2, r.vector[1]);
    assertEquals(9999999999999999L, r.vector[2]);

    // test with nulls in input
View Full Code Here


    VectorizedRowBatch b = getBatchDecimalLong();
    VectorExpression expr = new CastDecimalToBoolean(0, 1);
    DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
    in.vector[1].update(0);
    expr.evaluate(b);
    LongColumnVector r = (LongColumnVector) b.cols[1];
    assertEquals(1, r.vector[0]);
    assertEquals(0, r.vector[1]);
    assertEquals(1, r.vector[2]);
  }
View Full Code Here

  private VectorizedRowBatch getBatchDecimalLong() {
    VectorizedRowBatch b = new VectorizedRowBatch(2);
    DecimalColumnVector dv;
    short scale = 2;
    b.cols[0] = dv = new DecimalColumnVector(18, scale);
    b.cols[1] = new LongColumnVector();

    b.size = 3;

    dv.vector[0].update("1.1", scale);
    dv.vector[1].update("-2.2", scale);
View Full Code Here

  @Test
  public void testCastDecimalToTimestamp() {
    VectorizedRowBatch b = getBatchDecimalLong2();
    VectorExpression expr = new CastDecimalToTimestamp(0, 1);
    expr.evaluate(b);
    LongColumnVector r = (LongColumnVector) b.cols[1];
    assertEquals(1111111111L, r.vector[0]);
    assertEquals(-2222222222L, r.vector[1]);
    assertEquals(31536000999999999L, r.vector[2]);
  }
View Full Code Here

  private VectorizedRowBatch getBatchDecimalLong2() {
    VectorizedRowBatch b = new VectorizedRowBatch(2);
    DecimalColumnVector dv;
    short scale = 9;
    b.cols[0] = dv = new DecimalColumnVector(18, scale);
    b.cols[1] = new LongColumnVector();

    b.size = 3;

    dv.vector[0].update("1.111111111", scale);
    dv.vector[1].update("-2.222222222", scale);
View Full Code Here

    assertTrue(r.vector[2].equals(new Decimal128(99999999999999L, (short) 2)));
  }

  private VectorizedRowBatch getBatchLongDecimal() {
    VectorizedRowBatch b = new VectorizedRowBatch(2);
    LongColumnVector lv;
    b.cols[0] = lv = new LongColumnVector();
    b.cols[1] = new DecimalColumnVector(18, 2);
    lv.vector[0] = 0;
    lv.vector[1] = -1;
    lv.vector[2] = 99999999999999L;
    return b;
View Full Code Here

    // The input timestamps are stored as long values
    // measured in nanoseconds from the epoch.
    VectorizedRowBatch b = getBatchLongDecimal();
    VectorExpression expr = new CastTimestampToDecimal(0, 1);
    LongColumnVector inL = (LongColumnVector) b.cols[0];
    inL.vector[1] = -1990000000L;
    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
    assertTrue(r.vector[0].equals(new Decimal128(0, (short) 2)));
    assertTrue(r.vector[1].equals(new Decimal128("-1.99", (short) 2)));
View Full Code Here

   * converted to decimal, will not fit in the given precision.
   * Then it will be possible to check that the results are NULL.
   */
  private VectorizedRowBatch getBatchLongDecimalPrec5Scale2() {
    VectorizedRowBatch b = new VectorizedRowBatch(2);
    LongColumnVector lv;
    b.cols[0] = lv = new LongColumnVector();
    b.cols[1] = new DecimalColumnVector(5, 2);
    lv.vector[0] = 0;
    lv.vector[1] = -1;
    lv.vector[2] = 99999999999999L;
    return b;
View Full Code Here

  private long newRandom(int i) {
    return random.nextInt(i);
  }

  private LongColumnVector newRandomLongColumnVector(int range, int size) {
    LongColumnVector vector = new LongColumnVector(size);
    for (int i = 0; i < size; i++) {
      vector.vector[i] = random.nextInt(range);
    }
    return vector;
  }
View Full Code Here

    }
    return vector;
  }

  private LongColumnVector toTimestamp(LongColumnVector date) {
    LongColumnVector vector = new LongColumnVector(size);
    for (int i = 0; i < size; i++) {
      if (date.isNull[i]) {
        vector.isNull[i] = true;
        vector.noNulls = false;
      } else {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector

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.