Package org.apache.tajo.storage

Examples of org.apache.tajo.storage.Tuple


  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);
    assertEquals(24, partitioner.getTotalCardinality().longValue());

    Tuple beforeOverflow = partitioner.increment(s, 5, 2);
    assertTrue(1.1d == beforeOverflow.get(0).asFloat8());
    assertTrue(2.1d == beforeOverflow.get(1).asFloat8());
    assertTrue(3.1d == beforeOverflow.get(2).asFloat8());
    Tuple overflow = partitioner.increment(beforeOverflow, 1, 2);
    assertTrue(2.1d == overflow.get(0).asFloat8());
    assertTrue(1.1d == overflow.get(1).asFloat8());
    assertTrue(1.1d == overflow.get(2).asFloat8());
  }
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

      this.partitionFilter = partitionFilter;
    }

    @Override
    public boolean accept(Path path) {
      Tuple tuple = TupleUtil.buildTupleFromPartitionPath(schema, path, true);
      if (tuple == null) { // if it is a file or not acceptable file
        return false;
      }

      return partitionFilter.eval(schema, tuple).asBool();
View Full Code Here

  public Tuple next() throws IOException {

    if (leftTupleSlots.isEmpty()) {
      for (int k = 0; k < TUPLE_SLOT_SIZE; k++) {
        Tuple t = leftChild.next();
        if (t == null) {
          leftEnd = true;
          break;
        }
        leftTupleSlots.add(t);
      }
      leftIterator = leftTupleSlots.iterator();
      leftTuple = leftIterator.next();
    }

    if (rightTupleSlots.isEmpty()) {
      for (int k = 0; k < TUPLE_SLOT_SIZE; k++) {
        Tuple t = rightChild.next();
        if (t == null) {
          rightEnd = true;
          break;
        }
        rightTupleSlots.add(t);
      }
      rightIterator = rightTupleSlots.iterator();
    }

    if((rightNext = rightChild.next()) == null){
      rightEnd = true;
    }

    while (true) {
      if (!rightIterator.hasNext()) { // if leftIterator ended
        if (leftIterator.hasNext()) { // if rightTupleslot remains
          leftTuple = leftIterator.next();
          rightIterator = rightTupleSlots.iterator();
        } else {
          if (rightEnd) {
            rightChild.rescan();
            rightEnd = false;
           
            if (leftEnd) {
              return null;
            }
            leftTupleSlots.clear();
            for (int k = 0; k < TUPLE_SLOT_SIZE; k++) {
              Tuple t = leftChild.next();
              if (t == null) {
                leftEnd = true;
                break;
              }
              leftTupleSlots.add(t);
            }
            if (leftTupleSlots.isEmpty()) {
              return null;
            }
            leftIterator = leftTupleSlots.iterator();
            leftTuple = leftIterator.next();
           
          } else {
            leftIterator = leftTupleSlots.iterator();
            leftTuple = leftIterator.next();
          }
         
          rightTupleSlots.clear();
          if (rightNext != null) {
            rightTupleSlots.add(rightNext);
            for (int k = 1; k < TUPLE_SLOT_SIZE; k++) { // fill right
              Tuple t = rightChild.next();
              if (t == null) {
                rightEnd = true;
                break;
              }
              rightTupleSlots.add(t);
            }
          } else {
            for (int k = 0; k < TUPLE_SLOT_SIZE; k++) { // fill right
              Tuple t = rightChild.next();
              if (t == null) {
                rightEnd = true;
                break;
              }
              rightTupleSlots.add(t);
View Full Code Here

    if (first) {
      loadRightToHashTable();
      scanStartTime = System.currentTimeMillis();
    }

    Tuple rightTuple;
    boolean found = false;

    while(!finished) {
      if (shouldGetLeftTuple) { // initially, it is true.
        // getting new outer
View Full Code Here

    return new VTuple(outTuple);
  }

  protected void loadRightToHashTable() throws IOException {
    Tuple tuple;
    Tuple keyTuple;

    while ((tuple = rightChild.next()) != null) {
      keyTuple = new VTuple(joinKeyPairs.size());
      for (int i = 0; i < rightKeyList.length; i++) {
        keyTuple.put(i, tuple.get(rightKeyList[i]));
      }

      List<Tuple> newValue = tupleSlots.get(keyTuple);

      if (newValue != null) {
View Full Code Here

      if (rightTuple == null) {
        // the scan of the right operand is finished with no matches found
        if(foundAtLeastOneMatch == false){
          //output a tuple with the nulls padded rightTuple
          Tuple nullPaddedTuple = TupleUtil.createNullPaddedTuple(rightNumCols);
          frameTuple.set(leftTuple, nullPaddedTuple);
          projector.eval(frameTuple, outTuple);
          // we simulate we found a match, which is exactly the null padded one
          foundAtLeastOneMatch = true;
          needNextRightTuple = true;
View Full Code Here

    this.projector = new Projector(inSchema, outSchema, this.plan.getTargets());
  }

  @Override
  public Tuple next() throws IOException {
    Tuple tuple = child.next();

    if (tuple ==  null) {
      return null;
    }
View Full Code Here

  /* (non-Javadoc)
   * @see PhysicalExec#next()
   */
  @Override
  public Tuple next() throws IOException {
    Tuple tuple;
    StringBuilder sb = new StringBuilder();
    while((tuple = child.next()) != null) {
      // set subpartition directory name
      sb.delete(0, sb.length());
      if (keyIds != null) {
        for(int i = 0; i < keyIds.length; i++) {
          Datum datum = tuple.get(keyIds[i]);
          if(i > 0)
            sb.append("/");
          sb.append(keyNames[i]).append("=");
          sb.append(datum.asChars());
        }
View Full Code Here

TOP

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

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.