Examples of DecimalColumnVector


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

    assertEquals(31536000999999999L, r.vector[2]);
  }

  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);
View Full Code Here

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

  @Test
  public void testCastLongToDecimal() {
    VectorizedRowBatch b = getBatchLongDecimal();
    VectorExpression expr = new CastLongToDecimal(0, 1);
    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, (short) 2)));
    assertTrue(r.vector[2].equals(new Decimal128(99999999999999L, (short) 2)));
  }
View Full Code Here

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

  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

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

  @Test
  public void testCastDoubleToDecimal() {
    VectorizedRowBatch b = getBatchDoubleDecimal();
    VectorExpression expr = new CastDoubleToDecimal(0, 1);
    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[1];

    assertTrue(r.vector[0].equals(new Decimal128(0, r.scale)));
    assertTrue(r.vector[1].equals(new Decimal128(-1, r.scale)));
    assertTrue(r.vector[2].equals(new Decimal128("99999999999999.0", r.scale)));
  }
View Full Code Here

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

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

    b.size = 3;

    dv.vector[0] = 0d;
    dv.vector[1] = -1d;
View Full Code Here

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

  @Test
  public void testCastStringToDecimal() {
    VectorizedRowBatch b = getBatchStringDecimal();
    VectorExpression expr = new CastStringToDecimal(0, 1);
    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
    assertTrue(r.vector[0].equals(new Decimal128("1.10", r.scale)));
    assertTrue(r.vector[1].equals(new Decimal128("-2.20", r.scale)));
    assertTrue(r.vector[2].equals(new Decimal128("99999999999999.0", r.scale)));
  }
View Full Code Here

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

  private VectorizedRowBatch getBatchStringDecimal() {
    VectorizedRowBatch b = new VectorizedRowBatch(2);
    BytesColumnVector bv;
    b.cols[0] = bv = new BytesColumnVector();
    b.cols[1] = new DecimalColumnVector(18, 2);

    bv.initBuffer();

    byte[] x0 = toBytes("1.10");
    byte[] x1 = toBytes("-2.20");
View Full Code Here

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

    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)));
    assertTrue(r.vector[2].equals(new Decimal128("100000.00", (short) 2)));

    // Try again with a value that won't fit in 5 digits, to make
View Full Code Here

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

   */
  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

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

    // test casting from one precision and scale to another.
    VectorizedRowBatch b = getBatchDecimalDecimal();
    VectorExpression expr = new CastDecimalToDecimal(0, 1);
    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
    assertTrue(r.vector[0].equals(new Decimal128("10.00", (short) 2)));
    assertFalse(r.noNulls);
    assertTrue(r.isNull[1]);

    // test an increase in precision/scale
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.