Examples of PlanNode


Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

          recordDebug("cannot push having, since having is not supported by source", parentNode, record); //$NON-NLS-1$
          return false;
        }
       
        //don't push criteria into an invalid location above an ordered limit - shouldn't happen
        PlanNode limitNode = NodeEditor.findNodePreOrder(accessNode, NodeConstants.Types.TUPLE_LIMIT, NodeConstants.Types.SOURCE);
        if (limitNode != null && FrameUtil.isOrderedLimit(limitNode)) {
          return false;
        }
       
        Criteria crit = (Criteria) parentNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

   
    static PlanNode performRaise(PlanNode rootNode, PlanNode accessNode, PlanNode parentNode) {
      accessNode.removeProperty(NodeConstants.Info.EST_CARDINALITY);
        NodeEditor.removeChildNode(parentNode, accessNode);
        parentNode.addAsParent(accessNode);
        PlanNode grandparentNode = accessNode.getParent();
        if(grandparentNode != null) {
            return rootNode;
        }
        return accessNode;
    }
View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

            return null;
        }
       
        //if I'm on the inner side of an outer join, then and we have a criteria restriction, then I can't be pushed
    if (type.isOuter() && CapabilitiesUtil.getSupportedJoinCriteria(modelId, metadata, capFinder) != SupportedJoinCriteria.ANY) {
      PlanNode critNode = NodeEditor.findNodePreOrder(joinNode.getLastChild(), NodeConstants.Types.SELECT, NodeConstants.Types.SOURCE);
      if (critNode != null) {
        return null;
      }
      if (type == JoinType.JOIN_FULL_OUTER) {
        critNode = NodeEditor.findNodePreOrder(joinNode.getFirstChild(), NodeConstants.Types.SELECT, NodeConstants.Types.SOURCE);
View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

    }
    return false;
  }
   
    static PlanNode raiseAccessOverJoin(PlanNode joinNode, Object modelID, boolean insert) {
    PlanNode leftAccess = joinNode.getFirstChild();
    PlanNode rightAccess = joinNode.getLastChild();

    // Remove old access nodes - this will automatically add children of access nodes to join node
    NodeEditor.removeChildNode(joinNode, leftAccess);
    NodeEditor.removeChildNode(joinNode, rightAccess);
       
        //Set for later possible use, even though this isn't an access node
        joinNode.setProperty(NodeConstants.Info.MODEL_ID, modelID);

    // Insert new access node above join node
    PlanNode newAccess = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
    newAccess.setProperty(NodeConstants.Info.MODEL_ID, modelID);
    newAccess.addGroups(rightAccess.getGroups());
    newAccess.addGroups(leftAccess.getGroups());
       
        // Combine hints if necessary
        Object leftHint = leftAccess.getProperty(NodeConstants.Info.MAKE_DEP);
        if(leftHint != null) {
            newAccess.setProperty(NodeConstants.Info.MAKE_DEP, leftHint);
        } else {
            Object rightHint = rightAccess.getProperty(NodeConstants.Info.MAKE_DEP);
            if(rightHint != null) {
                newAccess.setProperty(NodeConstants.Info.MAKE_DEP, rightHint);
            }   
        }
        RulePlaceAccess.copyDependentHints(leftAccess, newAccess);
        RulePlaceAccess.copyDependentHints(rightAccess, newAccess);
        RulePlaceAccess.copyDependentHints(joinNode, newAccess);
       
        if (insert) {
            joinNode.addAsParent(newAccess);
        } else {
            newAccess.addFirstChild(joinNode);
        }
       
        return newAccess;
  }
View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

     * @param foundNodes Roots of criteria chains
     */
     void findCriteriaChains(PlanNode root, List<PlanNode> foundNodes, AnalysisRecord analysisRecord)
        throws QueryPlannerException, TeiidComponentException {

        PlanNode recurseRoot = root;
        if(root.getType() == NodeConstants.Types.SELECT) {
         
            // Walk to end of the chain and change recurse root
            while(recurseRoot.getType() == NodeConstants.Types.SELECT) {
              // Look for opportunities to replace with a semi-join
              recurseRoot = planMergeJoin(recurseRoot, root, analysisRecord);
              if (root.getChildCount() == 0) {
                root = recurseRoot.getFirstChild();
                if (root.getType() != NodeConstants.Types.SELECT) {
                  root = root.getParent();
                }
              }
              recurseRoot = recurseRoot.getFirstChild();
            }

            // Ignore trivial 1-node case
            if(recurseRoot.getParent() != root) {
                // Found root for chain
                foundNodes.add(root);
            }
        }
       
        if (recurseRoot.getType() != NodeConstants.Types.ACCESS) {
            for (PlanNode child : recurseRoot.getChildren()) {
                findCriteriaChains(child, foundNodes, analysisRecord);
            }
        }
    }
