Search in sources :

Example 6 with AccessPattern

use of org.teiid.query.resolver.util.AccessPattern in project teiid by teiid.

the class FrameUtil method convertAccessPatterns.

/**
 * @param symbolMap
 * @param node
 * @throws QueryPlannerException
 */
private static void convertAccessPatterns(Map symbolMap, PlanNode node) throws QueryPlannerException {
    List<AccessPattern> accessPatterns = (List<AccessPattern>) node.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
    if (accessPatterns != null) {
        for (AccessPattern ap : accessPatterns) {
            Set<ElementSymbol> newElements = new HashSet<ElementSymbol>();
            for (Iterator<ElementSymbol> elems = ap.getUnsatisfied().iterator(); elems.hasNext(); ) {
                ElementSymbol symbol = elems.next();
                Expression mapped = convertExpression(symbol, symbolMap);
                newElements.addAll(ElementCollectorVisitor.getElements(mapped, true));
            }
            ap.setUnsatisfied(newElements);
            Set<ElementSymbol> newHistory = new HashSet<ElementSymbol>();
            for (Iterator<ElementSymbol> elems = ap.getCurrentElements().iterator(); elems.hasNext(); ) {
                ElementSymbol symbol = elems.next();
                Expression mapped = convertExpression(symbol, symbolMap);
                newHistory.addAll(ElementCollectorVisitor.getElements(mapped, true));
            }
            ap.addElementHistory(newHistory);
        }
        Collections.sort(accessPatterns);
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) AccessPattern(org.teiid.query.resolver.util.AccessPattern) Expression(org.teiid.query.sql.symbol.Expression)

Example 7 with AccessPattern

use of org.teiid.query.resolver.util.AccessPattern in project teiid by teiid.

the class FrameUtil method canConvertAccessPatterns.

static boolean canConvertAccessPatterns(PlanNode sourceNode) {
    List<AccessPattern> accessPatterns = (List) sourceNode.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
    if (accessPatterns == null) {
        return true;
    }
    SymbolMap symbolMap = (SymbolMap) sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
    for (Iterator<AccessPattern> i = accessPatterns.iterator(); i.hasNext(); ) {
        AccessPattern ap = i.next();
        for (Iterator<ElementSymbol> elems = ap.getUnsatisfied().iterator(); elems.hasNext(); ) {
            ElementSymbol symbol = elems.next();
            Expression mapped = convertExpression(symbol, symbolMap.asMap());
            if (ElementCollectorVisitor.getElements(mapped, true).isEmpty()) {
                return false;
            }
        }
    }
    return true;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) AccessPattern(org.teiid.query.resolver.util.AccessPattern) Expression(org.teiid.query.sql.symbol.Expression) SymbolMap(org.teiid.query.sql.util.SymbolMap)

Example 8 with AccessPattern

use of org.teiid.query.resolver.util.AccessPattern in project teiid by teiid.

the class JoinRegion method addJoinSourceNode.

public void addJoinSourceNode(PlanNode sourceNode) {
    PlanNode root = sourceNode;
    while (root.getParent() != null && root.getParent().getType() == NodeConstants.Types.SELECT) {
        root = root.getParent();
    }
    if (sourceNode.hasCollectionProperty(NodeConstants.Info.ACCESS_PATTERNS)) {
        Collection<AccessPattern> aps = (Collection<AccessPattern>) sourceNode.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
        unsatisfiedAccessPatterns.add(aps);
        dependentJoinSourceNodes.put(sourceNode, root);
    } else {
        joinSourceNodes.put(sourceNode, root);
    }
    if (joinRoot == null) {
        joinRoot = root;
    }
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) AccessPattern(org.teiid.query.resolver.util.AccessPattern)

Aggregations

AccessPattern (org.teiid.query.resolver.util.AccessPattern)8 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)4 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)4 Expression (org.teiid.query.sql.symbol.Expression)3 SymbolMap (org.teiid.query.sql.util.SymbolMap)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)2 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)1 RuleStack (org.teiid.query.optimizer.relational.RuleStack)1