Package org.apache.tajo.storage

Examples of org.apache.tajo.storage.VTuple


    schema1.addColumn("table1.score", INT4);
   
    BinaryEval expr = new BinaryEval(EvalType.PLUS, e1, e2);
    EvalContext evalCtx = expr.newContext();
    assertCloneEqual(expr);
    VTuple tuple = new VTuple(2);
    tuple.put(0, DatumFactory.createInt4(1)); // put 0th field
    tuple.put(1, DatumFactory.createInt4(99)); // put 0th field

    // the result of evaluation must be 100.
    expr.eval(evalCtx, schema1, tuple);
    assertEquals(expr.terminate(evalCtx).asInt4(), 100);
  }
View Full Code Here


  @Test
  public void testAvgInt() {
    Tuple [] tuples = new Tuple[5];

    for (int i = 1; i <= 5; i++) {
      tuples[i-1] = new VTuple(1);
      tuples[i-1].put(0, DatumFactory.createInt4(i));
    }

    AvgLong avg = new AvgLong();
    FunctionContext ctx = avg.newContext();
    for (int i = 1; i <= 5; i++) {
      avg.eval(ctx, tuples[i-1]);
    }

    assertTrue(15 / 5 == avg.terminate(ctx).asFloat8());


    Tuple [] tuples2 = new Tuple[10];

    FunctionContext ctx2 = avg.newContext();
    for (int i = 1; i <= 10; i++) {
      tuples2[i-1] = new VTuple(1);
      tuples2[i-1].put(0, DatumFactory.createInt4(i));
      avg.eval(ctx2, tuples2[i-1]);
    }
    assertTrue((double)55 / 10 == avg.terminate(ctx2).asFloat8());


    avg.merge(ctx, new VTuple(new Datum[] {avg.getPartialResult(ctx2)}));
    assertTrue((double)(15 + 55) / (5 + 10) == avg.terminate(ctx).asFloat8());
  }
