Repository: tajo Updated Branches: refs/heads/master 254c92394 -> 8ad250eb9
TAJO-1882: Clean up GreedyHeuristicJoinOrderAlgorithm::getCost APIs. Closes #817 Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/8ad250eb Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/8ad250eb Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/8ad250eb Branch: refs/heads/master Commit: 8ad250eb9c81e6dec204bfddfcca85cca2937b54 Parents: 254c923 Author: Jihoon Son <[email protected]> Authored: Tue Nov 10 10:18:28 2015 +0900 Committer: Jihoon Son <[email protected]> Committed: Tue Nov 10 10:18:28 2015 +0900 ---------------------------------------------------------------------- CHANGES | 2 ++ .../GreedyHeuristicJoinOrderAlgorithm.java | 32 ++++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/8ad250eb/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index a40a15a..4f7d303 100644 --- a/CHANGES +++ b/CHANGES @@ -33,6 +33,8 @@ Release 0.12.0 - unreleased BUG FIXES + TAJO-1882: Clean up GreedyHeuristicJoinOrderAlgorithm::getCost APIs. (jihoon) + TAJO-1972: Invalid sort order with NULLS FIRST|LAST. (jihoon) TAJO-1896: Fix the travis test failure. (jinho) http://git-wip-us.apache.org/repos/asf/tajo/blob/8ad250eb/tajo-plan/src/main/java/org/apache/tajo/plan/joinorder/GreedyHeuristicJoinOrderAlgorithm.java ---------------------------------------------------------------------- diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/joinorder/GreedyHeuristicJoinOrderAlgorithm.java b/tajo-plan/src/main/java/org/apache/tajo/plan/joinorder/GreedyHeuristicJoinOrderAlgorithm.java index 79ae314..c158f57 100644 --- a/tajo-plan/src/main/java/org/apache/tajo/plan/joinorder/GreedyHeuristicJoinOrderAlgorithm.java +++ b/tajo-plan/src/main/java/org/apache/tajo/plan/joinorder/GreedyHeuristicJoinOrderAlgorithm.java @@ -237,8 +237,8 @@ public class GreedyHeuristicJoinOrderAlgorithm implements JoinOrderAlgorithm { private static JoinEdge swapLeftAndRightIfNecessary(JoinEdge edge) { if (PlannerUtil.isCommutativeJoinType(edge.getJoinType())) { - double leftCost = getCost(edge.getLeftVertex()); - double rightCost = getCost(edge.getRightVertex()); + double leftCost = getCostOfVertex(edge.getLeftVertex()); + double rightCost = getCostOfVertex(edge.getRightVertex()); if (leftCost < rightCost) { return new JoinEdge(edge.getJoinSpec(), edge.getRightVertex(), edge.getLeftVertex()); } else if (leftCost == rightCost) { @@ -394,18 +394,18 @@ public class GreedyHeuristicJoinOrderAlgorithm implements JoinOrderAlgorithm { break; } // cost = estimated input size * filter factor * (output tuple width / input tuple width) - cost = getCost(joinEdge.getLeftVertex()) * - getCost(joinEdge.getRightVertex()) * factor; + cost = getCostOfVertex(joinEdge.getLeftVertex()) * + getCostOfVertex(joinEdge.getRightVertex()) * factor; } else { // make cost bigger if cross join - cost = Math.pow(getCost(joinEdge.getLeftVertex()) * - getCost(joinEdge.getRightVertex()), 2); + cost = Math.pow(getCostOfVertex(joinEdge.getLeftVertex()) * + getCostOfVertex(joinEdge.getRightVertex()), 2); } return checkInfinity(cost * COMPUTATION_FACTOR); } - public static double getCost(JoinVertex joinVertex) { + public static double getCostOfVertex(JoinVertex joinVertex) { double cost; if (joinVertex instanceof RelationVertex) { cost = getCost(((RelationVertex) joinVertex).getRelationNode()); @@ -438,7 +438,7 @@ public class GreedyHeuristicJoinOrderAlgorithm implements JoinOrderAlgorithm { case PROJECTION: ProjectionNode projectionNode = (ProjectionNode) node; - cost = getCost((LogicalNode) projectionNode.getChild()); + cost = getCost(projectionNode.getChild()); break; case JOIN: @@ -447,17 +447,17 @@ public class GreedyHeuristicJoinOrderAlgorithm implements JoinOrderAlgorithm { if (joinNode.hasJoinQual()) { filterFactor = Math.pow(DEFAULT_SELECTION_FACTOR, AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual()).length); - cost = getCost((LogicalNode)joinNode.getLeftChild()) * - getCost((LogicalNode)joinNode.getRightChild()) * filterFactor; + cost = getCost(joinNode.getLeftChild()) * + getCost(joinNode.getRightChild()) * filterFactor; } else { - cost = Math.pow(getCost((LogicalNode)joinNode.getLeftChild()) * - getCost((LogicalNode)joinNode.getRightChild()), 2); + cost = Math.pow(getCost(joinNode.getLeftChild()) * + getCost(joinNode.getRightChild()), 2); } break; case SELECTION: SelectionNode selectionNode = (SelectionNode) node; - cost = getCost((LogicalNode)selectionNode.getChild()) * + cost = getCost(selectionNode.getChild()) * Math.pow(DEFAULT_SELECTION_FACTOR, AlgebraicUtil.toConjunctiveNormalFormArray(selectionNode.getQual()).length); break; @@ -477,8 +477,8 @@ public class GreedyHeuristicJoinOrderAlgorithm implements JoinOrderAlgorithm { case UNION: UnionNode unionNode = (UnionNode) node; - cost = getCost((LogicalNode)unionNode.getLeftChild()) + - getCost((LogicalNode)unionNode.getRightChild()); + cost = getCost(unionNode.getLeftChild()) + + getCost(unionNode.getRightChild()); break; case EXCEPT: @@ -488,7 +488,7 @@ public class GreedyHeuristicJoinOrderAlgorithm implements JoinOrderAlgorithm { default: // all binary operators (join, union, except, and intersect) are handled in the above cases. // So, we need to handle only unary nodes in default. - cost = getCost((LogicalNode)((UnaryNode) node).getChild()); + cost = getCost(((UnaryNode) node).getChild()); break; }
