Package org.teiid.query.optimizer.relational.plantree

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


    private void findInputNodes(final HashSet inputs,
                               PlanNode critNode,
                               final List conjuncts, final Set params) {
       
        while (critNode.getType() == NodeConstants.Types.SELECT) {
            final PlanNode currentNode = critNode;
           
            final Criteria crit = (Criteria)currentNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
           
            critNode = currentNode.getParent();
           
            if (!currentNode.getGroups().isEmpty()) {
                continue;
            }
           
            LanguageVisitor visitor = new LanguageVisitor() {     
                public void visit(CompareCriteria compCrit){
                    if (compCrit.getOperator() == CompareCriteria.EQ && checkForInput(compCrit.getLeftExpression()) && !checkForAnyInput(compCrit.getRightExpression())) {
                        addInputNode((Reference)compCrit.getLeftExpression());
                    }
                }
               
                private void addInputNode(Reference param) {
                    params.add(param.getExpression());
                    conjuncts.add(crit);
                    NodeEditor.removeChildNode(currentNode.getParent(), currentNode);
                }
               
                public void visit(IsNullCriteria isNull){
                    if (!isNull.isNegated() && checkForInput(isNull.getExpression())) {
                        addInputNode((Reference)isNull.getExpression());
View Full Code Here


                break;
            case NodeConstants.Types.ACCESS:
            case NodeConstants.Types.SORT:
            {
                //Simply record the cost of the only child
                PlanNode child = node.getFirstChild();
                Float childCost = (Float)child.getProperty(NodeConstants.Info.EST_CARDINALITY);
                setCardinalityEstimate(node, childCost, true, metadata);
                break;
            }
            case NodeConstants.Types.NULL:
                setCardinalityEstimate(node, 0f, true, metadata);
                break;

            case NodeConstants.Types.PROJECT:
            {
                Float childCost = null;
                //Simply record the cost of the only child
                if (node.getChildCount() != 0) {
                    PlanNode child = node.getFirstChild();
                    childCost = (Float)child.getProperty(NodeConstants.Info.EST_CARDINALITY);
                } else {
                    childCost = 1f;
                }
                setCardinalityEstimate(node, childCost, true, metadata);
                break;
            }
            case NodeConstants.Types.SET_OP:
            {
                estimateSetOpCost(node, metadata);
                break;
            }
            case NodeConstants.Types.TUPLE_LIMIT:
            {
                PlanNode child = node.getFirstChild();
                float childCost = child.getCardinality();
               
                Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
                Float cost = childCost;
               
                if (childCost != UNKNOWN_VALUE && offset instanceof Constant) {
View Full Code Here

  }

  private static float getDistinctEstimate(PlanNode node,
      QueryMetadataInterface metadata, float cost)
      throws QueryMetadataException, TeiidComponentException {
    PlanNode projectNode = NodeEditor.findNodePreOrder(node, NodeConstants.Types.PROJECT);
    if (projectNode != null) {
      cost = getNDVEstimate(node.getParent(), metadata, cost, (List)projectNode.getProperty(NodeConstants.Info.PROJECT_COLS), false);
    }
    return cost;
  }
View Full Code Here

     */
    private static void estimateJoinNodeCost(PlanNode node, QueryMetadataInterface metadata)
        throws QueryMetadataException, TeiidComponentException {

        Iterator<PlanNode> children = node.getChildren().iterator();
        PlanNode child1 = children.next();
        float childCost1 = child1.getCardinality();
        PlanNode child2 = children.next();
        float childCost2 = child2.getCardinality();
       
        if (childCost1 == UNKNOWN_VALUE || childCost2 == UNKNOWN_VALUE) {
          setCardinalityEstimate(node, null, true, metadata);
          return;
        }
View Full Code Here

     * @param metadata
     */
    private static void estimateSelectNodeCost(PlanNode node, QueryMetadataInterface metadata)
        throws QueryMetadataException, TeiidComponentException {

        PlanNode child = node.getFirstChild();
        float childCost = child.getCardinality();
       
        //Get list of conjuncts
        Criteria selectCriteria = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
        float newCost = recursiveEstimateCostOfCriteria(childCost, node, selectCriteria, metadata);
        setCardinalityEstimate(node, newCost, true, metadata);
View Full Code Here

        float cost = UNKNOWN_VALUE;
        if(node.getChildCount() > 0) {
          SymbolMap references = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
          //only cost non-correlated TODO: a better estimate for correlated
          if (references == null) {
              PlanNode child = node.getFirstChild();
              cost = child.getCardinality();
              SymbolMap symbolMap = (SymbolMap)node.getProperty(NodeConstants.Info.SYMBOL_MAP);
              if (symbolMap != null) {
                ColStats colStats = (ColStats) child.getProperty(Info.EST_COL_STATS);
                if (colStats != null) {
                  List<? extends Expression> outputCols = getOutputCols(node, metadata);
                  ColStats newColStats = new ColStats();
                  for (Expression expr : outputCols) {
                    if (!(expr instanceof ElementSymbol)) {
View Full Code Here

      TeiidComponentException {
    List<Expression> outputCols =(List<Expression>)node.getProperty(Info.OUTPUT_COLS);
    if (outputCols != null) {
      return outputCols;
    }
    PlanNode projectNode = NodeEditor.findNodePreOrder(node,
        NodeConstants.Types.PROJECT | NodeConstants.Types.GROUP
        | NodeConstants.Types.SOURCE | NodeConstants.Types.JOIN
        | NodeConstants.Types.NULL);
    if (projectNode != null) {
      node = projectNode;
View Full Code Here

     * @throws TeiidComponentException
     */
    private static void estimateNodeCost(PlanNode node, List expressions, QueryMetadataInterface metadata)
        throws QueryMetadataException, TeiidComponentException {
       
        PlanNode child = node.getFirstChild();
        float childCost = child.getCardinality();
       
        if(childCost == UNKNOWN_VALUE) {
            setCardinalityEstimate(node, null, true, metadata);
            return;
        }
View Full Code Here

          ColStats colStats = null;
        if (node.getChildCount() == 0) {
          colStats = createColStats(node, metadata, cardinality);
        } else {
          for (int i = branch; i < node.getChildCount(); i++) {
            PlanNode child = node.getChildren().get(i);
            colStats = (ColStats) child.getProperty(Info.EST_COL_STATS);
              if (colStats == null) {
                continue;
              }
          float[] stats = colStats.get(expression);
          if (stats != null) {
View Full Code Here

     *
     */
    public static DependentCostAnalysis computeCostForDepJoin(PlanNode joinNode, boolean leftIndependent, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context)
        throws TeiidComponentException, QueryMetadataException, QueryPlannerException {
       
        PlanNode independentNode = leftIndependent?joinNode.getFirstChild():joinNode.getLastChild();
        PlanNode dependentNode = leftIndependent?joinNode.getLastChild():joinNode.getFirstChild();
       
        List independentExpressions = (List)(leftIndependent?joinNode.getProperty(NodeConstants.Info.LEFT_EXPRESSIONS):joinNode.getProperty(NodeConstants.Info.RIGHT_EXPRESSIONS));
        List dependentExpressions = (List)(leftIndependent?joinNode.getProperty(NodeConstants.Info.RIGHT_EXPRESSIONS):joinNode.getProperty(NodeConstants.Info.LEFT_EXPRESSIONS));
       
        return computeCostForDepJoin(independentNode, dependentNode,
View Full Code Here

TOP

Related Classes of org.teiid.query.optimizer.relational.plantree.PlanNode

Copyright © 2018 www.massapicom. 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.