示例#1
0
  @Override
  public Object clone() throws CloneNotSupportedException {
    EvalNode node = (EvalNode) super.clone();
    node.type = type;
    node.leftExpr = leftExpr != null ? (EvalNode) leftExpr.clone() : null;
    node.rightExpr = rightExpr != null ? (EvalNode) rightExpr.clone() : null;

    return node;
  }
示例#2
0
 public void postOrder(EvalNodeVisitor visitor) {
   leftExpr.postOrder(visitor);
   rightExpr.postOrder(visitor);
   visitor.visit(this);
 }
示例#3
0
 public void preOrder(EvalNodeVisitor visitor) {
   visitor.visit(this);
   leftExpr.preOrder(visitor);
   rightExpr.preOrder(visitor);
 }
示例#4
0
 public String toString() {
   return "(" + this.type + "(" + leftExpr.toString() + " " + rightExpr.toString() + "))";
 }
示例#5
0
  public Tuple next() throws IOException {

    if (outerTupleSlots.isEmpty()) {
      for (int k = 0; k < TUPLE_SLOT_SIZE; k++) {
        Tuple t = outerChild.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 = innerChild.next();
        if (t == null) {
          innerEnd = true;
          break;
        }
        innerTupleSlots.add(t);
      }
      innerIterator = innerTupleSlots.iterator();
    }

    if ((innext = innerChild.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) {
            innerChild.rescan();
            innerEnd = false;

            if (outerEnd) {
              return null;
            }
            outerTupleSlots.clear();
            for (int k = 0; k < TUPLE_SLOT_SIZE; k++) {
              Tuple t = outerChild.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 = innerChild.next();
              if (t == null) {
                innerEnd = true;
                break;
              }
              innerTupleSlots.add(t);
            }
          } else {
            for (int k = 0; k < TUPLE_SLOT_SIZE; k++) { // fill inner
              Tuple t = innerChild.next();
              if (t == null) {
                innerEnd = true;
                break;
              }
              innerTupleSlots.add(t);
            }
          }

          if ((innext = innerChild.next()) == null) {
            innerEnd = true;
          }
          innerIterator = innerTupleSlots.iterator();
        }
      }

      frameTuple.set(outerTuple, innerIterator.next());
      if (joinQual != null) {
        joinQual.eval(qualCtx, inSchema, frameTuple);
        if (joinQual.terminate(qualCtx).asBool()) {
          RowStoreUtil.project(frameTuple, outputTuple, targetIds);
          return outputTuple;
        }
      } else {
        RowStoreUtil.project(frameTuple, outputTuple, targetIds);
        return outputTuple;
      }
    }
  }
示例#6
0
 @Test
 public final void testOnlyExpr() {
   QueryBlock block = (QueryBlock) analyzer.parse(QUERIES[6]).getParseTree();
   EvalNode node = block.getTargetList()[0].getEvalTree();
   assertEquals(Type.PLUS, node.getType());
 }