You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2014/10/25 20:18:07 UTC
[18/28] TAJO-1125: Separate logical plan and optimizer into a maven
module.
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/TypeDeterminant.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/TypeDeterminant.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/TypeDeterminant.java
deleted file mode 100644
index 511814c..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/TypeDeterminant.java
+++ /dev/null
@@ -1,321 +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.Preconditions;
-import org.apache.tajo.algebra.*;
-import org.apache.tajo.catalog.CatalogService;
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.catalog.Column;
-import org.apache.tajo.catalog.FunctionDesc;
-import org.apache.tajo.catalog.exception.NoSuchFunctionException;
-import org.apache.tajo.catalog.proto.CatalogProtos;
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.DataTypeUtil;
-
-import java.util.Stack;
-
-import static org.apache.tajo.common.TajoDataTypes.DataType;
-import static org.apache.tajo.common.TajoDataTypes.Type.BOOLEAN;
-import static org.apache.tajo.common.TajoDataTypes.Type.NULL_TYPE;
-
-public class TypeDeterminant extends SimpleAlgebraVisitor<LogicalPlanner.PlanContext, DataType> {
- private DataType BOOL_TYPE = CatalogUtil.newSimpleDataType(BOOLEAN);
- private CatalogService catalog;
-
- public TypeDeterminant(CatalogService catalog) {
- this.catalog = catalog;
- }
-
- public DataType determineDataType(LogicalPlanner.PlanContext ctx, Expr expr) throws PlanningException {
- return visit(ctx, new Stack<Expr>(), expr);
- }
-
- @Override
- public DataType visitUnaryOperator(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, UnaryOperator expr)
- throws PlanningException {
- stack.push(expr);
- DataType dataType = null;
- switch (expr.getType()) {
- case IsNullPredicate:
- case ExistsPredicate:
- dataType = BOOL_TYPE;
- break;
- case Cast:
- dataType = LogicalPlanner.convertDataType(((CastExpr)expr).getTarget());
- break;
- default:
- dataType = visit(ctx, stack, expr.getChild());
- }
-
- return dataType;
- }
-
- @Override
- public DataType visitBinaryOperator(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, BinaryOperator expr)
- throws PlanningException {
- stack.push(expr);
- DataType lhsType = visit(ctx, stack, expr.getLeft());
- DataType rhsType = visit(ctx, stack, expr.getRight());
- stack.pop();
- return computeBinaryType(expr.getType(), lhsType, rhsType);
- }
-
- public DataType computeBinaryType(OpType type, DataType lhsDataType, DataType rhsDataType) throws PlanningException {
- Preconditions.checkNotNull(type);
- Preconditions.checkNotNull(lhsDataType);
- Preconditions.checkNotNull(rhsDataType);
-
- if(OpType.isLogicalType(type) || OpType.isComparisonType(type)) {
- return BOOL_TYPE;
- } else if (OpType.isArithmeticType(type)) {
- return DataTypeUtil.determineType(lhsDataType, rhsDataType);
- } else if (type == OpType.Concatenate) {
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.TEXT);
- } else if (type == OpType.InPredicate) {
- return BOOL_TYPE;
- } else if (type == OpType.LikePredicate || type == OpType.SimilarToPredicate || type == OpType.Regexp) {
- return BOOL_TYPE;
- } else {
- throw new PlanningException(type.name() + "is not binary type");
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Other Predicates Section
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- @Override
- public DataType visitBetween(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, BetweenPredicate expr)
- throws PlanningException {
- return CatalogUtil.newSimpleDataType(BOOLEAN);
- }
-
- @Override
- public DataType visitCaseWhen(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, CaseWhenPredicate caseWhen)
- throws PlanningException {
- DataType lastDataType = null;
-
- for (CaseWhenPredicate.WhenExpr when : caseWhen.getWhens()) {
- DataType resultType = visit(ctx, stack, when.getResult());
- if (lastDataType != null) {
- lastDataType = CatalogUtil.getWidestType(lastDataType, resultType);
- } else {
- lastDataType = resultType;
- }
- }
-
- if (caseWhen.hasElseResult()) {
- DataType elseResultType = visit(ctx, stack, caseWhen.getElseResult());
- lastDataType = CatalogUtil.getWidestType(lastDataType, elseResultType);
- }
-
- return lastDataType;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Other Expressions
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- @Override
- public DataType visitColumnReference(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, ColumnReferenceExpr expr)
- throws PlanningException {
- stack.push(expr);
- Column column = ctx.plan.resolveColumn(ctx.queryBlock, expr);
- stack.pop();
- return column.getDataType();
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
- // General Set Section
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- @Override
- public DataType visitFunction(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, FunctionExpr expr)
- throws PlanningException {
- stack.push(expr); // <--- Push
-
- // Given parameters
- Expr[] params = expr.getParams();
- if (params == null) {
- params = new Expr[0];
- }
-
- DataType[] givenArgs = new DataType[params.length];
- DataType[] paramTypes = new DataType[params.length];
-
- for (int i = 0; i < params.length; i++) {
- givenArgs[i] = visit(ctx, stack, params[i]);
- paramTypes[i] = givenArgs[i];
- }
-
- stack.pop(); // <--- Pop
-
- if (!catalog.containFunction(expr.getSignature(), paramTypes)) {
- throw new NoSuchFunctionException(expr.getSignature(), paramTypes);
- }
-
- FunctionDesc funcDesc = catalog.getFunction(expr.getSignature(), paramTypes);
- return funcDesc.getReturnType();
- }
-
- @Override
- public DataType visitCountRowsFunction(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, CountRowsFunctionExpr expr)
- throws PlanningException {
- FunctionDesc countRows = catalog.getFunction("count", CatalogProtos.FunctionType.AGGREGATION,
- new DataType[] {});
- return countRows.getReturnType();
- }
-
- @Override
- public DataType visitGeneralSetFunction(LogicalPlanner.PlanContext ctx, Stack<Expr> stack,
- GeneralSetFunctionExpr setFunction) throws PlanningException {
- stack.push(setFunction);
-
- Expr[] params = setFunction.getParams();
- DataType[] givenArgs = new DataType[params.length];
- DataType[] paramTypes = new DataType[params.length];
-
- CatalogProtos.FunctionType functionType = setFunction.isDistinct() ?
- CatalogProtos.FunctionType.DISTINCT_AGGREGATION : CatalogProtos.FunctionType.AGGREGATION;
- givenArgs[0] = visit(ctx, stack, params[0]);
- if (setFunction.getSignature().equalsIgnoreCase("count")) {
- paramTypes[0] = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.ANY);
- } else {
- paramTypes[0] = givenArgs[0];
- }
-
- stack.pop(); // <-- pop
-
- if (!catalog.containFunction(setFunction.getSignature(), functionType, paramTypes)) {
- throw new NoSuchFunctionException(setFunction.getSignature(), paramTypes);
- }
-
- FunctionDesc funcDesc = catalog.getFunction(setFunction.getSignature(), functionType, paramTypes);
- return funcDesc.getReturnType();
- }
-
- @Override
- public DataType visitWindowFunction(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, WindowFunctionExpr windowFunc)
- throws PlanningException {
- stack.push(windowFunc); // <--- Push
-
- String funcName = windowFunc.getSignature();
- boolean distinct = windowFunc.isDistinct();
- Expr[] params = windowFunc.getParams();
- DataType[] givenArgs = new DataType[params.length];
- TajoDataTypes.DataType[] paramTypes = new TajoDataTypes.DataType[params.length];
- CatalogProtos.FunctionType functionType;
-
- // Rewrite parameters if necessary
- if (params.length > 0) {
- givenArgs[0] = visit(ctx, stack, params[0]);
-
- if (windowFunc.getSignature().equalsIgnoreCase("count")) {
- paramTypes[0] = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.ANY);
- } else if (windowFunc.getSignature().equalsIgnoreCase("row_number")) {
- paramTypes[0] = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.INT8);
- } else {
- paramTypes[0] = givenArgs[0];
- }
- }
- stack.pop(); // <--- Pop
-
- // TODO - containFunction and getFunction should support the function type mask which provides ORing multiple types.
- // the below checking against WINDOW_FUNCTIONS is a workaround code for the above problem.
- if (ExprAnnotator.WINDOW_FUNCTIONS.contains(funcName.toLowerCase())) {
- if (distinct) {
- throw new NoSuchFunctionException("row_number() does not support distinct keyword.");
- }
- functionType = CatalogProtos.FunctionType.WINDOW;
- } else {
- functionType = distinct ?
- CatalogProtos.FunctionType.DISTINCT_AGGREGATION : CatalogProtos.FunctionType.AGGREGATION;
- }
-
- if (!catalog.containFunction(windowFunc.getSignature(), functionType, paramTypes)) {
- throw new NoSuchFunctionException(funcName, paramTypes);
- }
-
- FunctionDesc funcDesc = catalog.getFunction(funcName, functionType, paramTypes);
-
- return funcDesc.getReturnType();
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Literal Section
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- @Override
- public DataType visitDataType(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, DataTypeExpr expr)
- throws PlanningException {
- return LogicalPlanner.convertDataType(expr);
- }
-
- @Override
- public DataType visitLiteral(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, LiteralValue expr)
- throws PlanningException {
- // It must be the same to ExprAnnotator::visitLiteral.
-
- switch (expr.getValueType()) {
- case Boolean:
- return CatalogUtil.newSimpleDataType(BOOLEAN);
- case String:
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.TEXT);
- case Unsigned_Integer:
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.INT4);
- case Unsigned_Large_Integer:
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.INT8);
- case Unsigned_Float:
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.FLOAT8);
- default:
- throw new RuntimeException("Unsupported type: " + expr.getValueType());
- }
- }
-
- @Override
- public DataType visitNullLiteral(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, NullLiteral expr)
- throws PlanningException {
- return CatalogUtil.newSimpleDataType(NULL_TYPE);
- }
-
- @Override
- public DataType visitTimestampLiteral(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, TimestampLiteral expr)
- throws PlanningException {
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.TIMESTAMP);
- }
-
- @Override
- public DataType visitTimeLiteral(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, TimeLiteral expr)
- throws PlanningException {
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.TIME);
- }
-
- @Override
- public DataType visitDateLiteral(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, DateLiteral expr)
- throws PlanningException {
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.DATE);
- }
-
- @Override
- public DataType visitIntervalLiteral(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, IntervalLiteral expr)
- throws PlanningException {
- return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.INTERVAL);
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/VerificationState.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/VerificationState.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/VerificationState.java
deleted file mode 100644
index 18882b8..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/VerificationState.java
+++ /dev/null
@@ -1,44 +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.collect.Lists;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.tajo.util.TUtil;
-
-import java.util.List;
-
-public class VerificationState {
- private static final Log LOG = LogFactory.getLog(VerificationState.class);
- List<String> errorMessages = Lists.newArrayList();
-
- public void addVerification(String error) {
- LOG.warn(TUtil.getCurrentCodePoint(1) + " causes: " + error);
- errorMessages.add(error);
- }
-
- public boolean verified() {
- return errorMessages.size() == 0;
- }
-
- public List<String> getErrorMessages() {
- return errorMessages;
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/DataChannel.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/DataChannel.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/DataChannel.java
index b3b5bb0..4a2cd19 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/DataChannel.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/DataChannel.java
@@ -22,11 +22,13 @@ import com.google.common.base.Preconditions;
import org.apache.tajo.ExecutionBlockId;
import org.apache.tajo.catalog.Column;
import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.engine.utils.SchemaUtil;
+import org.apache.tajo.plan.util.SchemaUtil;
import org.apache.tajo.util.TUtil;
import static org.apache.tajo.catalog.proto.CatalogProtos.StoreType;
import static org.apache.tajo.ipc.TajoWorkerProtocol.*;
+import static org.apache.tajo.plan.serder.PlanProto.ShuffleType;
+import static org.apache.tajo.plan.serder.PlanProto.TransmitType;
public class DataChannel {
private ExecutionBlockId srcId;
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/ExecutionBlock.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/ExecutionBlock.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/ExecutionBlock.java
index 1d14996..77eb32d 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/ExecutionBlock.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/ExecutionBlock.java
@@ -16,7 +16,7 @@ package org.apache.tajo.engine.planner.global;
import org.apache.tajo.ExecutionBlockId;
import org.apache.tajo.engine.planner.enforce.Enforcer;
-import org.apache.tajo.engine.planner.logical.*;
+import org.apache.tajo.plan.logical.*;
import java.util.*;
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
index 01e02d7..b33e4a0 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
@@ -33,13 +33,19 @@ import org.apache.tajo.catalog.partition.PartitionMethodDesc;
import org.apache.tajo.catalog.proto.CatalogProtos;
import org.apache.tajo.common.TajoDataTypes;
import org.apache.tajo.conf.TajoConf;
-import org.apache.tajo.engine.eval.*;
-import org.apache.tajo.engine.function.AggFunction;
-import org.apache.tajo.engine.planner.*;
+import org.apache.tajo.engine.planner.BroadcastJoinMarkCandidateVisitor;
+import org.apache.tajo.engine.planner.BroadcastJoinPlanVisitor;
import org.apache.tajo.engine.planner.global.builder.DistinctGroupbyBuilder;
-import org.apache.tajo.engine.planner.logical.*;
-import org.apache.tajo.engine.planner.rewrite.ProjectionPushDownRule;
import org.apache.tajo.exception.InternalException;
+import org.apache.tajo.plan.LogicalPlan;
+import org.apache.tajo.plan.util.PlannerUtil;
+import org.apache.tajo.plan.PlanningException;
+import org.apache.tajo.plan.Target;
+import org.apache.tajo.plan.expr.*;
+import org.apache.tajo.plan.function.AggFunction;
+import org.apache.tajo.plan.logical.*;
+import org.apache.tajo.plan.rewrite.rules.ProjectionPushDownRule;
+import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
import org.apache.tajo.util.KeyValueSet;
import org.apache.tajo.util.TUtil;
import org.apache.tajo.worker.TajoWorker;
@@ -48,7 +54,7 @@ import java.io.IOException;
import java.util.*;
import static org.apache.tajo.conf.TajoConf.ConfVars;
-import static org.apache.tajo.ipc.TajoWorkerProtocol.ShuffleType.*;
+import static org.apache.tajo.plan.serder.PlanProto.ShuffleType.*;
/**
* Build DAG
@@ -520,7 +526,7 @@ public class GlobalPlanner {
}
}
- private AggregationFunctionCallEval createSumFunction(EvalNode [] args) throws InternalException {
+ private AggregationFunctionCallEval createSumFunction(EvalNode[] args) throws InternalException {
FunctionDesc functionDesc = getCatalog().getFunction("sum", CatalogProtos.FunctionType.AGGREGATION,
args[0].getValueType());
return new AggregationFunctionCallEval(functionDesc, (AggFunction) functionDesc.newInstance(), args);
@@ -556,7 +562,7 @@ public class GlobalPlanner {
*/
private static class RewrittenFunctions {
AggregationFunctionCallEval [] firstStageEvals;
- Target [] firstStageTargets;
+ Target[] firstStageTargets;
AggregationFunctionCallEval secondStageEvals;
public RewrittenFunctions(int firstStageEvalNum) {
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/MasterPlan.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/MasterPlan.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/MasterPlan.java
index 9b99c5f..3cca4f2 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/MasterPlan.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/MasterPlan.java
@@ -23,10 +23,10 @@ package org.apache.tajo.engine.planner.global;
import org.apache.tajo.ExecutionBlockId;
import org.apache.tajo.QueryId;
-import org.apache.tajo.engine.planner.LogicalPlan;
-import org.apache.tajo.engine.planner.PlannerUtil;
+import org.apache.tajo.plan.LogicalPlan;
+import org.apache.tajo.plan.util.PlannerUtil;
import org.apache.tajo.engine.planner.enforce.Enforcer;
-import org.apache.tajo.engine.planner.graph.SimpleDirectedGraph;
+import org.apache.tajo.util.graph.SimpleDirectedGraph;
import org.apache.tajo.engine.query.QueryContext;
import org.apache.tajo.ipc.TajoWorkerProtocol;
@@ -36,6 +36,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
+import static org.apache.tajo.plan.serder.PlanProto.ShuffleType;
+
public class MasterPlan {
private final QueryId queryId;
private final QueryContext context;
@@ -110,11 +112,11 @@ public class MasterPlan {
execBlockGraph.addEdge(dataChannel.getSrcId(), dataChannel.getTargetId(), dataChannel);
}
- public void addConnect(ExecutionBlock src, ExecutionBlock target, TajoWorkerProtocol.ShuffleType type) {
+ public void addConnect(ExecutionBlock src, ExecutionBlock target, ShuffleType type) {
addConnect(src.getId(), target.getId(), type);
}
- public void addConnect(ExecutionBlockId src, ExecutionBlockId target, TajoWorkerProtocol.ShuffleType type) {
+ public void addConnect(ExecutionBlockId src, ExecutionBlockId target, ShuffleType type) {
addConnect(new DataChannel(src, target, type));
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java
index cbe2d7e..671bb19 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java
@@ -25,32 +25,31 @@ import org.apache.tajo.catalog.Column;
import org.apache.tajo.catalog.Schema;
import org.apache.tajo.catalog.proto.CatalogProtos.SortSpecProto;
import org.apache.tajo.common.TajoDataTypes.Type;
-import org.apache.tajo.engine.eval.AggregationFunctionCallEval;
-import org.apache.tajo.engine.eval.EvalNode;
-import org.apache.tajo.engine.eval.EvalTreeUtil;
-import org.apache.tajo.engine.eval.FieldEval;
-import org.apache.tajo.engine.planner.LogicalPlan;
-import org.apache.tajo.engine.planner.PlannerUtil;
-import org.apache.tajo.engine.planner.PlanningException;
-import org.apache.tajo.engine.planner.Target;
import org.apache.tajo.engine.planner.global.DataChannel;
import org.apache.tajo.engine.planner.global.ExecutionBlock;
import org.apache.tajo.engine.planner.global.GlobalPlanner;
import org.apache.tajo.engine.planner.global.GlobalPlanner.GlobalPlanContext;
import org.apache.tajo.engine.planner.global.MasterPlan;
-import org.apache.tajo.engine.planner.logical.DistinctGroupbyNode;
-import org.apache.tajo.engine.planner.logical.GroupbyNode;
-import org.apache.tajo.engine.planner.logical.LogicalNode;
-import org.apache.tajo.engine.planner.logical.ScanNode;
-import org.apache.tajo.engine.planner.rewrite.ProjectionPushDownRule;
import org.apache.tajo.ipc.TajoWorkerProtocol.DistinctGroupbyEnforcer.DistinctAggregationAlgorithm;
import org.apache.tajo.ipc.TajoWorkerProtocol.DistinctGroupbyEnforcer.MultipleAggregationStage;
import org.apache.tajo.ipc.TajoWorkerProtocol.DistinctGroupbyEnforcer.SortSpecArray;
+import org.apache.tajo.plan.LogicalPlan;
+import org.apache.tajo.plan.util.PlannerUtil;
+import org.apache.tajo.plan.PlanningException;
+import org.apache.tajo.plan.Target;
+import org.apache.tajo.plan.expr.AggregationFunctionCallEval;
+import org.apache.tajo.plan.expr.EvalNode;
+import org.apache.tajo.plan.expr.EvalTreeUtil;
+import org.apache.tajo.plan.expr.FieldEval;
+import org.apache.tajo.plan.logical.DistinctGroupbyNode;
+import org.apache.tajo.plan.logical.GroupbyNode;
+import org.apache.tajo.plan.logical.LogicalNode;
+import org.apache.tajo.plan.logical.ScanNode;
import org.apache.tajo.util.TUtil;
import java.util.*;
-import static org.apache.tajo.ipc.TajoWorkerProtocol.ShuffleType.HASH_SHUFFLE;
+import static org.apache.tajo.plan.serder.PlanProto.ShuffleType.HASH_SHUFFLE;
public class DistinctGroupbyBuilder {
private static Log LOG = LogFactory.getLog(DistinctGroupbyBuilder.class);
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraph.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraph.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraph.java
deleted file mode 100644
index c6f4aaa..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraph.java
+++ /dev/null
@@ -1,64 +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.graph;
-
-import org.apache.tajo.annotation.Nullable;
-
-import java.util.List;
-
-/**
- * This represents a directed graph.
- *
- * @param <V> The vertex class type
- * @param <E> The edge class type
- */
-public interface DirectedGraph<V, E> extends Graph<V, E> {
-
- boolean hasReversedEdge(V head, V tail);
-
- E getReverseEdge(V head, V tail);
-
- List<E> getIncomingEdges(V head);
-
- List<E> getOutgoingEdges(V tail);
-
- /////////////////////////////////
- // belows are tree features
- /////////////////////////////////
- boolean isRoot(V v);
-
- boolean isLeaf(V v);
-
- int getParentCount(V block);
-
- @Nullable V getParent(V block, int idx);
-
- List<V> getParents(V block);
-
- int getChildCount(V block);
-
- @Nullable V getChild(V block, int idx);
-
- List<V> getChilds(V block);
-
- /**
- * It visits all vertices in a post-order traverse way.
- */
- void accept(V src, DirectedGraphVisitor<V> visitor);
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraphCursor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraphCursor.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraphCursor.java
deleted file mode 100644
index 7db9b83..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraphCursor.java
+++ /dev/null
@@ -1,65 +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.graph;
-
-import java.util.ArrayList;
-
-public class DirectedGraphCursor<V,E> {
- private DirectedGraph<V,E> graph;
- private ArrayList<V> orderedVertices = new ArrayList<V>();
- private int cursor = 0;
-
- public DirectedGraphCursor(DirectedGraph<V, E> graph, V startVertex) {
- this.graph = graph;
- buildOrder(startVertex);
- }
-
- public int size() {
- return orderedVertices.size();
- }
-
- private void buildOrder(V current) {
- if (!graph.isLeaf(current)) {
- for (V child : graph.getChilds(current)) {
- buildOrder(child);
- }
- }
- orderedVertices.add(current);
- }
-
- public boolean hasNext() {
- return cursor < orderedVertices.size();
- }
-
- public V nextBlock() {
- return orderedVertices.get(cursor++);
- }
-
- public V peek() {
- return orderedVertices.get(cursor);
- }
-
- public V peek(int skip) {
- return orderedVertices.get(cursor + skip);
- }
-
- public void reset() {
- cursor = 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraphVisitor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraphVisitor.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraphVisitor.java
deleted file mode 100644
index 3deec7f..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/DirectedGraphVisitor.java
+++ /dev/null
@@ -1,25 +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.graph;
-
-import java.util.Stack;
-
-public interface DirectedGraphVisitor<V> {
- void visit(Stack<V> stack, V v);
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/Graph.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/Graph.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/Graph.java
deleted file mode 100644
index d380b94..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/Graph.java
+++ /dev/null
@@ -1,45 +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.graph;
-
-import org.apache.tajo.annotation.Nullable;
-
-import java.util.Collection;
-
-/**
- * This is the topmost graph interface. It only provides essential graph features.
- * @param <V> Vertex class
- * @param <E> Edge Class
- */
-
-public interface Graph<V, E> {
- int getVertexSize();
-
- int getEdgeNum();
-
- void addEdge(V tail, V head, E edge);
-
- void removeEdge(V tail, V head);
-
- boolean hasEdge(V tail, V head);
-
- @Nullable E getEdge(V tail, V head);
-
- Collection<E> getEdgesAll();
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/SimpleDirectedGraph.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/SimpleDirectedGraph.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/SimpleDirectedGraph.java
deleted file mode 100644
index 396eb8b..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/SimpleDirectedGraph.java
+++ /dev/null
@@ -1,270 +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.graph;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.apache.tajo.annotation.Nullable;
-import org.apache.tajo.util.TUtil;
-
-import java.util.*;
-
-/**
- * This represents a simple directed graph. It does not support multiple edges between both vertices.
- *
- * @param <V> The vertex class type
- * @param <E> The edge class type
- */
-public class SimpleDirectedGraph<V, E> implements DirectedGraph<V,E> {
- /** map: child -> parent */
- protected Map<V, Map<V, E>> directedEdges = TUtil.newLinkedHashMap();
- /** map: parent -> child */
- protected Map<V, Map<V, E>> reversedEdges = TUtil.newLinkedHashMap();
-
- @Override
- public int getVertexSize() {
- return directedEdges.size();
- }
-
- @Override
- public int getEdgeNum() {
- int edgeNum = 0;
- for (Map<V, E> map : directedEdges.values()) {
- edgeNum += map.values().size();
- }
-
- return edgeNum;
- }
-
- @Override
- public void addEdge(V tail, V head, E edge) {
- TUtil.putToNestedMap(directedEdges, tail, head, edge);
- TUtil.putToNestedMap(reversedEdges, head, tail, edge);
- }
-
- @Override
- public void removeEdge(V tail, V head) {
- if (directedEdges.containsKey(tail)) {
- directedEdges.get(tail).remove(head);
- if (directedEdges.get(tail).isEmpty()) {
- directedEdges.remove(tail);
- }
-
- reversedEdges.get(head).remove(tail);
- if (reversedEdges.get(head).isEmpty()) {
- reversedEdges.remove(head);
- }
- } else {
- throw new RuntimeException("Not connected channel: " + tail + " -> " + head);
- }
- }
-
- @Override
- public boolean hasEdge(V tail, V head) {
- return directedEdges.containsKey(tail) && directedEdges.get(tail).containsKey(head);
- }
-
- @Override
- public boolean hasReversedEdge(V head, V tail) {
- return reversedEdges.containsKey(head) && reversedEdges.get(head).containsKey(tail);
- }
-
- @Override
- public @Nullable E getEdge(V tail, V head) {
- if (hasEdge(tail, head)) {
- return directedEdges.get(tail).get(head);
- } else {
- return null;
- }
- }
-
- @Override
- public @Nullable
- E getReverseEdge(V head, V tail) {
- if (hasReversedEdge(head, tail)) {
- return reversedEdges.get(head).get(tail);
- } else {
- return null;
- }
- }
-
- @Override
- public Collection<E> getEdgesAll() {
- List<E> edges = Lists.newArrayList();
- for (Map<V, E> map : directedEdges.values()) {
- edges.addAll(map.values());
- }
- return edges;
- }
-
- @Override
- public int getChildCount(V v) {
- if (reversedEdges.containsKey(v)) {
- return reversedEdges.get(v).size();
- } else {
- return 0;
- }
- }
-
- @Override
- public List<E> getIncomingEdges(V head) {
- if (reversedEdges.containsKey(head)) {
- return ImmutableList.copyOf(reversedEdges.get(head).values());
- } else {
- return null;
- }
- }
-
- @Override
- public List<E> getOutgoingEdges(V tail) {
- if (directedEdges.containsKey(tail)) {
- return ImmutableList.copyOf(directedEdges.get(tail).values());
- } else {
- return null;
- }
- }
-
- @Override
- public List<V> getChilds(V v) {
- List<V> childBlocks = new ArrayList<V>();
- if (reversedEdges.containsKey(v)) {
- for (Map.Entry<V, E> entry: reversedEdges.get(v).entrySet()) {
- childBlocks.add(entry.getKey());
- }
- }
- return childBlocks;
- }
-
- @Override
- public V getChild(V block, int idx) {
- if (reversedEdges.containsKey(block)) {
- int i = 0;
- for (Map.Entry<V, E> entry: reversedEdges.get(block).entrySet()) {
- if (idx == i++) {
- return entry.getKey();
- }
- }
- }
- return null;
- }
-
- @Override
- public @Nullable V getParent(V block, int idx) {
- if (directedEdges.containsKey(block)) {
- int i = 0;
- for (Map.Entry<V, E> entry: directedEdges.get(block).entrySet()) {
- if (idx == i++) {
- return entry.getKey();
- }
- }
- }
- return null;
- }
-
- @Override
- public List<V> getParents(V block) {
- List<V> childBlocks = new ArrayList<V>();
- if (directedEdges.containsKey(block)) {
- for (Map.Entry<V, E> entry: directedEdges.get(block).entrySet()) {
- childBlocks.add(entry.getKey());
- }
- }
- return childBlocks;
- }
-
- @Override
- public boolean isRoot(V v) {
- return !directedEdges.containsKey(v);
- }
-
- @Override
- public boolean isLeaf(V v) {
- return !reversedEdges.containsKey(v);
- }
-
- @Override
- public int getParentCount(V block) {
- if (directedEdges.containsKey(block)) {
- return directedEdges.get(block).size();
- } else {
- return -1;
- }
- }
-
- @Override
- public void accept(V source, DirectedGraphVisitor<V> visitor) {
- Stack<V> stack = new Stack<V>();
- visitRecursive(stack, source, visitor);
- }
-
- private void visitRecursive(Stack<V> stack, V current, DirectedGraphVisitor<V> visitor) {
- stack.push(current);
- for (V child : getChilds(current)) {
- visitRecursive(stack, child, visitor);
- }
- stack.pop();
- visitor.visit(stack, current);
- }
-
- public String toString() {
- return "G (|v| = " + directedEdges.size() +")";
- }
-
- public String printDepthString(DepthString planStr) {
- StringBuilder output = new StringBuilder();
- String pad = new String(new char[planStr.depth * 3]).replace('\0', ' ');
- output.append(pad + "|-" + planStr.vertexStr).append("\n");
-
- return output.toString();
- }
-
- public String toStringGraph(V vertex) {
- StringBuilder sb = new StringBuilder();
- QueryGraphTopologyStringBuilder visitor = new QueryGraphTopologyStringBuilder();
- accept(vertex, visitor);
- Stack<DepthString> depthStrings = visitor.getDepthStrings();
- while(!depthStrings.isEmpty()) {
- sb.append(printDepthString(depthStrings.pop()));
- }
- return sb.toString();
- }
-
- private class DepthString {
- int depth;
- String vertexStr;
-
- DepthString(int depth, String vertexStr) {
- this.depth = depth;
- this.vertexStr = vertexStr;
- }
- }
-
- private class QueryGraphTopologyStringBuilder implements DirectedGraphVisitor<V> {
- Stack<DepthString> depthString = new Stack<DepthString>();
-
- @Override
- public void visit(Stack<V> stack, V vertex) {
- depthString.push(new DepthString(stack.size(), vertex.toString()));
- }
-
- public Stack<DepthString> getDepthStrings() {
- return depthString;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/SimpleUndirectedGraph.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/SimpleUndirectedGraph.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/SimpleUndirectedGraph.java
deleted file mode 100644
index 3822ad7..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/SimpleUndirectedGraph.java
+++ /dev/null
@@ -1,102 +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.graph;
-
-import com.google.common.collect.Lists;
-import org.apache.tajo.annotation.Nullable;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This implementation is based on a directed graph implementation. Each edge is connected in bidirection
- * between two vertices.
- *
- * @param <V> Vertex Class
- * @param <E> Edge Class
- */
-public class SimpleUndirectedGraph<V, E> extends SimpleDirectedGraph<V, E> implements UndirectedGraph<V, E> {
-
- @Override
- public @Nullable E getEdge(V tail, V head) {
- E edge = super.getEdge(tail, head);
- if (edge != null) {
- return edge;
- }
- edge = super.getEdge(head, tail);
- if (edge != null) {
- return edge;
- }
- return null;
- }
-
- @Override
- public Collection<E> getEdges(V v) {
- List<E> edges = Lists.newArrayList();
- List<E> outgoingEdges = getOutgoingEdges(v);
- if (outgoingEdges != null) {
- edges.addAll(outgoingEdges);
- }
- List<E> incomingEdges = getIncomingEdges(v);
- if (incomingEdges != null) {
- edges.addAll(incomingEdges);
- }
- return edges;
- }
-
- @Override
- public int getDegree(V v) {
- return getEdges(v).size();
- }
-
- @Override
- public Collection<E> getEdgesAll() {
- List<E> edges = Lists.newArrayList();
- for (Map<V, E> map : directedEdges.values()) {
- edges.addAll(map.values());
- }
- return edges;
- }
-
- @Override
- public V getParent(V v, int idx) {
- throw new UnsupportedOperationException("Cannot support getParent(V v) in UndirectedGraph");
- }
-
- @Override
- public int getParentCount(V v) {
- throw new UnsupportedOperationException("Cannot support getParent(V v) in UndirectedGraph");
- }
-
- @Override
- public List<V> getParents(V v) {
- throw new UnsupportedOperationException("Cannot support getParent(V v) in UndirectedGraph");
- }
-
- @Override
- public boolean isRoot(V v) {
- throw new UnsupportedOperationException("Cannot support isRoot(V v) in UndirectedGraph");
- }
-
- @Override
- public boolean isLeaf(V v) {
- throw new UnsupportedOperationException("Cannot support isLeaf(V v) in UndirectedGraph");
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/UndirectedGraph.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/UndirectedGraph.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/UndirectedGraph.java
deleted file mode 100644
index 7f74cd1..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/graph/UndirectedGraph.java
+++ /dev/null
@@ -1,30 +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.graph;
-
-
-import org.apache.tajo.annotation.NotNull;
-
-import java.util.Collection;
-
-public interface UndirectedGraph<V, E> extends Graph<V, E> {
- Collection<E> getEdges(@NotNull V v);
-
- int getDegree(@NotNull V v);
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/AlterTableNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/AlterTableNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/AlterTableNode.java
deleted file mode 100644
index 76a47d0..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/AlterTableNode.java
+++ /dev/null
@@ -1,134 +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.logical;
-
-
-import com.google.gson.annotations.Expose;
-import org.apache.tajo.algebra.AlterTableOpType;
-import org.apache.tajo.catalog.Column;
-import org.apache.tajo.engine.planner.PlanString;
-
-public class AlterTableNode extends LogicalNode {
-
- @Expose
- private String tableName;
- @Expose
- private String newTableName;
- @Expose
- private String columnName;
- @Expose
- private String newColumnName;
- @Expose
- private Column addNewColumn;
- @Expose
- private AlterTableOpType alterTableOpType;
-
- public AlterTableNode(int pid) {
- super(pid, NodeType.ALTER_TABLE);
- }
-
- public String getTableName() {
- return tableName;
- }
-
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
-
- public String getNewTableName() {
- return newTableName;
- }
-
- public void setNewTableName(String newTableName) {
- this.newTableName = newTableName;
- }
-
- public String getColumnName() {
- return columnName;
- }
-
- public void setColumnName(String columnName) {
- this.columnName = columnName;
- }
-
- public String getNewColumnName() {
- return newColumnName;
- }
-
- public void setNewColumnName(String newColumnName) {
- this.newColumnName = newColumnName;
- }
-
- public Column getAddNewColumn() {
- return addNewColumn;
- }
-
- public void setAddNewColumn(Column addNewColumn) {
- this.addNewColumn = addNewColumn;
- }
-
- public AlterTableOpType getAlterTableOpType() {
- return alterTableOpType;
- }
-
- public void setAlterTableOpType(AlterTableOpType alterTableOpType) {
- this.alterTableOpType = alterTableOpType;
- }
-
- @Override
- public PlanString getPlanString() {
- return new PlanString(this);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof AlterTableNode) {
- AlterTableNode other = (AlterTableNode) obj;
- return super.equals(other);
- } else {
- return false;
- }
- }
-
- /*@Override
- public Object clone() throws CloneNotSupportedException {
- AlterTableNode alterTableNode = (AlterTableNode) super.clone();
- alterTableNode.tableName = tableName;
- alterTableNode.newTableName = newTableName;
- alterTableNode.columnName = columnName;
- alterTableNode.newColumnName=newColumnName;
- alterTableNode.addNewColumn =(Column) addNewColumn.clone();
- return alterTableNode;
- }*/
-
- @Override
- public String toString() {
- return "AlterTable (table=" + tableName + ")";
- }
-
- @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/logical/BinaryNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/BinaryNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/BinaryNode.java
deleted file mode 100644
index 8aaeb58..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/BinaryNode.java
+++ /dev/null
@@ -1,77 +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.logical;
-
-import com.google.gson.annotations.Expose;
-import org.apache.tajo.json.GsonObject;
-
-public abstract class BinaryNode extends LogicalNode implements Cloneable, GsonObject {
- @Expose LogicalNode leftChild = null;
- @Expose LogicalNode rightChild = null;
-
- public BinaryNode(int pid, NodeType nodeType) {
- super(pid, nodeType);
- }
-
- public <T extends LogicalNode> T getLeftChild() {
- return (T) this.leftChild;
- }
-
- public void setLeftChild(LogicalNode op) {
- this.leftChild = op;
- }
-
- public <T extends LogicalNode> T getRightChild() {
- return (T) this.rightChild;
- }
-
- public void setRightChild(LogicalNode op) {
- this.rightChild = op;
- }
-
- public boolean deepEquals(Object o) {
- if (o instanceof BinaryNode) {
- BinaryNode b = (BinaryNode) o;
- return equals(o) &&
- leftChild.deepEquals(b.leftChild) && rightChild.deepEquals(b.rightChild);
- }
- return false;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- BinaryNode binNode = (BinaryNode) super.clone();
- binNode.leftChild = (LogicalNode) leftChild.clone();
- binNode.rightChild = (LogicalNode) rightChild.clone();
-
- return binNode;
- }
-
- public void preOrder(LogicalNodeVisitor visitor) {
- visitor.visit(this);
- leftChild.postOrder(visitor);
- rightChild.postOrder(visitor);
- }
-
- public void postOrder(LogicalNodeVisitor visitor) {
- leftChild.postOrder(visitor);
- rightChild.postOrder(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/logical/CreateDatabaseNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/CreateDatabaseNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/CreateDatabaseNode.java
deleted file mode 100644
index 9dc73e2..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/CreateDatabaseNode.java
+++ /dev/null
@@ -1,87 +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.logical;
-
-import com.google.common.base.Objects;
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.engine.planner.PlanString;
-
-public class CreateDatabaseNode extends LogicalNode implements Cloneable {
- private String databaseName;
- private boolean ifNotExists;
-
- public CreateDatabaseNode(int pid) {
- super(pid, NodeType.CREATE_DATABASE);
- }
-
- public void init(String databaseName, boolean ifNotExists) {
- this.databaseName = databaseName;
- this.ifNotExists = ifNotExists;
- }
-
- public String getDatabaseName() {
- return this.databaseName;
- }
-
- public boolean isIfNotExists() {
- return ifNotExists;
- }
-
- @Override
- public PlanString getPlanString() {
- return new PlanString(this).appendTitle(ifNotExists ? " IF NOT EXISTS " : " ").appendTitle(databaseName);
- }
-
- public int hashCode() {
- return Objects.hashCode(databaseName, ifNotExists);
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof CreateDatabaseNode) {
- CreateDatabaseNode other = (CreateDatabaseNode) obj;
- return super.equals(other) && this.databaseName.equals(other.databaseName) && ifNotExists == other.ifNotExists;
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- CreateDatabaseNode newNode = (CreateDatabaseNode) super.clone();
- newNode.databaseName = databaseName;
- newNode.ifNotExists = ifNotExists;
- return newNode;
- }
-
- @Override
- public String toString() {
- return "CREATE DATABASE " + (ifNotExists ? " IF NOT EXISTS " : "")
- + CatalogUtil.denormalizeIdentifier(databaseName);
- }
-
- @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/logical/CreateTableNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/CreateTableNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/CreateTableNode.java
deleted file mode 100644
index a39b391..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/CreateTableNode.java
+++ /dev/null
@@ -1,145 +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.logical;
-
-import com.google.common.base.Objects;
-import com.google.gson.annotations.Expose;
-import org.apache.hadoop.fs.Path;
-import org.apache.tajo.util.KeyValueSet;
-import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.engine.planner.PlanString;
-import org.apache.tajo.util.TUtil;
-
-public class CreateTableNode extends StoreTableNode implements Cloneable {
- @Expose private Schema schema;
- @Expose private Path path;
- @Expose private boolean external;
- @Expose private boolean ifNotExists;
-
- public CreateTableNode(int pid) {
- super(pid, NodeType.CREATE_TABLE);
- }
-
- public void setTableSchema(Schema schema) {
- this.schema = schema;
- }
-
- public Schema getTableSchema() {
- return this.schema;
- }
-
- public Schema getLogicalSchema() {
- if (hasPartition()) {
- Schema logicalSchema = new Schema(schema);
- logicalSchema.addColumns(getPartitionMethod().getExpressionSchema());
- return logicalSchema;
- } else {
- return schema;
- }
- }
-
- public boolean hasPath() {
- return this.path != null;
- }
-
- public void setPath(Path path) {
- this.path = path;
- }
-
- public Path getPath() {
- return this.path;
- }
-
- public boolean isExternal() {
- return external;
- }
-
- public void setExternal(boolean external) {
- this.external = external;
- }
-
- public boolean hasSubQuery() {
- return child != null;
- }
-
- public void setIfNotExists(boolean ifNotExists) {
- this.ifNotExists = ifNotExists;
- }
-
- public boolean isIfNotExists() {
- return ifNotExists;
- }
-
- @Override
- public PlanString getPlanString() {
- return new PlanString(this);
- }
-
- public int hashCode() {
- return super.hashCode() ^ Objects.hashCode(schema, path, external, ifNotExists) * 31;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof CreateTableNode) {
- CreateTableNode other = (CreateTableNode) obj;
- return super.equals(other)
- && this.schema.equals(other.schema)
- && this.external == other.external
- && TUtil.checkEquals(path, other.path)
- && ifNotExists == other.ifNotExists;
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- CreateTableNode createTableNode = (CreateTableNode) super.clone();
- createTableNode.tableName = tableName;
- createTableNode.schema = (Schema) schema.clone();
- createTableNode.storageType = storageType;
- createTableNode.external = external;
- createTableNode.path = path != null ? new Path(path.toString()) : null;
- createTableNode.options = (KeyValueSet) (options != null ? options.clone() : null);
- createTableNode.ifNotExists = ifNotExists;
- return createTableNode;
- }
-
- public String toString() {
- return "CreateTable (table=" + tableName + ", external=" + external + ", storeType=" + storageType +
- ", ifNotExists=" + ifNotExists +")";
- }
-
- @Override
- public void preOrder(LogicalNodeVisitor visitor) {
- if (hasSubQuery()) {
- child.preOrder(visitor);
- }
- visitor.visit(this);
- }
-
- @Override
- public void postOrder(LogicalNodeVisitor visitor) {
- visitor.visit(this);
- if (hasSubQuery()) {
- child.preOrder(visitor);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DistinctGroupbyNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DistinctGroupbyNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DistinctGroupbyNode.java
deleted file mode 100644
index 47e8933..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DistinctGroupbyNode.java
+++ /dev/null
@@ -1,253 +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.logical;
-
-import com.google.gson.annotations.Expose;
-import org.apache.tajo.catalog.Column;
-import org.apache.tajo.engine.eval.AggregationFunctionCallEval;
-import org.apache.tajo.engine.planner.PlanString;
-import org.apache.tajo.engine.planner.PlannerUtil;
-import org.apache.tajo.engine.planner.Target;
-import org.apache.tajo.util.TUtil;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class DistinctGroupbyNode extends UnaryNode implements Projectable, Cloneable {
- @Expose
- private GroupbyNode groupbyPlan;
-
- @Expose
- private List<GroupbyNode> groupByNodes;
-
- @Expose
- private Target[] targets;
-
- @Expose
- private Column[] groupingColumns;
-
- @Expose
- private int[] resultColumnIds;
-
- /** Aggregation Functions */
- @Expose private AggregationFunctionCallEval [] aggrFunctions;
-
- public DistinctGroupbyNode(int pid) {
- super(pid, NodeType.DISTINCT_GROUP_BY);
- }
-
- @Override
- public boolean hasTargets() {
- return targets != null && targets.length > 0;
- }
-
- @Override
- public void setTargets(Target[] targets) {
- this.targets = targets;
- setOutSchema(PlannerUtil.targetToSchema(targets));
- }
-
- @Override
- public Target[] getTargets() {
- if (hasTargets()) {
- return targets;
- } else {
- return new Target[0];
- }
- }
-
- public void setGroupbyNodes(List<GroupbyNode> groupByNodes) {
- this.groupByNodes = groupByNodes;
- }
-
- public List<GroupbyNode> getGroupByNodes() {
- return groupByNodes;
- }
-
- public final Column[] getGroupingColumns() {
- return groupingColumns;
- }
-
- public final void setGroupColumns(Column[] groupingColumns) {
- this.groupingColumns = groupingColumns;
- }
-
- public int[] getResultColumnIds() {
- return resultColumnIds;
- }
-
- public void setResultColumnIds(int[] resultColumnIds) {
- this.resultColumnIds = resultColumnIds;
- }
-
- public AggregationFunctionCallEval [] getAggFunctions() {
- return this.aggrFunctions;
- }
-
- public void setAggFunctions(AggregationFunctionCallEval[] evals) {
- this.aggrFunctions = evals;
- }
-
- public void setGroupbyPlan(GroupbyNode groupbyPlan) { this.groupbyPlan = groupbyPlan; }
-
- public GroupbyNode getGroupbyPlan() { return this.groupbyPlan; }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- DistinctGroupbyNode cloneNode = (DistinctGroupbyNode)super.clone();
-
- if (groupingColumns != null) {
- cloneNode.groupingColumns = new Column[groupingColumns.length];
- for (int i = 0; i < groupingColumns.length; i++) {
- cloneNode.groupingColumns[i] = groupingColumns[i];
- }
- }
-
- if (groupByNodes != null) {
- cloneNode.groupByNodes = new ArrayList<GroupbyNode>();
- for (GroupbyNode eachNode: groupByNodes) {
- GroupbyNode groupbyNode = (GroupbyNode)eachNode.clone();
- groupbyNode.setPID(-1);
- cloneNode.groupByNodes.add(groupbyNode);
- }
- }
-
- if (targets != null) {
- cloneNode.targets = new Target[targets.length];
- for (int i = 0; i < targets.length; i++) {
- cloneNode.targets[i] = (Target) targets[i].clone();
- }
- }
-
- if (groupbyPlan != null) {
- cloneNode.groupbyPlan = (GroupbyNode)groupbyPlan.clone();
- }
- return cloneNode;
- }
-
- public final boolean isEmptyGrouping() {
- return groupingColumns == null || groupingColumns.length == 0;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder("Distinct GroupBy (");
- if (groupingColumns != null || groupingColumns.length > 0) {
- sb.append("grouping set=").append(TUtil.arrayToString(groupingColumns));
- sb.append(", ");
- }
- for (GroupbyNode eachNode: groupByNodes) {
- sb.append(", groupbyNode=").append(eachNode.toString());
- }
- sb.append(")");
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof DistinctGroupbyNode) {
- DistinctGroupbyNode other = (DistinctGroupbyNode) obj;
- boolean eq = super.equals(other);
- eq = eq && TUtil.checkEquals(groupingColumns, other.groupingColumns);
- eq = eq && TUtil.checkEquals(groupByNodes, other.groupByNodes);
- eq = eq && TUtil.checkEquals(targets, other.targets);
- return eq;
- } else {
- return false;
- }
- }
-
- @Override
- public PlanString getPlanString() {
- PlanString planStr = new PlanString(this);
-
- StringBuilder sb = new StringBuilder();
- sb.append("(");
- Column [] groupingColumns = this.groupingColumns;
- for (int j = 0; j < groupingColumns.length; j++) {
- sb.append(groupingColumns[j].getSimpleName());
- if(j < groupingColumns.length - 1) {
- sb.append(",");
- }
- }
-
- sb.append(")");
-
- planStr.appendTitle(sb.toString());
-
- sb = new StringBuilder();
- sb.append("(");
-
- String prefix = "";
- for (GroupbyNode eachNode: groupByNodes) {
- if (eachNode.hasAggFunctions()) {
- AggregationFunctionCallEval[] aggrFunctions = eachNode.getAggFunctions();
- for (int j = 0; j < aggrFunctions.length; j++) {
- sb.append(prefix).append(aggrFunctions[j]);
- prefix = ",";
- }
- }
- }
- sb.append(")");
- planStr.appendExplain("exprs: ").appendExplain(sb.toString());
-
- sb = new StringBuilder("target list: ");
- for (int i = 0; i < targets.length; i++) {
- sb.append(targets[i]);
- if( i < targets.length - 1) {
- sb.append(", ");
- }
- }
- planStr.addExplan(sb.toString());
-
- planStr.addDetail("out schema:").appendDetail(getOutSchema().toString());
- planStr.addDetail("in schema:").appendDetail(getInSchema().toString());
-
- for (GroupbyNode eachNode: groupByNodes) {
- planStr.addDetail("\t").appendDetail("distinct: " + eachNode.isDistinct())
- .appendDetail(", " + eachNode.getShortPlanString());
- }
-
- return planStr;
- }
-
- public Column[] getFirstStageShuffleKeyColumns() {
- List<Column> shuffleKeyColumns = new ArrayList<Column>();
- shuffleKeyColumns.add(getOutSchema().getColumn(0)); //distinctseq column
- if (groupingColumns != null) {
- for (Column eachColumn: groupingColumns) {
- if (!shuffleKeyColumns.contains(eachColumn)) {
- shuffleKeyColumns.add(eachColumn);
- }
- }
- }
- for (GroupbyNode eachGroupbyNode: groupByNodes) {
- if (eachGroupbyNode.getGroupingColumns() != null && eachGroupbyNode.getGroupingColumns().length > 0) {
- for (Column eachColumn: eachGroupbyNode.getGroupingColumns()) {
- if (!shuffleKeyColumns.contains(eachColumn)) {
- shuffleKeyColumns.add(eachColumn);
- }
- }
- }
- }
-
- return shuffleKeyColumns.toArray(new Column[]{});
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DropDatabaseNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DropDatabaseNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DropDatabaseNode.java
deleted file mode 100644
index 1578759..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DropDatabaseNode.java
+++ /dev/null
@@ -1,85 +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.logical;
-
-import com.google.common.base.Objects;
-import com.google.gson.annotations.Expose;
-import org.apache.tajo.engine.planner.PlanString;
-
-public class DropDatabaseNode extends LogicalNode implements Cloneable {
- @Expose private String databaseName;
- @Expose private boolean ifExists;
-
- public DropDatabaseNode(int pid) {
- super(pid, NodeType.DROP_DATABASE);
- }
-
- public void init(String databaseName, boolean ifExists) {
- this.databaseName = databaseName;
- this.ifExists = ifExists;
- }
-
- public String getDatabaseName() {
- return this.databaseName;
- }
-
- public boolean isIfExists() {
- return ifExists;
- }
-
- @Override
- public PlanString getPlanString() {
- return new PlanString(this).appendTitle(ifExists ? " IF EXISTS " : " ").appendTitle(databaseName);
- }
-
- public int hashCode() {
- return Objects.hashCode(databaseName, ifExists);
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof DropDatabaseNode) {
- DropDatabaseNode other = (DropDatabaseNode) obj;
- return super.equals(other) && this.databaseName.equals(other.databaseName) && ifExists == other.ifExists;
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- DropDatabaseNode dropTableNode = (DropDatabaseNode) super.clone();
- dropTableNode.databaseName = databaseName;
- return dropTableNode;
- }
-
- @Override
- public String toString() {
- return "DROP DATABASE " + (ifExists ? "IF EXISTS ":"") + databaseName;
- }
-
- @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/logical/DropTableNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DropTableNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DropTableNode.java
deleted file mode 100644
index ac68a9c..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/DropTableNode.java
+++ /dev/null
@@ -1,95 +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.logical;
-
-import com.google.common.base.Objects;
-import org.apache.tajo.engine.planner.PlanString;
-
-public class DropTableNode extends LogicalNode implements Cloneable {
- private String tableName;
- private boolean ifExists;
- private boolean purge;
-
- public DropTableNode(int pid) {
- super(pid, NodeType.DROP_TABLE);
- }
-
- public void init(String tableName, boolean ifExists, boolean purge) {
- this.tableName = tableName;
- this.ifExists = ifExists;
- this.purge = purge;
- }
-
- public String getTableName() {
- return this.tableName;
- }
-
- public boolean isIfExists() {
- return this.ifExists;
- }
-
- public boolean isPurge() {
- return this.purge;
- }
-
- @Override
- public PlanString getPlanString() {
- return new PlanString(this).appendTitle(ifExists ? " IF EXISTS" : "").appendTitle(purge ? " PURGE" : "");
- }
-
- public int hashCode() {
- return Objects.hashCode(tableName, ifExists, purge);
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof DropTableNode) {
- DropTableNode other = (DropTableNode) obj;
- return super.equals(other) &&
- this.tableName.equals(other.tableName) &&
- this.ifExists == other.ifExists &&
- this.purge == other.purge;
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- DropTableNode dropTableNode = (DropTableNode) super.clone();
- dropTableNode.tableName = tableName;
- dropTableNode.ifExists = ifExists;
- dropTableNode.purge = purge;
- return dropTableNode;
- }
-
- @Override
- public String toString() {
- return "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + tableName + (purge ? " PURGE" : "");
- }
-
- @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/logical/EvalExprNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/EvalExprNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/EvalExprNode.java
deleted file mode 100644
index 45ab611..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/EvalExprNode.java
+++ /dev/null
@@ -1,85 +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.logical;
-
-import com.google.gson.annotations.Expose;
-import org.apache.tajo.engine.planner.PlanString;
-import org.apache.tajo.engine.planner.PlannerUtil;
-import org.apache.tajo.engine.planner.Target;
-import org.apache.tajo.util.TUtil;
-
-public class EvalExprNode extends LogicalNode implements Projectable {
- @Expose private Target[] exprs;
-
- public EvalExprNode(int pid) {
- super(pid, NodeType.EXPRS);
- }
-
- @Override
- public boolean hasTargets() {
- return true;
- }
-
- @Override
- public void setTargets(Target[] targets) {
- this.exprs = targets;
- setOutSchema(PlannerUtil.targetToSchema(targets));
- }
-
- @Override
- public Target[] getTargets() {
- return exprs;
- }
-
- public Target[] getExprs() {
- return this.exprs;
- }
-
- @Override
- public String toString() {
- return "EvalExprNode (" + TUtil.arrayToString(exprs) + ")";
- }
-
- public boolean equals(Object object) {
- if (object instanceof EvalExprNode) {
- EvalExprNode other = (EvalExprNode) object;
- return TUtil.checkEquals(this.exprs, other.exprs);
- } else {
- return false;
- }
- }
-
- @Override
- public void preOrder(LogicalNodeVisitor visitor) {
- // nothing
- }
-
- @Override
- public void postOrder(LogicalNodeVisitor visitor) {
- // nothing
- }
-
- @Override
- public PlanString getPlanString() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/b143f991/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/ExceptNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/ExceptNode.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/ExceptNode.java
deleted file mode 100644
index 1540e1c..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/logical/ExceptNode.java
+++ /dev/null
@@ -1,45 +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.logical;
-
-import org.apache.tajo.engine.planner.PlanString;
-
-public class ExceptNode extends BinaryNode {
-
- public ExceptNode(int pid) {
- super(pid, NodeType.EXCEPT);
- }
-
- public void init(LogicalNode left, LogicalNode right) {
- setLeftChild(left);
- setRightChild(right);
- }
-
- @Override
- public PlanString getPlanString() {
- PlanString planStr = new PlanString(this);
- planStr.appendTitle(" (L - " + ((TableSubQueryNode)getLeftChild()).getTableName());
- planStr.appendTitle(", R - " + ((TableSubQueryNode)getRightChild()).getTableName());
- planStr.appendTitle(")");
- return planStr;
- }
-}