View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

    static void mergeChain(PlanNode chainRoot, QueryMetadataInterface metadata) {
        // Remove all of chain except root, collect crit from each
        CompoundCriteria critParts = new CompoundCriteria();
        LinkedList<Criteria> subqueryCriteria = new LinkedList<Criteria>();
        PlanNode current = chainRoot;
        boolean isDependentSet = false;
        while(current.getType() == NodeConstants.Types.SELECT) {
          if (!current.getCorrelatedReferenceElements().isEmpty()) {
            //add at the end for delayed evaluation
            subqueryCriteria.add(0, (Criteria)current.getProperty(NodeConstants.Info.SELECT_CRITERIA));
          } else {
            critParts.getCriteria().add(0, (Criteria)current.getProperty(NodeConstants.Info.SELECT_CRITERIA))
          }
           
            isDependentSet |= current.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET);
           
            // Recurse
            PlanNode last = current;
            current = current.getLastChild();

            // Remove current
            if(last != chainRoot) {
                NodeEditor.removeChildNode(last.getParent(), last);
            }
        }
        critParts.getCriteria().addAll(subqueryCriteria);
        Criteria combinedCrit = QueryRewriter.optimizeCriteria(critParts, metadata);
View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

            }
                return current;
              }
      }
           
            PlanNode semiJoin = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
            semiJoin.addGroups(current.getGroups());
            semiJoin.setProperty(NodeConstants.Info.JOIN_STRATEGY, JoinStrategyType.MERGE);
            semiJoin.setProperty(NodeConstants.Info.JOIN_TYPE, plannedResult.not?JoinType.JOIN_ANTI_SEMI:JoinType.JOIN_SEMI);
            semiJoin.setProperty(NodeConstants.Info.NON_EQUI_JOIN_CRITERIA, plannedResult.nonEquiJoinCriteria);
           
            semiJoin.setProperty(NodeConstants.Info.LEFT_EXPRESSIONS, plannedResult.leftExpressions);
            semiJoin.setProperty(NodeConstants.Info.RIGHT_EXPRESSIONS, plannedResult.rightExpressions);
            semiJoin.setProperty(NodeConstants.Info.SORT_RIGHT, SortOption.ALREADY_SORTED);
            semiJoin.setProperty(NodeConstants.Info.OUTPUT_COLS, root.getProperty(NodeConstants.Info.OUTPUT_COLS));
           
            List childOutput = (List)current.getFirstChild().getProperty(NodeConstants.Info.OUTPUT_COLS);
            PlanNode toCorrect = root;
            while (toCorrect != current) {
              toCorrect.setProperty(NodeConstants.Info.OUTPUT_COLS, childOutput);
              toCorrect = toCorrect.getFirstChild();
            }
           
            PlanNode node = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
            node.setProperty(NodeConstants.Info.PROCESSOR_PLAN, subPlan);
            node.setProperty(NodeConstants.Info.OUTPUT_COLS, projectedSymbols);
            node.setProperty(NodeConstants.Info.EST_CARDINALITY, planCardinality);
            root.addAsParent(semiJoin);
            semiJoin.addLastChild(node);
            PlanNode result = current.getParent();
            NodeEditor.removeChildNode(result, current);
            RuleImplementJoinStrategy.insertSort(semiJoin.getFirstChild(), (List<SingleElementSymbol>) plannedResult.leftExpressions, semiJoin, metadata, capFinder, true);
            return result;
    } catch (QueryPlannerException e) {
      //can't be done - probably access patterns - what about dependent
View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

                treeChanged = true;
            }
            
            if (removeCopiedFlag) {
                //allow the criteria above the join to be eligible for pushing and copying
                PlanNode parent = node.getParent();
                while (parent != null && parent.getType() == NodeConstants.Types.SELECT) {
                    parent.setProperty(NodeConstants.Info.IS_COPIED, Boolean.FALSE);
                    parent = parent.getParent();
                }
            }           
        }
       
        if (treeChanged) {
View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

     * @param tgtCrit
     * @return
     */
    private boolean pushCriteria(PlanNode joinNode,
                                  Criteria tgtCrit) {
        PlanNode newCritNode = RelationalPlanner.createSelectNode(tgtCrit, false);
       
        Set<GroupSymbol> groups = newCritNode.getGroups();
       
        PlanNode[] innerJoinNodes = JoinUtil.getInnerSideJoinNodes(joinNode);

        boolean pushed = false;

View Full Code Here

Examples of org.teiid.query.optimizer.relational.plantree.PlanNode

     */
  public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
    throws QueryPlannerException, QueryMetadataException, TeiidComponentException {

    // Record project node output columns in top node
    PlanNode projectNode = NodeEditor.findNodePreOrder(plan, NodeConstants.Types.PROJECT);

        if(projectNode == null) {
            return plan;
        }

    List<SingleElementSymbol> projectCols = (List<SingleElementSymbol>)projectNode.getProperty(NodeConstants.Info.PROJECT_COLS);

    assignOutputElements(plan, projectCols, metadata, capFinder, rules, analysisRecord, context);

    return plan;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.