tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hj...@apache.org
Subject [28/35] TAJO-1125: Separate logical plan and optimizer into a maven module.
Date Sun, 26 Oct 2014 19:27:34 GMT
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/AlterTablespaceNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/AlterTablespaceNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/AlterTablespaceNode.java
deleted file mode 100644
index d64a89d..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/AlterTablespaceNode.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tajo.engine.planner;
-
-
-import com.google.common.base.Objects;
-import com.google.gson.annotations.Expose;
-import org.apache.tajo.algebra.AlterTablespaceSetType;
-import org.apache.tajo.engine.planner.logical.LogicalNode;
-import org.apache.tajo.engine.planner.logical.LogicalNodeVisitor;
-import org.apache.tajo.engine.planner.logical.NodeType;
-
-public class AlterTablespaceNode extends LogicalNode implements Cloneable {
-
-  @Expose private String tablespaceName;
-  @Expose private AlterTablespaceSetType setType;
-  @Expose private String uri;
-
-
-  public AlterTablespaceNode(int pid) {
-    super(pid, NodeType.ALTER_TABLESPACE);
-  }
-
-  public String getTablespaceName() {
-    return tablespaceName;
-  }
-
-  public void setTablespaceName(String tablespaceName) {
-    this.tablespaceName = tablespaceName;
-  }
-
-  public AlterTablespaceSetType getSetType() {
-    return setType;
-  }
-
-  public String getLocation() {
-    return uri;
-  }
-
-  public void setLocation(String uri) {
-    this.setType = AlterTablespaceSetType.LOCATION;
-    this.uri = uri;
-  }
-
-  @Override
-  public PlanString getPlanString() {
-    return new PlanString(this);
-  }
-
-  @Override
-  public boolean equals(Object obj) {
-    if (obj instanceof AlterTablespaceNode) {
-      AlterTablespaceNode other = (AlterTablespaceNode) obj;
-      return super.equals(other);
-    } else {
-      return false;
-    }
-  }
-
-  public int hashCode() {
-    return Objects.hashCode(tablespaceName, setType, uri);
-  }
-
-  @Override
-  public Object clone() throws CloneNotSupportedException {
-    AlterTablespaceNode alter = (AlterTablespaceNode) super.clone();
-    alter.tablespaceName = tablespaceName;
-    alter.setType = setType;
-    alter.uri = uri;
-    return alter;
-  }
-
-  @Override
-  public String toString() {
-    return "AlterTablespace (space=" + tablespaceName + ")";
-  }
-
-  @Override
-  public void preOrder(LogicalNodeVisitor visitor) {
-    visitor.visit(this);
-  }
-
-  @Override
-  public void postOrder(LogicalNodeVisitor visitor) {
-    visitor.visit(this);
-  }
-}

