public static final PlanNode findNodePreOrder(PlanNode root, int types) { return findNodePreOrder(root, types, NodeConstants.Types.NO_TYPE); }
public static final PlanNode findParent(PlanNode root, int types) { return findParent(root, types, NodeConstants.Types.NO_TYPE); }
private void addInputNode(Reference param) { params.add(param.getExpression()); conjuncts.add(crit); NodeEditor.removeChildNode(currentNode.getParent(), currentNode); }
/** * Finds the closest project columns in the current frame */ static List<Expression> findTopCols(PlanNode node) { PlanNode project = NodeEditor.findNodePreOrder(node, NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE); if (project == null) { project = NodeEditor.findParent(node, NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE); } if (project != null) { return (List<Expression>)project.getProperty(NodeConstants.Info.PROJECT_COLS); } Assertion.failed("no top cols in frame"); //$NON-NLS-1$ return null; }
public List<SymbolMap> getExportedCorrelatedReferences() { if (type != NodeConstants.Types.JOIN) { return Collections.emptyList(); } LinkedList<SymbolMap> result = new LinkedList<SymbolMap>(); for (PlanNode child : NodeEditor.findAllNodes(this, NodeConstants.Types.SOURCE, NodeConstants.Types.ACCESS)) { SymbolMap references = (SymbolMap)child.getProperty(NodeConstants.Info.CORRELATED_REFERENCES); if (references == null) { continue; } Set<GroupSymbol> correlationGroups = GroupsUsedByElementsVisitor.getGroups(references.getValues()); PlanNode joinNode = NodeEditor.findParent(child, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE); while (joinNode != null) { if (joinNode.getGroups().containsAll(correlationGroups)) { if (joinNode == this) { result.add(references); } break; } joinNode = NodeEditor.findParent(joinNode, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE); } } return result; }
private boolean mergeSortWithDupRemoval(PlanNode node) { if (node.getFirstChild() == null) { return false; } switch (node.getFirstChild().getType()) { case NodeConstants.Types.SET_OP: if (node.getFirstChild().getProperty(NodeConstants.Info.SET_OPERATION) == SetQuery.Operation.UNION && !node.getFirstChild().hasBooleanProperty(NodeConstants.Info.USE_ALL)) { node.getFirstChild().setProperty(NodeConstants.Info.USE_ALL, true); return true; } break; case NodeConstants.Types.DUP_REMOVE: NodeEditor.removeChildNode(node, node.getFirstChild()); return true; } if (node.hasBooleanProperty(Info.UNRELATED_SORT)) { PlanNode source = NodeEditor.findNodePreOrder(node, NodeConstants.Types.SOURCE); if (source != null) { PlanNode parentProject = NodeEditor.findParent(source, NodeConstants.Types.PROJECT); if (parentProject != null && parentProject.getProperty(Info.PROJECT_COLS).equals(source.getProperty(Info.OUTPUT_COLS))) { //can't sort on a derived expression return mergeSortWithDupRemoval(source); } } } return false; }
private List<PlanNode> getAllPossibleSubqueryNodes(PlanNode plan) { return NodeEditor.findAllNodes(plan, NodeConstants.Types.PROJECT | NodeConstants.Types.SELECT | NodeConstants.Types.JOIN | NodeConstants.Types.SOURCE | NodeConstants.Types.GROUP | NodeConstants.Types.SORT); }
public static final List<PlanNode> findAllNodes(PlanNode root, int types) { LinkedList<PlanNode> nodes = new LinkedList<PlanNode>(); findAllNodesHelper(root, types, nodes, NodeConstants.Types.NO_TYPE); return nodes; }
private boolean mergeSortWithDupRemoval(PlanNode node) { if (node.getFirstChild() == null) { return false; } switch (node.getFirstChild().getType()) { case NodeConstants.Types.SET_OP: if (node.getFirstChild().getProperty(NodeConstants.Info.SET_OPERATION) == SetQuery.Operation.UNION && !node.getFirstChild().hasBooleanProperty(NodeConstants.Info.USE_ALL)) { node.getFirstChild().setProperty(NodeConstants.Info.USE_ALL, true); return true; } break; case NodeConstants.Types.DUP_REMOVE: NodeEditor.removeChildNode(node, node.getFirstChild()); return true; } if (node.hasBooleanProperty(Info.UNRELATED_SORT)) { PlanNode source = NodeEditor.findNodePreOrder(node, NodeConstants.Types.SOURCE); if (source != null) { PlanNode parentProject = NodeEditor.findParent(source, NodeConstants.Types.PROJECT); if (parentProject != null && parentProject.getProperty(Info.PROJECT_COLS).equals(source.getProperty(Info.OUTPUT_COLS))) { //can't sort on a derived expression return mergeSortWithDupRemoval(source); } } } return false; }
/** * Finds the closest project columns in the current frame */ static List<Expression> findTopCols(PlanNode node) { PlanNode project = NodeEditor.findNodePreOrder(node, NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE); if (project == null) { project = NodeEditor.findParent(node, NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE); } if (project != null) { return (List<Expression>)project.getProperty(NodeConstants.Info.PROJECT_COLS); } Assertion.failed("no top cols in frame"); //$NON-NLS-1$ return null; }
private List<PlanNode> getAllPossibleSubqueryNodes(PlanNode plan) { return NodeEditor.findAllNodes(plan, NodeConstants.Types.PROJECT | NodeConstants.Types.SELECT | NodeConstants.Types.JOIN | NodeConstants.Types.SOURCE | NodeConstants.Types.GROUP | NodeConstants.Types.SORT); }
public List<SymbolMap> getExportedCorrelatedReferences() { if (type != NodeConstants.Types.JOIN) { return Collections.emptyList(); } LinkedList<SymbolMap> result = new LinkedList<SymbolMap>(); for (PlanNode child : NodeEditor.findAllNodes(this, NodeConstants.Types.SOURCE, NodeConstants.Types.ACCESS)) { SymbolMap references = (SymbolMap)child.getProperty(NodeConstants.Info.CORRELATED_REFERENCES); if (references == null) { continue; } Set<GroupSymbol> correlationGroups = GroupsUsedByElementsVisitor.getGroups(references.getValues()); PlanNode joinNode = NodeEditor.findParent(child, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE); while (joinNode != null) { if (joinNode.getGroups().containsAll(correlationGroups)) { if (joinNode == this) { result.add(references); } break; } joinNode = NodeEditor.findParent(joinNode, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE); } } return result; }
public static final List<PlanNode> findAllNodes(PlanNode root, int types) { LinkedList<PlanNode> nodes = new LinkedList<PlanNode>(); findAllNodesHelper(root, types, nodes, NodeConstants.Types.NO_TYPE); return nodes; }
private boolean mergeSortWithDupRemoval(PlanNode node) { if (node.getFirstChild() == null) { return false; } switch (node.getFirstChild().getType()) { case NodeConstants.Types.SET_OP: if (node.getFirstChild().getProperty(NodeConstants.Info.SET_OPERATION) == SetQuery.Operation.UNION && !node.getFirstChild().hasBooleanProperty(NodeConstants.Info.USE_ALL)) { node.getFirstChild().setProperty(NodeConstants.Info.USE_ALL, true); return true; } break; case NodeConstants.Types.DUP_REMOVE: NodeEditor.removeChildNode(node, node.getFirstChild()); return true; } if (node.hasBooleanProperty(Info.UNRELATED_SORT)) { PlanNode source = NodeEditor.findNodePreOrder(node, NodeConstants.Types.SOURCE); if (source != null) { PlanNode parentProject = NodeEditor.findParent(source, NodeConstants.Types.PROJECT); if (parentProject != null && parentProject.getProperty(Info.PROJECT_COLS).equals(source.getProperty(Info.OUTPUT_COLS))) { //can't sort on a derived expression return mergeSortWithDupRemoval(source); } } } return false; }
public static final PlanNode findNodePreOrder(PlanNode root, int types) { return findNodePreOrder(root, types, NodeConstants.Types.NO_TYPE); }
private void addInputNode(Reference param) { params.add(param.getExpression()); conjuncts.add(crit); NodeEditor.removeChildNode(currentNode.getParent(), currentNode); }
public static final PlanNode findParent(PlanNode root, int types) { return findParent(root, types, NodeConstants.Types.NO_TYPE); }
/** * Finds the closest project columns in the current frame */ static List<Expression> findTopCols(PlanNode node) { PlanNode project = NodeEditor.findNodePreOrder(node, NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE); if (project == null) { project = NodeEditor.findParent(node, NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE); } if (project != null) { return (List<Expression>)project.getProperty(NodeConstants.Info.PROJECT_COLS); } Assertion.failed("no top cols in frame"); //$NON-NLS-1$ return null; }
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context) throws QueryMetadataException, TeiidComponentException { for (PlanNode joinNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.JOIN, NodeConstants.Types.ACCESS)) { chooseJoinStrategy(joinNode, metadata); } return plan; }
public List<SymbolMap> getExportedCorrelatedReferences() { if (type != NodeConstants.Types.JOIN) { return Collections.emptyList(); } LinkedList<SymbolMap> result = new LinkedList<SymbolMap>(); for (PlanNode child : NodeEditor.findAllNodes(this, NodeConstants.Types.SOURCE, NodeConstants.Types.ACCESS)) { SymbolMap references = (SymbolMap)child.getProperty(NodeConstants.Info.CORRELATED_REFERENCES); if (references == null) { continue; } Set<GroupSymbol> correlationGroups = GroupsUsedByElementsVisitor.getGroups(references.getValues()); PlanNode joinNode = NodeEditor.findParent(child, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE); while (joinNode != null) { if (joinNode.getGroups().containsAll(correlationGroups)) { if (joinNode == this) { result.add(references); } break; } joinNode = NodeEditor.findParent(joinNode, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE); } } return result; }