Package org.apache.tajo.storage

Examples of org.apache.tajo.storage.Tuple


    return outTuple;
  }

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

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

      if (tupleSlots.containsKey(keyTuple)) {
        newValue = tupleSlots.get(keyTuple);
        newValue.add(tuple);
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(evalContexts, frameTuple);
          projector.terminate(evalContexts, outTuple);
          // we simulate we found a match, which is exactly the null padded one
          foundAtLeastOneMatch = true;
View Full Code Here

    this.evalContexts = projector.renew();
  }

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

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

   * @param schema
   * @param range
   * @return
   */
  public static long computeCardinality(Schema schema, TupleRange range) {
    Tuple start = range.getStart();
    Tuple end = range.getEnd();
    Column col;

    long cardinality = 1;
    long columnCard;
    for (int i = 0; i < schema.getColumnNum(); i++) {
      col = schema.getColumn(i);
      switch (col.getDataType().getType()) {
        case CHAR:
          columnCard = end.get(i).asChar() - start.get(i).asChar();
          break;
        case BIT:
          columnCard = end.get(i).asByte() - start.get(i).asByte();
          break;
        case INT2:
          columnCard = end.get(i).asInt2() - start.get(i).asInt2();
          break;
        case INT4:
          columnCard = end.get(i).asInt4() - start.get(i).asInt4();
          break;
        case INT8:
          columnCard = end.get(i).asInt8() - start.get(i).asInt8();
          break;
        case FLOAT4:
          columnCard = end.get(i).asInt4() - start.get(i).asInt4();
          break;
        case FLOAT8:
          columnCard = end.get(i).asInt8() - start.get(i).asInt8();
          break;
        case TEXT:
          columnCard = end.get(i).asChars().charAt(0) - start.get(i).asChars().charAt(0);
          break;
        default:
          throw new UnsupportedOperationException(col.getDataType() + " is not supported yet");
      }

View Full Code Here

    private void fillRootIndex(int entryNum, FSDataInputStream in)
        throws IOException {
      this.dataIndex = new Tuple[entryNum];
      this.offsetIndex = new long[entryNum];
      Tuple keyTuple;
      byte[] buf;
      for (int i = 0; i < entryNum; i++) {
        buf = new byte[in.readInt()];
        in.read(buf);
        keyTuple = RowStoreUtil.RowStoreDecoder.toTuple(keySchema, buf);
View Full Code Here

  }

  public Tuple getNextUnmatchedRight() {

    List<Tuple> newValue;
    Tuple returnedTuple;
    // get a keyTUple from the matched hashmap with a boolean false value
    for(Tuple aKeyTuple : matched.keySet()) {
      if(matched.get(aKeyTuple) == false) {
        newValue = tupleSlots.get(aKeyTuple);
        returnedTuple = newValue.remove(0);
View Full Code Here

  public Tuple next() throws IOException {
    if (first) {
      loadRightToHashTable();
    }

    Tuple rightTuple;
    boolean found = false;

    while(!finished) {
      if (shouldGetLeftTuple) { // initially, it is true.
        // getting new outer
        leftTuple = leftChild.next(); // it comes from a disk
        if (leftTuple == null) { // if no more tuples in left tuples on disk, a join is completed.
          // in this stage we can begin outputing tuples from the right operand (which were before in tupleSlots) null padded on the left side
          Tuple unmatchedRightTuple = getNextUnmatchedRight();
          if( unmatchedRightTuple == null) {
            finished = true;
            outTuple = null;
            return null;
          } else {
            Tuple nullPaddedTuple = TupleUtil.createNullPaddedTuple(leftNumCols);
            frameTuple.set(nullPaddedTuple, unmatchedRightTuple);
            projector.eval(evalContexts, frameTuple);
            projector.terminate(evalContexts, outTuple);

            return outTuple;
          }
        }

        // getting corresponding right
        getKeyLeftTuple(leftTuple, leftKeyTuple); // get a left key tuple
        if (tupleSlots.containsKey(leftKeyTuple)) { // finds right tuples on in-memory hash table.
          iterator = tupleSlots.get(leftKeyTuple).iterator();
          shouldGetLeftTuple = false;
        } else {
          //this left tuple doesn't have a match on the right.But full outer join => we should keep it anyway
          //output a tuple with the nulls padded rightTuple
          Tuple nullPaddedTuple = TupleUtil.createNullPaddedTuple(rightNumCols);
          frameTuple.set(leftTuple, nullPaddedTuple);
          projector.eval(evalContexts, frameTuple);
          projector.terminate(evalContexts, outTuple);
          // we simulate we found a match, which is exactly the null padded one
          shouldGetLeftTuple = true;
View Full Code Here

    }
    return outTuple;
  }

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

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

      if (tupleSlots.containsKey(keyTuple)) {
        newValue = tupleSlots.get(keyTuple);
        newValue.add(tuple);
View Full Code Here

  @Override
  public Tuple next() throws IOException {

    if (!sorted) {
      Tuple tuple;
      while ((tuple = child.next()) != null) {
        tupleSlots.add(new VTuple(tuple));
      }
     
      Collections.sort(tupleSlots, getComparator());
View Full Code Here

  public Tuple next() throws IOException {

    if (outerTupleSlots.isEmpty()) {
      for (int k = 0; k < TUPLE_SLOT_SIZE; k++) {
        Tuple t = leftChild.next();
        if (t == null) {
          outerEnd = true;
          break;
        }
        outerTupleSlots.add(t);
      }
      outerIterator = outerTupleSlots.iterator();
      outerTuple = outerIterator.next();
    }

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

    if((innext = rightChild.next()) == null){
      innerEnd = true;
    }

    while (true) {
      if (!innerIterator.hasNext()) { // if inneriterator ended
        if (outerIterator.hasNext()) { // if outertupleslot remains
          outerTuple = outerIterator.next();
          innerIterator = innerTupleSlots.iterator();
        } else {
          if (innerEnd) {
            rightChild.rescan();
            innerEnd = false;
           
            if (outerEnd) {
              return null;
            }
            outerTupleSlots.clear();
            for (int k = 0; k < TUPLE_SLOT_SIZE; k++) {
              Tuple t = leftChild.next();
              if (t == null) {
                outerEnd = true;
                break;
              }
              outerTupleSlots.add(t);
            }
            if (outerTupleSlots.isEmpty()) {
              return null;
            }
            outerIterator = outerTupleSlots.iterator();
            outerTuple = outerIterator.next();
           
          } else {
            outerIterator = outerTupleSlots.iterator();
            outerTuple = outerIterator.next();
          }
         
          innerTupleSlots.clear();
          if (innext != null) {
            innerTupleSlots.add(innext);
            for (int k = 1; k < TUPLE_SLOT_SIZE; k++) { // fill inner
              Tuple t = rightChild.next();
              if (t == null) {
                innerEnd = true;
                break;
              }
              innerTupleSlots.add(t);
            }
          } else {
            for (int k = 0; k < TUPLE_SLOT_SIZE; k++) { // fill inner
              Tuple t = rightChild.next();
              if (t == null) {
                innerEnd = true;
                break;
              }
              innerTupleSlots.add(t);
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.