http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/BaseAlgebraVisitor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/BaseAlgebraVisitor.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/BaseAlgebraVisitor.java
deleted file mode 100644
index 24ff2e4..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/BaseAlgebraVisitor.java
+++ /dev/null
@@ -1,789 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tajo.engine.planner;
-
-import org.apache.tajo.algebra.*;
-
-import java.util.Stack;
-
-public class BaseAlgebraVisitor<CONTEXT, RESULT> implements AlgebraVisitor<CONTEXT, RESULT> {
-
-  /**
-   * The prehook is called before each expression is visited.
-   */
-  public void preHook(CONTEXT ctx, Stack<Expr> stack, Expr expr) throws PlanningException {
-  }
-
-
-  /**
-   * The posthook is called before each expression is visited.
-   */
-  public RESULT postHook(CONTEXT ctx, Stack<Expr> stack, Expr expr, RESULT current) throws PlanningException {
-    return current;
-  }
-
-  /**
-   * visit visits each relational operator expression recursively.
-   *
-   * @param stack The stack contains the upper operators' type.
-   * @param expr The visiting relational operator
-   */
-  public RESULT visit(CONTEXT ctx, Stack<Expr> stack, Expr expr) throws PlanningException {
-    preHook(ctx, stack, expr);
-
-    RESULT current;
-
-    switch (expr.getType()) {
-
-    case Projection:
-      current = visitProjection(ctx, stack, (Projection) expr);
-      break;
-    case Limit:
-      current = visitLimit(ctx, stack, (Limit) expr);
-      break;
-    case Sort:
-      current = visitSort(ctx, stack, (Sort) expr);
-      break;
-    case Having:
-      current = visitHaving(ctx, stack, (Having) expr);
-      break;
-    case Aggregation:
-      current = visitGroupBy(ctx, stack, (Aggregation) expr);
-      break;
-    case Join:
-      current = visitJoin(ctx, stack, (Join) expr);
-      break;
-    case Filter:
-      current = visitFilter(ctx, stack, (Selection) expr);
-      break;
-    case Union:
-      current = visitUnion(ctx, stack, (SetOperation) expr);
-      break;
-    case Except:
-      current = visitExcept(ctx, stack, (SetOperation) expr);
-      break;
-    case Intersect:
-      current = visitIntersect(ctx, stack, (SetOperation) expr);
-      break;
-    case SimpleTableSubQuery:
-      current = visitSimpleTableSubQuery(ctx, stack, (SimpleTableSubQuery) expr);
-      break;
-    case TablePrimaryTableSubQuery:
-      current = visitTableSubQuery(ctx, stack, (TablePrimarySubQuery) expr);
-      break;
-    case RelationList:
-      current = visitRelationList(ctx, stack, (RelationList) expr);
-      break;
-    case Relation:
-      current = visitRelation(ctx, stack, (Relation) expr);
-      break;
-    case ScalarSubQuery:
-      current = visitScalarSubQuery(ctx, stack, (ScalarSubQuery) expr);
-      break;
-    case Explain:
-      current = visitExplain(ctx, stack, (Explain) expr);
-      break;
-
-    case CreateDatabase:
-      current = visitCreateDatabase(ctx, stack, (CreateDatabase) expr);
-      break;
-    case DropDatabase:
-      current = visitDropDatabase(ctx, stack, (DropDatabase) expr);
-      break;
-    case CreateTable:
-      current = visitCreateTable(ctx, stack, (CreateTable) expr);
-      break;
-    case DropTable:
-      current = visitDropTable(ctx, stack, (DropTable) expr);
-      break;
-    case AlterTablespace:
-      current = visitAlterTablespace(ctx, stack, (AlterTablespace) expr);
-      break;
-    case AlterTable:
-      current = visitAlterTable(ctx, stack, (AlterTable) expr);
-      break;
-    case TruncateTable:
-      current = visitTruncateTable(ctx, stack, (TruncateTable)expr);
-      break;
-
-    case Insert:
-      current = visitInsert(ctx, stack, (Insert) expr);
-      break;
-
-    case And:
-      current = visitAnd(ctx, stack, (BinaryOperator) expr);
-      break;
-    case Or:
-      current = visitOr(ctx, stack, (BinaryOperator) expr);
-      break;
-    case Not:
-      current = visitNot(ctx, stack, (NotExpr) expr);
-      break;
-
-    case Equals:
-      current = visitEquals(ctx, stack, (BinaryOperator) expr);
-      break;
-    case NotEquals:
-      current = visitNotEquals(ctx, stack, (BinaryOperator) expr);
-      break;
-    case LessThan:
-      current = visitLessThan(ctx, stack, (BinaryOperator) expr);
-      break;
-    case LessThanOrEquals:
-      current = visitLessThanOrEquals(ctx, stack, (BinaryOperator) expr);
-      break;
-    case GreaterThan:
-      current = visitGreaterThan(ctx, stack, (BinaryOperator) expr);
-      break;
-    case GreaterThanOrEquals:
-      current = visitGreaterThanOrEquals(ctx, stack, (BinaryOperator) expr);
-      break;
-
-    // Other Predicates
-    case Between:
-      current = visitBetween(ctx, stack, (BetweenPredicate) expr);
-      break;
-    case CaseWhen:
-      current = visitCaseWhen(ctx, stack, (CaseWhenPredicate) expr);
-      break;
-    case IsNullPredicate:
-      current = visitIsNullPredicate(ctx, stack, (IsNullPredicate) expr);
-      break;
-    case InPredicate:
-      current = visitInPredicate(ctx, stack, (InPredicate) expr);
-      break;
-    case ValueList:
-      current = visitValueListExpr(ctx, stack, (ValueListExpr) expr);
-      break;
-    case ExistsPredicate:
-      current = visitExistsPredicate(ctx, stack, (ExistsPredicate) expr);
-      break;
-
-    // String Operator or Pattern Matching Predicates
-    case LikePredicate:
-      current = visitLikePredicate(ctx, stack, (PatternMatchPredicate) expr);
-      break;
-    case SimilarToPredicate:
-      current = visitSimilarToPredicate(ctx, stack, (PatternMatchPredicate) expr);
-      break;
-    case Regexp:
-      current = visitRegexpPredicate(ctx, stack, (PatternMatchPredicate) expr);
-      break;
-    case Concatenate:
-      current = visitConcatenate(ctx, stack, (BinaryOperator) expr);
-      break;
-
-    // Arithmetic Operators
-    case Plus:
-      current = visitPlus(ctx, stack, (BinaryOperator) expr);
-      break;
-    case Minus:
-      current = visitMinus(ctx, stack, (BinaryOperator) expr);
-      break;
-    case Multiply:
-      current = visitMultiply(ctx, stack, (BinaryOperator) expr);
-      break;
-    case Divide:
-      current = visitDivide(ctx, stack, (BinaryOperator) expr);
-      break;
-    case Modular:
-      current = visitModular(ctx, stack, (BinaryOperator) expr);
-      break;
-
-    // Other Expressions
-    case Sign:
-      current = visitSign(ctx, stack, (SignedExpr) expr);
-      break;
-    case Column:
-      current = visitColumnReference(ctx, stack, (ColumnReferenceExpr) expr);
-      break;
-    case Target:
-      current = visitTargetExpr(ctx, stack, (NamedExpr) expr);
-      break;
-    case Function:
-      current = visitFunction(ctx, stack, (FunctionExpr) expr);
-      break;
-    case Asterisk:
-      current = visitQualifiedAsterisk(ctx, stack, (QualifiedAsteriskExpr) expr);
-      break;
-
-
-    case CountRowsFunction:
-      current = visitCountRowsFunction(ctx, stack, (CountRowsFunctionExpr) expr);
-      break;
-    case GeneralSetFunction:
-      current = visitGeneralSetFunction(ctx, stack, (GeneralSetFunctionExpr) expr);
-      break;
-    case WindowFunction:
-      current = visitWindowFunction(ctx, stack, (WindowFunctionExpr) expr);
-      break;
-
-
-    case DataType:
-      current = visitDataType(ctx, stack, (DataTypeExpr) expr);
-      break;
-    case Cast:
-      current = visitCastExpr(ctx, stack, (CastExpr) expr);
-      break;
-    case Literal:
-      current = visitLiteral(ctx, stack, (LiteralValue) expr);
-      break;
-    case NullLiteral:
-      current = visitNullLiteral(ctx, stack, (NullLiteral) expr);
-      break;
-    case DateLiteral:
-      current = visitDateLiteral(ctx, stack, (DateLiteral) expr);
-      break;
-    case TimeLiteral:
-      current = visitTimeLiteral(ctx, stack, (TimeLiteral) expr);
-      break;
-    case TimestampLiteral:
-      current = visitTimestampLiteral(ctx, stack, (TimestampLiteral) expr);
-      break;
-    case IntervalLiteral:
-      current = visitIntervalLiteral(ctx, stack, (IntervalLiteral) expr);
-      break;
-
-
-    default:
-      throw new PlanningException("Cannot support this type algebra \"" + expr.getType() + "\"");
-    }
-
-    // skip postHook against only one relation
-    if (expr.getType() == OpType.RelationList) {
-      RelationList relationList = (RelationList)expr;
-      if (relationList.size() == 1 && relationList.getRelations()[0].getType() == OpType.Relation) {
-        return current;
-      }
-    }
-
-    postHook(ctx, stack, expr, current);
-    return current;
-  }
-
-  private RESULT visitDefaultUnaryExpr(CONTEXT ctx, Stack<Expr> stack, UnaryOperator expr) throws PlanningException {
-    stack.push(expr);
-    RESULT child = visit(ctx, stack, expr.getChild());
-    stack.pop();
-    return child;
-  }
-
-  private RESULT visitDefaultBinaryExpr(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr)
-      throws PlanningException {
-    stack.push(expr);
-    RESULT child = visit(ctx, stack, expr.getLeft());
-    visit(ctx, stack, expr.getRight());
-    stack.pop();
-    return child;
-  }
-
-  @Override
-  public RESULT visitProjection(CONTEXT ctx, Stack<Expr> stack, Projection expr) throws PlanningException {
-    stack.push(expr);
-    try {
-      for (NamedExpr target : expr.getNamedExprs()) {
-        visit(ctx, stack, target);
-      }
-      if (expr.hasChild()) {
-        return visit(ctx, stack, expr.getChild());
-      }
-    } finally {
-      stack.pop();
-    }
-    return null;
-  }
-
-  @Override
-  public RESULT visitLimit(CONTEXT ctx, Stack<Expr> stack, Limit expr) throws PlanningException {
-    stack.push(expr);
-    visit(ctx, stack, expr.getFetchFirstNum());
-    RESULT result = visit(ctx, stack, expr.getChild());
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitSort(CONTEXT ctx, Stack<Expr> stack, Sort expr) throws PlanningException {
-    stack.push(expr);
-    for (Sort.SortSpec sortSpec : expr.getSortSpecs()) {
-      visit(ctx, stack, sortSpec.getKey());
-    }
-    RESULT result = visit(ctx, stack, expr.getChild());
-    return result;
-  }
-
-  @Override
-  public RESULT visitHaving(CONTEXT ctx, Stack<Expr> stack, Having expr) throws PlanningException {
-    stack.push(expr);
-    visit(ctx, stack, expr.getQual());
-    RESULT result = visit(ctx, stack, expr.getChild());
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitGroupBy(CONTEXT ctx, Stack<Expr> stack, Aggregation expr) throws PlanningException {
-    stack.push(expr);
-
-    for (org.apache.tajo.algebra.Aggregation.GroupElement groupElement : expr.getGroupSet()) {
-      for (Expr groupingSet : groupElement.getGroupingSets()) {
-        visit(ctx, stack, groupingSet);
-      }
-    }
-
-    RESULT result = visit(ctx, stack, expr.getChild());
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitJoin(CONTEXT ctx, Stack<Expr> stack, Join expr) throws PlanningException {
-    stack.push(expr);
-    visit(ctx, stack, expr.getQual());
-    visit(ctx, stack, expr.getLeft());
-    RESULT result = visit(ctx, stack, expr.getRight());
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitFilter(CONTEXT ctx, Stack<Expr> stack, Selection expr) throws PlanningException {
-    stack.push(expr);
-    visit(ctx, stack, expr.getQual());
-    RESULT result = visit(ctx, stack, expr.getChild());
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitUnion(CONTEXT ctx, Stack<Expr> stack, SetOperation expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitExcept(CONTEXT ctx, Stack<Expr> stack, SetOperation expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitIntersect(CONTEXT ctx, Stack<Expr> stack, SetOperation expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitSimpleTableSubQuery(CONTEXT ctx, Stack<Expr> stack, SimpleTableSubQuery expr)
-      throws PlanningException {
-    return visitDefaultUnaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitTableSubQuery(CONTEXT ctx, Stack<Expr> stack, TablePrimarySubQuery expr)
-      throws PlanningException {
-    stack.push(expr);
-    RESULT child = visit(ctx, stack, expr.getSubQuery());
-    stack.pop();
-    return child;
-  }
-
-  @Override
-  public RESULT visitRelationList(CONTEXT ctx, Stack<Expr> stack, RelationList expr) throws PlanningException {
-    stack.push(expr);
-    RESULT child = null;
-    for (Expr e : expr.getRelations()) {
-      child = visit(ctx, stack, e);
-    }
-    stack.pop();
-    return child;
-  }
-
-  @Override
-  public RESULT visitRelation(CONTEXT ctx, Stack<Expr> stack, Relation expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitScalarSubQuery(CONTEXT ctx, Stack<Expr> stack, ScalarSubQuery expr) throws PlanningException {
-    return visitDefaultUnaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitExplain(CONTEXT ctx, Stack<Expr> stack, Explain expr) throws PlanningException {
-    stack.push(expr);
-    RESULT child = visit(ctx, stack, expr.getChild());
-    stack.pop();
-    return child;
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // Data Definition Language Section
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @Override
-  public RESULT visitCreateDatabase(CONTEXT ctx, Stack<Expr> stack, CreateDatabase expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitDropDatabase(CONTEXT ctx, Stack<Expr> stack, DropDatabase expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitCreateTable(CONTEXT ctx, Stack<Expr> stack, CreateTable expr) throws PlanningException {
-    stack.push(expr);
-    RESULT child = null;
-    if (expr.hasSubQuery()) {
-      child = visit(ctx, stack, expr.getSubQuery());
-    }
-    stack.pop();
-    return child;
-  }
-
-  @Override
-  public RESULT visitDropTable(CONTEXT ctx, Stack<Expr> stack, DropTable expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitAlterTablespace(CONTEXT ctx, Stack<Expr> stack, AlterTablespace expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitAlterTable(CONTEXT ctx, Stack<Expr> stack, AlterTable expr) throws PlanningException {
-    return null;
-  }
-
-  public RESULT visitTruncateTable(CONTEXT ctx, Stack<Expr> stack, TruncateTable expr) throws PlanningException {
-    return null;
-  }
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // Insert or Update Section
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public RESULT visitInsert(CONTEXT ctx, Stack<Expr> stack, Insert expr) throws PlanningException {
-    stack.push(expr);
-    RESULT child = visit(ctx, stack, expr.getSubQuery());
-    stack.pop();
-    return child;
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // Logical Operator Section
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @Override
-  public RESULT visitAnd(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitOr(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitNot(CONTEXT ctx, Stack<Expr> stack, NotExpr expr) throws PlanningException {
-    return visitDefaultUnaryExpr(ctx, stack, expr);
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // Comparison Predicates Section
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  @Override
-  public RESULT visitEquals(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitNotEquals(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitLessThan(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitLessThanOrEquals(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitGreaterThan(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitGreaterThanOrEquals(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr)
-      throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // Other Predicates Section
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @Override
-  public RESULT visitBetween(CONTEXT ctx, Stack<Expr> stack, BetweenPredicate expr) throws PlanningException {
-    stack.push(expr);
-    RESULT result = visit(ctx, stack, expr.predicand());
-    visit(ctx, stack, expr.begin());
-    visit(ctx, stack, expr.end());
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitCaseWhen(CONTEXT ctx, Stack<Expr> stack, CaseWhenPredicate expr) throws PlanningException {
-    stack.push(expr);
-    RESULT result = null;
-    for (CaseWhenPredicate.WhenExpr when : expr.getWhens()) {
-      result = visit(ctx, stack, when.getCondition());
-      visit(ctx, stack, when.getResult());
-    }
-    if (expr.hasElseResult()) {
-      visit(ctx, stack, expr.getElseResult());
-    }
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitIsNullPredicate(CONTEXT ctx, Stack<Expr> stack, IsNullPredicate expr) throws PlanningException {
-    return visitDefaultUnaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitInPredicate(CONTEXT ctx, Stack<Expr> stack, InPredicate expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitValueListExpr(CONTEXT ctx, Stack<Expr> stack, ValueListExpr expr) throws PlanningException {
-    stack.push(expr);
-    RESULT result = null;
-    for (Expr value : expr.getValues()) {
-      result = visit(ctx, stack, value);
-    }
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitExistsPredicate(CONTEXT ctx, Stack<Expr> stack, ExistsPredicate expr) throws PlanningException {
-    return visitDefaultUnaryExpr(ctx, stack, expr);
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // String Operator or Pattern Matching Predicates Section
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  @Override
-  public RESULT visitLikePredicate(CONTEXT ctx, Stack<Expr> stack, PatternMatchPredicate expr)
-      throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitSimilarToPredicate(CONTEXT ctx, Stack<Expr> stack, PatternMatchPredicate expr)
-      throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitRegexpPredicate(CONTEXT ctx, Stack<Expr> stack, PatternMatchPredicate expr)
-      throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitConcatenate(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // Arithmetic Operators
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @Override
-  public RESULT visitPlus(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitMinus(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitMultiply(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitDivide(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitModular(CONTEXT ctx, Stack<Expr> stack, BinaryOperator expr) throws PlanningException {
-    return visitDefaultBinaryExpr(ctx, stack, expr);
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // Other Expressions
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @Override
-  public RESULT visitSign(CONTEXT ctx, Stack<Expr> stack, SignedExpr expr) throws PlanningException {
-    return visitDefaultUnaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitColumnReference(CONTEXT ctx, Stack<Expr> stack, ColumnReferenceExpr expr)
-      throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitTargetExpr(CONTEXT ctx, Stack<Expr> stack, NamedExpr expr) throws PlanningException {
-    return visitDefaultUnaryExpr(ctx, stack, expr);
-  }
-
-  @Override
-  public RESULT visitFunction(CONTEXT ctx, Stack<Expr> stack, FunctionExpr expr) throws PlanningException {
-    stack.push(expr);
-    RESULT result = null;
-    if (expr.hasParams()) {
-      for (Expr param : expr.getParams()) {
-        result = visit(ctx, stack, param);
-      }
-    }
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitQualifiedAsterisk(CONTEXT ctx, Stack<Expr> stack, QualifiedAsteriskExpr expr) throws PlanningException {
-    return null;
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // General Set Section
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @Override
-  public RESULT visitCountRowsFunction(CONTEXT ctx, Stack<Expr> stack, CountRowsFunctionExpr expr)
-      throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitGeneralSetFunction(CONTEXT ctx, Stack<Expr> stack, GeneralSetFunctionExpr expr)
-      throws PlanningException {
-    stack.push(expr);
-    RESULT result = null;
-    for (Expr param : expr.getParams()) {
-      result = visit(ctx, stack, param);
-    }
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitWindowFunction(CONTEXT ctx, Stack<Expr> stack, WindowFunctionExpr expr) throws PlanningException {
-    stack.push(expr);
-    RESULT result = null;
-    for (Expr param : expr.getParams()) {
-      result = visit(ctx, stack, param);
-    }
-
-    WindowSpec windowSpec = expr.getWindowSpec();
-
-    if (windowSpec.hasPartitionBy()) {
-      for (Expr partitionKey : windowSpec.getPartitionKeys()) {
-        visit(ctx, stack, partitionKey);
-      }
-    }
-    if (windowSpec.hasOrderBy()) {
-      for (Sort.SortSpec sortKey : windowSpec.getSortSpecs()) {
-        visit(ctx, stack, sortKey.getKey());
-      }
-    }
-    if (windowSpec.hasWindowFrame()) {
-      if (windowSpec.getWindowFrame().getStartBound().hasNumber()) {
-        visit(ctx, stack, windowSpec.getWindowFrame().getStartBound().getNumber());
-      }
-      if (windowSpec.getWindowFrame().getEndBound().hasNumber()) {
-        visit(ctx, stack, windowSpec.getWindowFrame().getEndBound().getNumber());
-      }
-    }
-
-    stack.pop();
-    return result;
-  }
-
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // Literal Section
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @Override
-  public RESULT visitDataType(CONTEXT ctx, Stack<Expr> stack, DataTypeExpr expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitCastExpr(CONTEXT ctx, Stack<Expr> stack, CastExpr expr) throws PlanningException {
-    stack.push(expr);
-    RESULT result = visit(ctx, stack, expr.getOperand());
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitLiteral(CONTEXT ctx, Stack<Expr> stack, LiteralValue expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitNullLiteral(CONTEXT ctx, Stack<Expr> stack, NullLiteral expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitTimestampLiteral(CONTEXT ctx, Stack<Expr> stack, TimestampLiteral expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitIntervalLiteral(CONTEXT ctx, Stack<Expr> stack, IntervalLiteral expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitTimeLiteral(CONTEXT ctx, Stack<Expr> stack, TimeLiteral expr) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitDateLiteral(CONTEXT ctx, Stack<Expr> stack, DateLiteral expr) throws PlanningException {
-    return null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/BasicLogicalPlanVisitor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/BasicLogicalPlanVisitor.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/BasicLogicalPlanVisitor.java
deleted file mode 100644
index a4e90b4..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/BasicLogicalPlanVisitor.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tajo.engine.planner;
-
-import org.apache.tajo.engine.planner.logical.*;
-
-import java.util.Stack;
-
-public class BasicLogicalPlanVisitor<CONTEXT, RESULT> implements LogicalPlanVisitor<CONTEXT, RESULT> {
-
-  /**
-   * The prehook is called before each node is visited.
-   */
-  @SuppressWarnings("unused")
-  public void preHook(LogicalPlan plan, LogicalNode node, Stack<LogicalNode> stack, CONTEXT data)
-      throws PlanningException {
-  }
-
-  /**
-   * The posthook is called after each node is visited.
-   */
-  @SuppressWarnings("unused")
-  public void postHook(LogicalPlan plan, LogicalNode node, Stack<LogicalNode> stack, CONTEXT data)
-      throws PlanningException {
-  }
-
-  public CONTEXT visit(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block)
-      throws PlanningException {
-    visit(context, plan, block, block.getRoot(), new Stack<LogicalNode>());
-    return context;
-  }
-
-  /**
-   * visit visits each logicalNode recursively.
-   */
-  public RESULT visit(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, LogicalNode node,
-                      Stack<LogicalNode> stack)
-      throws PlanningException {
-    RESULT current;
-    switch (node.getType()) {
-      case ROOT:
-        current = visitRoot(context, plan, block, (LogicalRootNode) node, stack);
-        break;
-      case EXPRS:
-        return null;
-      case PROJECTION:
-        current = visitProjection(context, plan, block, (ProjectionNode) node, stack);
-        break;
-      case LIMIT:
-        current = visitLimit(context, plan, block, (LimitNode) node, stack);
-        break;
-      case SORT:
-        current = visitSort(context, plan, block, (SortNode) node, stack);
-        break;
-      case HAVING:
-        current = visitHaving(context, plan, block, (HavingNode) node, stack);
-        break;
-      case GROUP_BY:
-        current = visitGroupBy(context, plan, block, (GroupbyNode) node, stack);
-        break;
-      case WINDOW_AGG:
-        current = visitWindowAgg(context, plan, block, (WindowAggNode) node, stack);
-        break;
-      case DISTINCT_GROUP_BY:
-        current = visitDistinct(context, plan, block, (DistinctGroupbyNode) node, stack);
-        break;
-      case SELECTION:
-        current = visitFilter(context, plan, block, (SelectionNode) node, stack);
-        break;
-      case JOIN:
-        current = visitJoin(context, plan, block, (JoinNode) node, stack);
-        break;
-      case UNION:
-        current = visitUnion(context, plan, block, (UnionNode) node, stack);
-        break;
-      case EXCEPT:
-        current = visitExcept(context, plan, block, (ExceptNode) node, stack);
-        break;
-      case INTERSECT:
-        current = visitIntersect(context, plan, block, (IntersectNode) node, stack);
-        break;
-      case TABLE_SUBQUERY:
-        current = visitTableSubQuery(context, plan, block, (TableSubQueryNode) node, stack);
-        break;
-      case SCAN:
-        current = visitScan(context, plan, block, (ScanNode) node, stack);
-        break;
-      case PARTITIONS_SCAN:
-        current = visitPartitionedTableScan(context, plan, block, (PartitionedTableScanNode) node, stack);
-        break;
-      case STORE:
-        current = visitStoreTable(context, plan, block, (StoreTableNode) node, stack);
-        break;
-      case INSERT:
-        current = visitInsert(context, plan, block, (InsertNode) node, stack);
-        break;
-      case CREATE_DATABASE:
-        current = visitCreateDatabase(context, plan, block, (CreateDatabaseNode) node, stack);
-        break;
-      case DROP_DATABASE:
-        current = visitDropDatabase(context, plan, block, (DropDatabaseNode) node, stack);
-        break;
-      case CREATE_TABLE:
-        current = visitCreateTable(context, plan, block, (CreateTableNode) node, stack);
-        break;
-      case DROP_TABLE:
-        current = visitDropTable(context, plan, block, (DropTableNode) node, stack);
-        break;
-      case ALTER_TABLESPACE:
-        current = visitAlterTablespace(context, plan, block, (AlterTablespaceNode) node, stack);
-        break;
-      case ALTER_TABLE:
-        current = visitAlterTable(context, plan, block, (AlterTableNode) node, stack);
-        break;
-      case TRUNCATE_TABLE:
-        current = visitTruncateTable(context, plan, block, (TruncateTableNode) node, stack);
-        break;
-      default:
-        throw new PlanningException("Unknown logical node type: " + node.getType());
-    }
-
-    return current;
-  }
-
-  @Override
-  public RESULT visitRoot(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, LogicalRootNode node,
-                          Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitProjection(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode node,
-                                Stack<LogicalNode> stack)
-      throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitLimit(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, LimitNode node,
-                           Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitSort(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, SortNode node,
-                          Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitHaving(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, HavingNode node,
-                            Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitGroupBy(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, GroupbyNode node,
-                             Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitWindowAgg(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, WindowAggNode node,
-                               Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  public RESULT visitDistinct(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, DistinctGroupbyNode node,
-                             Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitFilter(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node,
-                            Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitJoin(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node,
-                          Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getLeftChild(), stack);
-    visit(context, plan, block, node.getRightChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitUnion(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node,
-                           Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild());
-    RESULT result = visit(context, plan, leftBlock, leftBlock.getRoot(), stack);
-    LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild());
-    visit(context, plan, rightBlock, rightBlock.getRoot(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitExcept(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, ExceptNode node,
-                            Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getLeftChild(), stack);
-    visit(context, plan, block, node.getRightChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitIntersect(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, IntersectNode node,
-                               Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getLeftChild(), stack);
-    visit(context, plan, block, node.getRightChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitTableSubQuery(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                   TableSubQueryNode node, Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    LogicalPlan.QueryBlock childBlock = plan.getBlock(node.getSubQuery());
-    RESULT result = visit(context, plan, childBlock, childBlock.getRoot(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitScan(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, ScanNode node,
-                          Stack<LogicalNode> stack) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitPartitionedTableScan(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                          PartitionedTableScanNode node, Stack<LogicalNode> stack)
-      throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitStoreTable(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, StoreTableNode node,
-                                Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitInsert(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, InsertNode node,
-                            Stack<LogicalNode> stack) throws PlanningException {
-    stack.push(node);
-    RESULT result = visit(context, plan, block, node.getChild(), stack);
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitCreateDatabase(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                    CreateDatabaseNode node, Stack<LogicalNode> stack) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitDropDatabase(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, DropDatabaseNode node, Stack<LogicalNode> stack) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitCreateTable(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, CreateTableNode node,
-                                 Stack<LogicalNode> stack) throws PlanningException {
-    RESULT result = null;
-    stack.push(node);
-    if (node.hasSubQuery()) {
-      result = visit(context, plan, block, node.getChild(), stack);
-    }
-    stack.pop();
-    return result;
-  }
-
-  @Override
-  public RESULT visitDropTable(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, DropTableNode node,
-                               Stack<LogicalNode> stack) {
-    return null;
-  }
-
-  @Override
-  public RESULT visitAlterTablespace(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                     AlterTablespaceNode node, Stack<LogicalNode> stack) throws PlanningException {
-    return null;
-  }
-
-  @Override
-  public RESULT visitAlterTable(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, AlterTableNode node,
-                                 Stack<LogicalNode> stack) {
-        return null;
-    }
-
-  @Override
-  public RESULT visitTruncateTable(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                   TruncateTableNode node, Stack<LogicalNode> stack) throws PlanningException {
-    return null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinMarkCandidateVisitor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinMarkCandidateVisitor.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinMarkCandidateVisitor.java
index 28ef000..6b3dc48 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinMarkCandidateVisitor.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinMarkCandidateVisitor.java
@@ -19,10 +19,13 @@
 package org.apache.tajo.engine.planner;
 
 import org.apache.tajo.engine.planner.global.GlobalPlanner;
-import org.apache.tajo.engine.planner.logical.JoinNode;
-import org.apache.tajo.engine.planner.logical.LogicalNode;
-import org.apache.tajo.engine.planner.logical.NodeType;
-import org.apache.tajo.engine.planner.logical.ScanNode;
+import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
+import org.apache.tajo.plan.LogicalPlan;
+import org.apache.tajo.plan.PlanningException;
+import org.apache.tajo.plan.logical.JoinNode;
+import org.apache.tajo.plan.logical.LogicalNode;
+import org.apache.tajo.plan.logical.NodeType;
+import org.apache.tajo.plan.logical.ScanNode;
 
 import java.util.Stack;
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinPlanVisitor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinPlanVisitor.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinPlanVisitor.java
index 0fb8f36..bd8efbe 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinPlanVisitor.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/BroadcastJoinPlanVisitor.java
@@ -19,10 +19,13 @@
 package org.apache.tajo.engine.planner;
 
 import org.apache.tajo.engine.planner.global.GlobalPlanner;
-import org.apache.tajo.engine.planner.logical.JoinNode;
-import org.apache.tajo.engine.planner.logical.LogicalNode;
-import org.apache.tajo.engine.planner.logical.NodeType;
-import org.apache.tajo.engine.planner.logical.ScanNode;
+import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
+import org.apache.tajo.plan.LogicalPlan;
+import org.apache.tajo.plan.PlanningException;
+import org.apache.tajo.plan.logical.JoinNode;
+import org.apache.tajo.plan.logical.LogicalNode;
+import org.apache.tajo.plan.logical.NodeType;
+import org.apache.tajo.plan.logical.ScanNode;
 
 import java.util.Stack;
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/ExplainLogicalPlanVisitor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/ExplainLogicalPlanVisitor.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/ExplainLogicalPlanVisitor.java
deleted file mode 100644
index a7e5375..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/ExplainLogicalPlanVisitor.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tajo.engine.planner;
-
-import org.apache.tajo.annotation.Nullable;
-import org.apache.tajo.engine.planner.logical.*;
-
-import java.util.Stack;
-
-/**
- * It returns a list of node plan strings.
- */
-public class ExplainLogicalPlanVisitor extends BasicLogicalPlanVisitor<ExplainLogicalPlanVisitor.Context, LogicalNode> {
-
-  public static class Context {
-    public int maxDepth  = -1;
-    public int depth = 0;
-    public Stack<DepthString> explains = new Stack<DepthString>();
-
-    public void add(int depth, PlanString planString) {
-      maxDepth = Math.max(maxDepth, depth);
-      explains.push(new DepthString(depth, planString));
-    }
-
-    public int getMaxDepth() {
-      return this.maxDepth;
-    }
-
-    public Stack<DepthString> getExplains() {
-      return explains;
-    }
-  }
-
-  public static class DepthString {
-    private int depth;
-    private PlanString planStr;
-
-    DepthString(int depth, PlanString planStr) {
-      this.depth = depth;
-      this.planStr = planStr;
-    }
-
-    public int getDepth() {
-      return depth;
-    }
-
-    public PlanString getPlanString() {
-      return planStr;
-    }
-  }
-
-  public Context getBlockPlanStrings(@Nullable LogicalPlan plan, LogicalNode node) throws PlanningException {
-    Stack<LogicalNode> stack = new Stack<LogicalNode>();
-    Context explainContext = new Context();
-    visit(explainContext, plan, null, node, stack);
-    return explainContext;
-  }
-
-  @Override
-  public LogicalNode visitRoot(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, LogicalRootNode node, Stack<LogicalNode> stack)
-      throws PlanningException {
-    return visit(context, plan, block, node.getChild(), stack);
-  }
-
-  @Override
-  public LogicalNode visitProjection(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                     ProjectionNode node, Stack<LogicalNode> stack)
-      throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitLimit(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                LimitNode node, Stack<LogicalNode> stack) throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitSort(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, SortNode node,
-                               Stack<LogicalNode> stack) throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  public LogicalNode visitHaving(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, HavingNode node,
-                                  Stack<LogicalNode> stack) throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitGroupBy(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, GroupbyNode node,
-                                  Stack<LogicalNode> stack) throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitWindowAgg(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, WindowAggNode node,
-                                    Stack<LogicalNode> stack) throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  public LogicalNode visitDistinct(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, DistinctGroupbyNode node,
-                                  Stack<LogicalNode> stack) throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  private LogicalNode visitUnaryNode(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                     UnaryNode node, Stack<LogicalNode> stack) throws PlanningException {
-    context.depth++;
-    stack.push(node);
-    visit(context, plan, block, node.getChild(), stack);
-    context.depth--;
-    context.add(context.depth, node.getPlanString());
-    return node;
-  }
-
-  private LogicalNode visitBinaryNode(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, BinaryNode node,
-                                      Stack<LogicalNode> stack)
-      throws PlanningException {
-    context.depth++;
-    stack.push(node);
-    visit(context, plan, block, node.getLeftChild(), stack);
-    visit(context, plan, block, node.getRightChild(), stack);
-    stack.pop();
-    context.depth--;
-    context.add(context.depth, node.getPlanString());
-    return node;
-  }
-
-  @Override
-  public LogicalNode visitFilter(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node,
-                                 Stack<LogicalNode> stack) throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitJoin(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node,
-                               Stack<LogicalNode> stack) throws PlanningException {
-    return visitBinaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitUnion(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node,
-                                Stack<LogicalNode> stack) throws PlanningException {
-    return visitBinaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitExcept(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, ExceptNode node,
-                                 Stack<LogicalNode> stack) throws PlanningException {
-    return visitBinaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitIntersect(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, IntersectNode node,
-                                    Stack<LogicalNode> stack) throws PlanningException {
-    return visitBinaryNode(context, plan, block, node, stack);
-  }
-
-  @Override
-  public LogicalNode visitTableSubQuery(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                        TableSubQueryNode node, Stack<LogicalNode> stack) throws PlanningException {
-    context.depth++;
-    stack.push(node);
-    visit(context, plan, block, node.getSubQuery(), new Stack<LogicalNode>());
-    stack.pop();
-    context.depth--;
-    context.add(context.depth, node.getPlanString());
-
-    return node;
-  }
-
-  @Override
-  public LogicalNode visitScan(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, ScanNode node,
-                               Stack<LogicalNode> stack) throws PlanningException {
-    context.add(context.depth, node.getPlanString());
-    return node;
-  }
-
-  @Override
-  public LogicalNode visitPartitionedTableScan(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                          PartitionedTableScanNode node, Stack<LogicalNode> stack)
-      throws PlanningException {
-    context.add(context.depth, node.getPlanString());
-    return node;
-  }
-
-  @Override
-  public LogicalNode visitStoreTable(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                     StoreTableNode node, Stack<LogicalNode> stack) throws PlanningException {
-    return visitUnaryNode(context, plan, block, node, stack);
-  }
-
-  public LogicalNode visitCreateDatabase(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                         CreateDatabaseNode node, Stack<LogicalNode> stack) throws PlanningException {
-    context.add(context.depth, node.getPlanString());
-    return node;
-  }
-
-  public LogicalNode visitDropDatabase(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                         DropDatabaseNode node, Stack<LogicalNode> stack) throws PlanningException {
-    context.add(context.depth, node.getPlanString());
-    return node;
-  }
-
-  @Override
-  public LogicalNode visitInsert(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, InsertNode node,
-                                 Stack<LogicalNode> stack) throws PlanningException {
-    context.depth++;
-    stack.push(node);
-    super.visitInsert(context, plan, block, node, stack);
-    stack.pop();
-    context.depth--;
-    context.add(context.depth, node.getPlanString());
-    return node;
-  }
-
-  public static String printDepthString(int maxDepth, DepthString planStr) {
-    StringBuilder output = new StringBuilder();
-    String pad = new String(new char[planStr.getDepth() * 3]).replace('\0', ' ');
-    output.append(pad + planStr.getPlanString().getTitle()).append("\n");
-
-    for (String str : planStr.getPlanString().getExplanations()) {
-      output.append(pad).append("  => ").append(str).append("\n");
-    }
-
-    for (String str : planStr.getPlanString().getDetails()) {
-      output.append(pad).append("  => ").append(str).append("\n");
-    }
-    return output.toString();
-  }
-}


Mime
View raw message