private boolean canPushToBranches(PlanNode limitNode, PlanNode child) { if (!limitNode.hasProperty(Info.MAX_TUPLE_LIMIT)) { return false; } if (!SetQuery.Operation.UNION.equals(child.getProperty(NodeConstants.Info.SET_OPERATION))) { return false; } if (!child.hasBooleanProperty(NodeConstants.Info.USE_ALL) && !limitNode.hasBooleanProperty(Info.IS_NON_STRICT)) { return false; } return true; }
private boolean canPushToBranches(PlanNode limitNode, PlanNode child) { if (!limitNode.hasProperty(Info.MAX_TUPLE_LIMIT)) { return false; } if (!SetQuery.Operation.UNION.equals(child.getProperty(NodeConstants.Info.SET_OPERATION))) { return false; } if (!child.hasBooleanProperty(NodeConstants.Info.USE_ALL) && !limitNode.hasBooleanProperty(Info.IS_NON_STRICT)) { return false; } return true; }
private boolean canPushToBranches(PlanNode limitNode, PlanNode child) { if (!limitNode.hasProperty(Info.MAX_TUPLE_LIMIT)) { return false; } if (!SetQuery.Operation.UNION.equals(child.getProperty(NodeConstants.Info.SET_OPERATION))) { return false; } if (!child.hasBooleanProperty(NodeConstants.Info.USE_ALL) && !limitNode.hasBooleanProperty(Info.IS_NON_STRICT)) { return false; } return true; }
private void visitSelectNode(PlanNode node, Set<Criteria> toCopy, Set<Criteria> allCriteria) { //First examine criteria in critNode for suitability Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA); if(node.getGroups().size() == 1) { List<Criteria> crits = Criteria.separateCriteriaByAnd(crit); if(!node.hasBooleanProperty(NodeConstants.Info.IS_HAVING) && node.getSubqueryContainers().isEmpty()) { if (!node.hasBooleanProperty(NodeConstants.Info.IS_COPIED)) { toCopy.addAll(crits); } allCriteria.addAll(crits); } } }
private void visitSelectNode(PlanNode node, Set<Criteria> toCopy, Set<Criteria> allCriteria) { //First examine criteria in critNode for suitability Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA); if(node.getGroups().size() == 1) { List<Criteria> crits = Criteria.separateCriteriaByAnd(crit); if(!node.hasBooleanProperty(NodeConstants.Info.IS_HAVING) && node.getSubqueryContainers().isEmpty()) { if (!node.hasBooleanProperty(NodeConstants.Info.IS_COPIED)) { toCopy.addAll(crits); } allCriteria.addAll(crits); } } }
private void visitSelectNode(PlanNode node, Set<Criteria> toCopy, Set<Criteria> allCriteria) { //First examine criteria in critNode for suitability Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA); if(node.getGroups().size() == 1) { List<Criteria> crits = Criteria.separateCriteriaByAnd(crit); if(!node.hasBooleanProperty(NodeConstants.Info.IS_HAVING) && node.getSubqueryContainers().isEmpty()) { if (!node.hasBooleanProperty(NodeConstants.Info.IS_COPIED)) { toCopy.addAll(crits); } allCriteria.addAll(crits); } } }
private boolean isDependentFinalDestination(PlanNode critNode, PlanNode currentNode) { return critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET) && NodeEditor.findNodePreOrder(currentNode.getFirstChild(), NodeConstants.Types.GROUP, NodeConstants.Types.SOURCE) == null; }
private static PlanNode newLimit(PlanNode limitNode) { PlanNode newLimit = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); if (limitNode.hasBooleanProperty(Info.IS_NON_STRICT)) { newLimit.setProperty(Info.IS_NON_STRICT, Boolean.TRUE); } return newLimit; }
private boolean isDependentFinalDestination(PlanNode critNode, PlanNode currentNode) { return critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET) && NodeEditor.findNodePreOrder(currentNode.getFirstChild(), NodeConstants.Types.GROUP, NodeConstants.Types.SOURCE) == null; }
private static PlanNode newLimit(PlanNode limitNode) { PlanNode newLimit = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); if (limitNode.hasBooleanProperty(Info.IS_NON_STRICT)) { newLimit.setProperty(Info.IS_NON_STRICT, Boolean.TRUE); } return newLimit; }
private boolean isDependentFinalDestination(PlanNode critNode, PlanNode currentNode) { return critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET) && NodeEditor.findNodePreOrder(currentNode.getFirstChild(), NodeConstants.Types.GROUP, NodeConstants.Types.SOURCE) == null; }
private static PlanNode newLimit(PlanNode limitNode) { PlanNode newLimit = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); if (limitNode.hasBooleanProperty(Info.IS_NON_STRICT)) { newLimit.setProperty(Info.IS_NON_STRICT, Boolean.TRUE); } return newLimit; }
public static boolean isOrderedOrStrictLimit(PlanNode node) { return node.getType() == NodeConstants.Types.TUPLE_LIMIT && (NodeEditor.findNodePreOrder(node, NodeConstants.Types.SORT, NodeConstants.Types.PROJECT | NodeConstants.Types.SET_OP) != null || !node.hasBooleanProperty(Info.IS_NON_STRICT)); }
public static boolean isOrderedOrStrictLimit(PlanNode node) { return node.getType() == NodeConstants.Types.TUPLE_LIMIT && (NodeEditor.findNodePreOrder(node, NodeConstants.Types.SORT, NodeConstants.Types.PROJECT | NodeConstants.Types.SET_OP) != null || !node.hasBooleanProperty(Info.IS_NON_STRICT)); }
public static boolean isOrderedOrStrictLimit(PlanNode node) { return node.getType() == NodeConstants.Types.TUPLE_LIMIT && (NodeEditor.findNodePreOrder(node, NodeConstants.Types.SORT, NodeConstants.Types.PROJECT | NodeConstants.Types.SET_OP) != null || !node.hasBooleanProperty(Info.IS_NON_STRICT)); }
private static void estimateSetOpCost(PlanNode node, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { float cost = 0; SetQuery.Operation op = (SetQuery.Operation)node.getProperty(NodeConstants.Info.SET_OPERATION); float leftCost = (Float)node.getFirstChild().getProperty(NodeConstants.Info.EST_CARDINALITY); float rightCost = (Float)node.getLastChild().getProperty(NodeConstants.Info.EST_CARDINALITY); if (!node.hasBooleanProperty(NodeConstants.Info.USE_ALL)) { leftCost = getDistinctEstimate(node.getFirstChild(), metadata, leftCost); rightCost = getDistinctEstimate(node.getLastChild(), metadata, rightCost); } cost = getCombinedSetEstimate(op, leftCost, rightCost, !node.hasBooleanProperty(NodeConstants.Info.USE_ALL)); setCardinalityEstimate(node, new Float(cost), true, metadata); }
private static void estimateSetOpCost(PlanNode node, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { float cost = 0; SetQuery.Operation op = (SetQuery.Operation)node.getProperty(NodeConstants.Info.SET_OPERATION); float leftCost = (Float)node.getFirstChild().getProperty(NodeConstants.Info.EST_CARDINALITY); float rightCost = (Float)node.getLastChild().getProperty(NodeConstants.Info.EST_CARDINALITY); if (!node.hasBooleanProperty(NodeConstants.Info.USE_ALL)) { leftCost = getDistinctEstimate(node.getFirstChild(), metadata, leftCost); rightCost = getDistinctEstimate(node.getLastChild(), metadata, rightCost); } cost = getCombinedSetEstimate(op, leftCost, rightCost, !node.hasBooleanProperty(NodeConstants.Info.USE_ALL)); setCardinalityEstimate(node, new Float(cost), true, metadata); }
private static void estimateSetOpCost(PlanNode node, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { float cost = 0; SetQuery.Operation op = (SetQuery.Operation)node.getProperty(NodeConstants.Info.SET_OPERATION); float leftCost = (Float)node.getFirstChild().getProperty(NodeConstants.Info.EST_CARDINALITY); float rightCost = (Float)node.getLastChild().getProperty(NodeConstants.Info.EST_CARDINALITY); if (!node.hasBooleanProperty(NodeConstants.Info.USE_ALL)) { leftCost = getDistinctEstimate(node.getFirstChild(), metadata, leftCost); rightCost = getDistinctEstimate(node.getLastChild(), metadata, rightCost); } cost = getCombinedSetEstimate(op, leftCost, rightCost, !node.hasBooleanProperty(NodeConstants.Info.USE_ALL)); setCardinalityEstimate(node, new Float(cost), true, metadata); }
private PlanNode removeUnnecessaryInlineView(PlanNode root, PlanNode accessNode) { PlanNode child = accessNode.getFirstChild(); if (child.hasBooleanProperty(NodeConstants.Info.INLINE_VIEW)) { child.removeProperty(NodeConstants.Info.INLINE_VIEW); root = RuleRaiseAccess.performRaise(root, child, accessNode); //add the groups from the lower project accessNode.getGroups().clear(); PlanNode sourceNode = FrameUtil.findJoinSourceNode(accessNode.getFirstChild()); if (sourceNode != null) { accessNode.addGroups(sourceNode.getGroups()); } accessNode.setProperty(Info.OUTPUT_COLS, accessNode.getFirstChild().getProperty(Info.OUTPUT_COLS)); } return root; }
private void processLimit(PlanNode node, QueryCommand query, QueryMetadataInterface metadata) { Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); Expression childLimit = null; Expression childOffset = null; if (query.getLimit() != null) { childLimit = query.getLimit().getRowLimit(); childOffset = query.getLimit().getOffset(); } RulePushLimit.combineLimits(limitNode, metadata, limit, offset, childLimit, childOffset); Limit lim = new Limit((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)); lim.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT) && (query.getLimit() == null || query.getLimit().isImplicit())); query.setLimit(lim); }