View Full Code Here

  @Test
  public void testIncrement1() {
    Schema schema = new Schema()
    .addColumn("l_returnflag", Type.TEXT)
    .addColumn("l_linestatus", Type.TEXT);
    Tuple s = new VTuple(2);
    s.put(0, DatumFactory.createText("A"));
    s.put(1, DatumFactory.createText("A"));
    Tuple e = new VTuple(2);
    e.put(0, DatumFactory.createText("D"));
    e.put(1, DatumFactory.createText("C"));

    TupleRange expected = new TupleRange(schema, s, e);

    UniformRangePartition partitioner =
        new UniformRangePartition(schema, expected);
View Full Code Here

  @Test
  public void testIncrement2() {
    Schema schema = new Schema()
    .addColumn("l_returnflag", Type.TEXT)
    .addColumn("l_linestatus", Type.TEXT);
    Tuple s = new VTuple(2);
    s.put(0, DatumFactory.createText("A"));
    s.put(1, DatumFactory.createText("A"));
    Tuple e = new VTuple(2);
    e.put(0, DatumFactory.createText("D"));
    e.put(1, DatumFactory.createText("C"));

    TupleRange expected = new TupleRange(schema, s, e);

    UniformRangePartition partitioner =
        new UniformRangePartition(schema, expected);
View Full Code Here

    Schema schema = new Schema()
    .addColumn("l_returnflag", Type.TEXT)
    .addColumn("l_linestatus", Type.TEXT)
    .addColumn("final", Type.TEXT);

    Tuple s = new VTuple(3);
    s.put(0, DatumFactory.createText("A"));
    s.put(1, DatumFactory.createText("A"));
    s.put(2, DatumFactory.createText("A"));
    Tuple e = new VTuple(3);
    e.put(0, DatumFactory.createText("D")); //  4
    e.put(1, DatumFactory.createText("B")); //  2
    e.put(2, DatumFactory.createText("C")); // x3 = 24

    TupleRange expected = new TupleRange(schema, s, e);

    UniformRangePartition partitioner =
        new UniformRangePartition(schema, expected);
View Full Code Here

  @Test
  public void testIncrement4() {
    Schema schema = new Schema()
    .addColumn("l_orderkey", Type.INT8)
    .addColumn("l_linenumber", Type.INT8);
    Tuple s = new VTuple(2);
    s.put(0, DatumFactory.createInt8(10));
    s.put(1, DatumFactory.createInt8(20));
    Tuple e = new VTuple(2);
    e.put(0, DatumFactory.createInt8(19));
    e.put(1, DatumFactory.createInt8(39));

    TupleRange expected = new TupleRange(schema, s, e);

    UniformRangePartition partitioner =
        new UniformRangePartition(schema, expected);
View Full Code Here

  @Test public void testIncrement5() {
    Schema schema = new Schema()
    .addColumn("l_orderkey", Type.INT8)
    .addColumn("l_linenumber", Type.INT8)
    .addColumn("final", Type.INT8);
    Tuple s = new VTuple(3);
    s.put(0, DatumFactory.createInt8(1));
    s.put(1, DatumFactory.createInt8(1));
    s.put(2, DatumFactory.createInt8(1));
    Tuple e = new VTuple(3);
    e.put(0, DatumFactory.createInt8(4)); // 4
    e.put(1, DatumFactory.createInt8(2)); // 2
    e.put(2, DatumFactory.createInt8(3)); //x3 = 24

    TupleRange expected = new TupleRange(schema, s, e);

    UniformRangePartition partitioner
        = new UniformRangePartition(schema, expected);
View Full Code Here

  public void testIncrement6() {
    Schema schema = new Schema()
      .addColumn("l_orderkey", Type.FLOAT8)
      .addColumn("l_linenumber", Type.FLOAT8)
      .addColumn("final", Type.FLOAT8);
    Tuple s = new VTuple(3);
    s.put(0, DatumFactory.createFloat8(1.1d));
    s.put(1, DatumFactory.createFloat8(1.1d));
    s.put(2, DatumFactory.createFloat8(1.1d));
    Tuple e = new VTuple(3);
    e.put(0, DatumFactory.createFloat8(4.1d)); // 4
    e.put(1, DatumFactory.createFloat8(2.1d)); // 2
    e.put(2, DatumFactory.createFloat8(3.1d)); //x3 = 24

    TupleRange expected = new TupleRange(schema, s, e);

    UniformRangePartition partitioner =
        new UniformRangePartition(schema, expected);
View Full Code Here

  @Test
  public void testPartition() {
    Schema schema = new Schema();
    schema.addColumn("l_returnflag", Type.TEXT);
    schema.addColumn("l_linestatus", Type.TEXT);
    Tuple s = new VTuple(2);
    s.put(0, DatumFactory.createText("A"));
    s.put(1, DatumFactory.createText("F"));
    Tuple e = new VTuple(2);
    e.put(0, DatumFactory.createText("R"));
    e.put(1, DatumFactory.createText("O"));
    TupleRange expected = new TupleRange(schema, s, e);
    RangePartitionAlgorithm partitioner
        = new UniformRangePartition(schema, expected, true);
    TupleRange [] ranges = partitioner.partition(31);
View Full Code Here

  @Test
  public void testPartitionForOnePartNum() {
    Schema schema = new Schema()
      .addColumn("l_returnflag", Type.TEXT)
      .addColumn("l_linestatus", Type.TEXT);
    Tuple s = new VTuple(2);
    s.put(0, DatumFactory.createText("A"));
    s.put(1, DatumFactory.createText("F"));
    Tuple e = new VTuple(2);
    e.put(0, DatumFactory.createText("R"));
    e.put(1, DatumFactory.createText("O"));
    TupleRange expected = new TupleRange(schema, s, e);
    RangePartitionAlgorithm partitioner =
        new UniformRangePartition(schema, expected, true);
    TupleRange [] ranges = partitioner.partition(1);
View Full Code Here

TOP

Related Classes of org.apache.tajo.storage.VTuple

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.