Package org.apache.tajo.storage

Examples of org.apache.tajo.storage.VTuple


          endInPopulationStage = false;

          boolean endLeft = false;
          boolean endRight = false;

          previous = new VTuple(leftTuple);
          do {
            leftTupleSlots.add(new VTuple(leftTuple));
            leftTuple = leftChild.next();
            if(leftTuple == null) {
              endLeft = true;
            }


          } while ((endLeft != true) && (tupleComparator[0].compare(previous, leftTuple) == 0));
          posLeftTupleSlots = 0;


          previous = new VTuple(rightTuple);
          do {
            rightTupleSlots.add(new VTuple(rightTuple));
            rightTuple = rightChild.next();
            if(rightTuple == null) {
              endRight = true;
            }

          } while ((endRight != true) && (tupleComparator[1].compare(previous, rightTuple) == 0) );
          posRightTupleSlots = 0;

          if ((endLeft == true) || (endRight == true)) {
            end = true;
            endInPopulationStage = true;
          }

        } // if end false
      } // if newRound


      ////////////////////////////////////////////////////////////////////////
      // RESULTS STAGE
      ////////////////////////////////////////////////////////////////////////
      // now output result matching tuples from the slots
      // if either we haven't reached end on neither side, or we did reach end
      // on one(or both) sides but that happened in the slots population step
      // (i.e. refers to next round)
      if(!end || (end && endInPopulationStage)){
        if(posLeftTupleSlots == 0){
          leftNext = new VTuple (leftTupleSlots.get(posLeftTupleSlots));
          posLeftTupleSlots = posLeftTupleSlots + 1;
        }

        if(posRightTupleSlots <= (rightTupleSlots.size() -1)) {
          Tuple aTuple = new VTuple(rightTupleSlots.get(posRightTupleSlots));
          posRightTupleSlots = posRightTupleSlots + 1;
          frameTuple.set(leftNext, aTuple);
          joinQual.eval(qualCtx, inSchema, frameTuple);
          projector.eval(evalContexts, frameTuple);
          projector.terminate(evalContexts, outTuple);
          return outTuple;
        } else {
          // right (inner) slots reached end and should be rewind if there are still tuples in the outer slots
          if(posLeftTupleSlots <= (leftTupleSlots.size()-1)) {
            //rewind the right slots position
            posRightTupleSlots = 0;
            Tuple aTuple = new VTuple(rightTupleSlots.get(posRightTupleSlots));
            posRightTupleSlots = posRightTupleSlots + 1;
            leftNext = new VTuple (leftTupleSlots.get(posLeftTupleSlots));
            posLeftTupleSlots = posLeftTupleSlots + 1;

            frameTuple.set(leftNext, aTuple);
            joinQual.eval(qualCtx, inSchema, frameTuple);
            projector.eval(evalContexts, frameTuple);
View Full Code Here


   */
  public HashAggregateExec(TaskAttemptContext ctx, GroupbyNode annotation,
                           PhysicalExec subOp) throws IOException {
    super(ctx, annotation, subOp);
    tupleSlots = new HashMap<Tuple, EvalContext[]>(10000);
    this.tuple = new VTuple(evalSchema.getColumnNum());
  }
View Full Code Here

  private void compute() throws IOException {
    Tuple tuple;
    Tuple keyTuple;
    int targetLength = plan.getTargets().length;
    while((tuple = child.next()) != null && !context.isStopped()) {
      keyTuple = new VTuple(keylist.length);
      // build one key tuple
      for(int i = 0; i < keylist.length; i++) {
        keyTuple.put(i, tuple.get(keylist[i]));
      }
     
View Full Code Here

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

    // for join
    frameTuple = new FrameTuple();
    outTuple = new VTuple(outSchema.getColumnNum());

    leftNumCols = outer.getSchema().getColumnNum();
  }
View Full Code Here

  /**
   * creates a tuple of a given size filled with NULL values in all fields
   */
  private Tuple createNullPaddedTuple(int columnNum){
    VTuple tuple = new VTuple(columnNum);
    for (int i = 0; i < columnNum; i++) {
      tuple.put(i, DatumFactory.createNullDatum());
    }
    return tuple;
  }
View Full Code Here

          endInPopulationStage = false;

          boolean endOuter = false;
          boolean endInner = false;

          previous = new VTuple(leftTuple);
          do {
            leftTupleSlots.add(new VTuple(leftTuple));
            leftTuple = leftChild.next();
            if( leftTuple == null) {
              endOuter = true;
            }
          } while ((endOuter != true) && (tupleComparator[0].compare(previous, leftTuple) == 0));
          posLeftTupleSlots = 0;

          previous = new VTuple(rightTuple);

          do {
            innerTupleSlots.add(new VTuple(rightTuple));
            rightTuple = rightChild.next();
            if(rightTuple == null) {
              endInner = true;
            }

          } while ((endInner != true) && (tupleComparator[1].compare(previous, rightTuple) == 0) );
          posRightTupleSlots = 0;

          if ((endOuter == true) || (endInner == true)) {
            end = true;
            endInPopulationStage = true;
          }
        } // if end false
      } // if newRound


      // Now output result matching tuples from the slots
      // if either we haven't reached end on neither side, or we did reach end on one(or both) sides
      // but that happened in the slots population step (i.e. refers to next round)

      if ((end == false) || ((end == true) && (endInPopulationStage == true))){

        if(posLeftTupleSlots == 0){
          nextLeft = new VTuple (leftTupleSlots.get(posLeftTupleSlots));
          posLeftTupleSlots = posLeftTupleSlots + 1;
        }


        if(posRightTupleSlots <= (innerTupleSlots.size() -1)) {

          Tuple aTuple = new VTuple(innerTupleSlots.get(posRightTupleSlots));
          posRightTupleSlots = posRightTupleSlots + 1;

          frameTuple.set(nextLeft, aTuple);
          joinQual.eval(qualCtx, inSchema, frameTuple);
          projector.eval(evalContexts, frameTuple);
          projector.terminate(evalContexts, outTuple);
          return outTuple;

        } else {
          // right (inner) slots reached end and should be rewind if there are still tuples in the outer slots
          if(posLeftTupleSlots <= (leftTupleSlots.size() - 1)) {
            //rewind the right slots position
            posRightTupleSlots = 0;
            Tuple aTuple = new VTuple(innerTupleSlots.get(posRightTupleSlots));
            posRightTupleSlots = posRightTupleSlots + 1;
            nextLeft = new VTuple (leftTupleSlots.get(posLeftTupleSlots));
            posLeftTupleSlots = posLeftTupleSlots + 1;

            frameTuple.set(nextLeft, aTuple);
            joinQual.eval(qualCtx, inSchema, frameTuple);
            projector.eval(evalContexts, frameTuple);
View Full Code Here

    }
  }

  private Tuple makeTuple() throws IOException {
    column.resetValid(schema.getColumnNum());
    Tuple tuple = new VTuple(schema.getColumnNum());
    int tid; // target column id
    for (int i = 0; i < projectionMap.length; i++) {
      tid = projectionMap[i];
      // if the column is byte[0], it presents a NULL value.
      if (column.get(tid).getLength() == 0) {
        tuple.put(tid, DatumFactory.createNullDatum());
      } else {
        switch (targets[i].getDataType().getType()) {
          case BOOLEAN:
            tuple.put(tid,
                DatumFactory.createBool(column.get(tid).getBytesCopy()[0]));
            break;
          case BIT:
            tuple.put(tid,
                DatumFactory.createBit(column.get(tid).getBytesCopy()[0]));
            break;
          case CHAR:
            byte[] buf = column.get(tid).getBytesCopy();
            tuple.put(tid,
                DatumFactory.createChar(buf));
            break;

          case INT2:
            tuple.put(tid,
                DatumFactory.createInt2(Bytes.toShort(
                    column.get(tid).getBytesCopy())));
            break;
          case INT4:
            tuple.put(tid,
                DatumFactory.createInt4(Bytes.toInt(
                    column.get(tid).getBytesCopy())));
            break;

          case INT8:
            tuple.put(tid,
                DatumFactory.createInt8(Bytes.toLong(
                    column.get(tid).getBytesCopy())));
            break;

          case FLOAT4:
            tuple.put(tid,
                DatumFactory.createFloat4(Bytes.toFloat(
                    column.get(tid).getBytesCopy())));
            break;

          case FLOAT8:
            tuple.put(tid,
                DatumFactory.createFloat8(Bytes.toDouble(
                    column.get(tid).getBytesCopy())));
            break;

          case INET4:
            tuple.put(tid,
                DatumFactory.createInet4(column.get(tid).getBytesCopy()));
            break;

          case TEXT:
            tuple.put(tid,
                DatumFactory.createText(
                    column.get(tid).getBytesCopy()));
            break;

          case BLOB:
            tuple.put(tid,
                DatumFactory.createBlob(column.get(tid).getBytesCopy()));
            break;

          default:
            throw new IOException("Unsupport data type");
View Full Code Here

  public HashLeftAntiJoinExec(TaskAttemptContext context, JoinNode plan, PhysicalExec fromSideChild,
                              PhysicalExec notInSideChild) {
    super(context, plan, fromSideChild, notInSideChild);
    // NUll Tuple
    rightNullTuple = new VTuple(leftChild.outColumnNum);
    for (int i = 0; i < leftChild.outColumnNum; i++) {
      rightNullTuple.put(i, NullDatum.get());
    }
  }
View Full Code Here

  public HashLeftSemiJoinExec(TaskAttemptContext context, JoinNode plan, PhysicalExec fromSideChild,
                              PhysicalExec inSideChild) {
    super(context, plan, fromSideChild, inSideChild);
    // NUll Tuple
    rightNullTuple = new VTuple(leftChild.outColumnNum);
    for (int i = 0; i < leftChild.outColumnNum; i++) {
      rightNullTuple.put(i, NullDatum.get());
    }
  }
View Full Code Here

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

    // for join
    frameTuple = new FrameTuple();
    outTuple = new VTuple(outSchema.getColumnNum());
    leftKeyTuple = new VTuple(leftKeyList.length);

    leftNumCols = leftChild.getSchema().getColumnNum();
    rightNumCols = rightChild.getSchema().getColumnNum();
  }
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.