Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.DependentSetCriteria


        Float cardinality = null;
       
        for (int i = 0; i < dependentExpressions.size(); i++) {
            Expression depExpr = (Expression) dependentExpressions.get(i);
            Expression indepExpr = (Expression) independentExpressions.get(i);
            DependentSetCriteria crit = new DependentSetCriteria(SymbolMap.getExpression(depExpr), id);
            float ndv = NewCalculateCostUtil.UNKNOWN_VALUE;
            if (dca != null && dca.expectedNdv[i] != null) {
              if (dca.expectedNdv[i] > 4*dca.maxNdv[i]) {
                continue; //not necessary to use
              }
              ndv = dca.expectedNdv[i];
              crit.setMaxNdv(dca.maxNdv[i]);
            } else {
              Collection<ElementSymbol> elems = ElementCollectorVisitor.getElements(indepExpr, true);
              if (cardinality == null) {
                cardinality = NewCalculateCostUtil.computeCostForTree(indNode, metadata);
              }
              ndv = NewCalculateCostUtil.getNDVEstimate(indNode, metadata, cardinality, elems, true);
            }
            crit.setNdv(ndv);
            crit.setValueExpression(indepExpr);
           
            PlanNode selectNode = RelationalPlanner.createSelectNode(crit, false);
           
            selectNode.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);
            result.add(selectNode);
View Full Code Here


                cost = nnv;
            }
           
            isNegatedPredicateCriteria = isNullCriteria.isNegated();
        } else if (predicateCriteria instanceof DependentSetCriteria) {
          DependentSetCriteria dsc = (DependentSetCriteria)predicateCriteria;
         
          if (unknownChildCost) {
                return UNKNOWN_VALUE;
            }
          if (dsc.getNdv() == UNKNOWN_VALUE) {
            return childCost / 3;
          }
         
          cost = childCost * dsc.getNdv() / ndv;
        }

        if (cost == UNKNOWN_VALUE) {
            return UNKNOWN_VALUE;
        }
View Full Code Here

      CapabilitiesFinder capFinder, RulePushSelectCriteria rpsc,
      Expression depExpr, LinkedList<Expression> depExpressions)
      throws QueryPlannerException, TeiidComponentException {
    LinkedList<PlanNode> targets = new LinkedList<PlanNode>();
    LinkedList<PlanNode> critNodes = new LinkedList<PlanNode>();
    critNodes.add(RelationalPlanner.createSelectNode(new DependentSetCriteria(depExpr, null), false));
    LinkedList<PlanNode> initialTargets = new LinkedList<PlanNode>();
    initialTargets.add(dependentNode);
    while (!critNodes.isEmpty()) {
      PlanNode critNode = critNodes.remove();
      PlanNode initial = initialTargets.remove();
      if (critNode.getGroups().isEmpty()) {
        //TODO: we need to project constants up through a plan to avoid this case
        continue;
      }
      PlanNode sourceNode = FrameUtil.findOriginatingNode(initial, critNode.getGroups());
      PlanNode target = sourceNode;
      if (initial != sourceNode) {
        target = rpsc.examinePath(initial, sourceNode, metadata, capFinder);         
      }
      if (target != sourceNode || (sourceNode.getType() == NodeConstants.Types.SOURCE && sourceNode.getChildCount() == 0)) {
        targets.add(target);
        DependentSetCriteria dsc = (DependentSetCriteria)critNode.getProperty(Info.SELECT_CRITERIA);
        depExpressions.add(dsc.getExpression());
        continue;
      }
      if (sourceNode.getType() == NodeConstants.Types.SOURCE) {
        PlanNode child = sourceNode.getFirstChild();
            child = FrameUtil.findOriginatingNode(child, child.getGroups());
            if (child != null && child.getType() == NodeConstants.Types.SET_OP) {
              targets.add(target);
          DependentSetCriteria dsc = (DependentSetCriteria)critNode.getProperty(Info.SELECT_CRITERIA);
          depExpressions.add(dsc.getExpression());
          //TODO: we need better handling for set op situations
          continue;
            }
        if (!rpsc.pushAcrossFrame(sourceNode, critNode, metadata)) {
          targets.add(target);
          DependentSetCriteria dsc = (DependentSetCriteria)critNode.getProperty(Info.SELECT_CRITERIA);
          depExpressions.add(dsc.getExpression());
        }
        List<PlanNode> createdNodes = rpsc.getCreatedNodes();
        for (PlanNode planNode : createdNodes) {
          critNodes.add(planNode);
          initialTargets.add(planNode.getFirstChild());
View Full Code Here

          values.add(eval.evaluate(expr, null));
        }
                state.valueIterator = new CollectionValueIterator(values);
                sources.add(Arrays.asList(state));
            } else if (criteria instanceof DependentSetCriteria) {
              DependentSetCriteria dsc = (DependentSetCriteria)criteria;
                String source = dsc.getContextSymbol();
               
                SetState state = new SetState();
                setStates.put(i, state);
                state.valueExpression = dsc.getValueExpression();
                TupleState ts = dependentState.get(source);
                if (ts == null) {
                  ts = new TupleState(source);
                  dependentState.put(source, ts);
                    sources.add(ts.getDepedentSetStates());
                }
                ts.getDepedentSetStates().add(state);
                state.maxNdv = dsc.getMaxNdv();
            }
        }       
    }
View Full Code Here

        super(name);
    }

    private DependentSetCriteria example() {
        ElementSymbol e1 = new ElementSymbol("pm1.g1.e1"); //$NON-NLS-1$
        DependentSetCriteria dsc = new DependentSetCriteria(e1, ""); //$NON-NLS-1$
       
        final ElementSymbol e2 = new ElementSymbol("pm2.g1.e2"); //$NON-NLS-1$
        dsc.setValueExpression(e2);
       
        return dsc;
    }
View Full Code Here

       
        return dsc;
    }
   
    public void testEquivalence() {
        DependentSetCriteria dsc = example();
       
        UnitTestUtil.helpTestEquivalence(0, dsc, dsc);           
        UnitTestUtil.helpTestEquivalence(0, dsc, dsc.clone());           
    }
View Full Code Here

        UnitTestUtil.helpTestEquivalence(0, dsc, dsc);           
        UnitTestUtil.helpTestEquivalence(0, dsc, dsc.clone());           
    }
   
    public void testEquivalence1() {
        DependentSetCriteria dsc = example();
        DependentSetCriteria dsc1 = example();
       
        dsc1.setValueExpression(new ElementSymbol("foo")); //$NON-NLS-1$
       
        assertNotSame(dsc, dsc1);
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.DependentSetCriteria

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.