Package org.teiid.query.mapping.xml

Examples of org.teiid.query.mapping.xml.ResultSetInfo


       
        return env;
    }
   
    private static void setResultInfo(String groupName, Command command) {
        ResultSetInfo rsInfo = new ResultSetInfo(groupName);
        rsInfo.setCommand(command);
        infos.put(groupName, rsInfo);
    }
View Full Code Here


    }
   
   
    static class SourceFixer extends MappingVisitor{
        public void visit(MappingSourceNode sourceNode) {
            ResultSetInfo info = getResultInfo(sourceNode.getResultName());
            Map symbolMap = new HashMap();
            for (Iterator i = info.getCommand().getProjectedSymbols().iterator(); i.hasNext();) {
                ElementSymbol element = (ElementSymbol)i.next();
                symbolMap.put(element, element);
            }
            sourceNode.setSymbolMap(symbolMap);
            sourceNode.setResultSetInfo(info);
View Full Code Here

    private static void planQueryWithCriteria(MappingSourceNode contextNode, XMLPlannerEnvironment planEnv)
        throws QueryPlannerException, TeiidComponentException, QueryMetadataException, QueryResolverException {
       
        Map symbolMap = new HashMap();
       
        ResultSetInfo rsInfo = contextNode.getResultSetInfo();
       
        // this list of all the source nodes below the context, which are directly ro indirectly
        // involved in the criteria
        LinkedHashSet resultSets = new LinkedHashSet();
       
        boolean singleParentage = getResultSets(contextNode, rsInfo.getCriteriaResultSets(), resultSets);
       
        Query contextQuery = null;
       
        if (rsInfo.isCriteriaRaised()) {
            contextQuery = (Query)QueryUtil.getQueryFromQueryNode(rsInfo.getResultSetName(), planEnv);
            String inlineViewName = planEnv.getAliasName(rsInfo.getResultSetName());
            updateSymbolMap(symbolMap, rsInfo.getResultSetName(), inlineViewName, planEnv.getGlobalMetadata());
        } else {
            contextQuery = (Query)rsInfo.getCommand();
        }
       
        Query currentQuery = contextQuery;
       
        for (Iterator i = resultSets.iterator(); i.hasNext();) {
            MappingSourceNode rsNode = (MappingSourceNode)i.next();
           
            ResultSetInfo childRsInfo = rsNode.getResultSetInfo();
           
            QueryNode planNode = QueryUtil.getQueryNode(childRsInfo.getResultSetName(), planEnv.getGlobalMetadata());   
            Command command = QueryUtil.getQuery(childRsInfo.getResultSetName(), planNode, planEnv);
           
            String inlineViewName = planEnv.getAliasName(childRsInfo.getResultSetName());
           
            updateSymbolMap(symbolMap, childRsInfo.getResultSetName(), inlineViewName, planEnv.getGlobalMetadata());
           
            // check if the criteria has been raised, if it is then we can update this as a join.
            if (childRsInfo.isCriteriaRaised()) {
                Query transformationQuery = (Query) command;
                SubqueryFromClause sfc = (SubqueryFromClause)transformationQuery.getFrom().getClauses().get(0);
               
                Criteria joinCriteria = ((Query)childRsInfo.getCommand()).getCriteria();
               
                if (joinCriteria == null) {
                    joinCriteria = QueryRewriter.TRUE_CRITERIA;
                }
               
View Full Code Here

     * @throws QueryResolverException
     */
    static void planStagingTable(String groupName, XMLPlannerEnvironment planEnv)
        throws QueryPlannerException, QueryMetadataException, TeiidComponentException, QueryResolverException {

        ResultSetInfo rsInfo = planEnv.getStagingTableResultsInfo(groupName);
       
        FromClause fromClause = new UnaryFromClause(new GroupSymbol(groupName));
        Query query = QueryUtil.wrapQuery(fromClause, groupName);
        if (rsInfo.getCriteria() != null) {
            query.setCriteria(rsInfo.getCriteria());
        }
        planStagaingQuery(false, groupName, groupName, query, planEnv);
    }
View Full Code Here

        Map tempMetadata = query.getTemporaryMetadata();
        if (tempMetadata != null && !tempMetadata.isEmpty()) {
            planEnv.addToGlobalMetadata(tempMetadata);
        }
       
        ResultSetInfo rsInfo = planEnv.getStagingTableResultsInfo(stageGroupName);
        rsInfo.setCommand(cmd);
        rsInfo.setPlan(plan);
       
        //set the carinality on the temp group.
        TempMetadataID intoGroupID = (TempMetadataID)intoGroupSymbol.getMetadataID();
        intoGroupID.setCardinality(cardinality);
       
        // add the meterialization hook for the staged table to original one.
        //GroupSymbol groupSymbol = (GroupSymbol)query.getFrom().getGroups().get(0);
        planEnv.addStagingTable(srcGroup.getMetadataID(), intoGroupID);
       
        // plan the unload of the staging table
        String unloadName = planEnv.unLoadResultName(stageGroupName);
        ResultSetInfo rsUnloadInfo = planEnv.getStagingTableResultsInfo(unloadName);
        Command command = wrapStagingTableUnloadQuery(intoGroupSymbol);
        QueryResolver.resolveCommand(command, planEnv.getGlobalMetadata());
        command = QueryUtil.rewriteQuery(command, planEnv.getGlobalMetadata(), planEnv.context);
       
        plan = optimizePlan(command, planEnv);
        rsUnloadInfo.setCommand(command);
        rsUnloadInfo.setPlan(plan);
       
        return true;
    }
View Full Code Here

                String msg = QueryPlugin.Util.getString("XMLPlanner.The_XML_document_element_{0}_is_not_mapped_to_data_and_cannot_be_used_in_the_ORDER_BY_clause__{1}_1", params); //$NON-NLS-1$
                throw new QueryPlannerException(msg);
            }
           
            MappingSourceNode sourceNode = elementNode.getSourceNode();
            ResultSetInfo rs = sourceNode.getResultSetInfo();
            OrderBy by = rs.getOrderBy();
            if (by == null) {
                by = new OrderBy();
            }
            ElementSymbol mappedSymbol = (ElementSymbol)sourceNode.getSymbolMap().get(new ElementSymbol(elementNode.getNameInSource()));
            by.addVariable((ElementSymbol)mappedSymbol.clone(), ((Boolean)types.get(i)).booleanValue());
            rs.setOrderBy(by);
    }
  }
View Full Code Here

        if (sourceNode.getAliasResultName() != null) {
            return false;
        }
       
        String groupName = sourceNode.getActualResultSetName();
        ResultSetInfo rsInfo = sourceNode.getResultSetInfo();

        // If this node has been eligible for raising, it will be eligible for staging.
        if (!rsInfo.isCriteriaRaised()) {
            return false;
        }
       
        // no bindings - no references
        QueryNode queryNode = QueryUtil.getQueryNode(groupName, planEnv.getGlobalMetadata());
View Full Code Here

    TempMetadataAdapter getGlobalMetadata() {
        return new TempMetadataAdapter(metadata, new TempMetadataStore(this.globalTempMetadata), this.stagingTableMap, this.queryNodeMap);
    }

    public ResultSetInfo getStagingTableResultsInfo(String groupName) {
        ResultSetInfo info = (ResultSetInfo)this.stagingResultsInfo.get(groupName.toUpperCase());
        if (info == null) {
            info = new ResultSetInfo(groupName, true);           
            this.stagingResultsInfo.put(info.getResultSetName().toUpperCase(), info);
        }
        return info;
    }
View Full Code Here

        throws QueryPlannerException, QueryMetadataException, TeiidComponentException {

        MappingVisitor queryPlanVisitor = new MappingVisitor() {
            public void visit(MappingSourceNode sourceNode) {
                try {
                    ResultSetInfo rsInfo = sourceNode.getResultSetInfo();
               
                    if (rsInfo.isJoinedWithParent()) {
                        return;
                    }
                   
                    Query command = (Query)rsInfo.getCommand();
                   
                    prepareQuery(sourceNode, planEnv, command);
                   
                    QueryUtil.rewriteQuery(command, planEnv.getGlobalMetadata(), planEnv.context);
                   
                    // Plan the result set.
                    ProcessorPlan queryPlan = optimizePlan(command, planEnv);
                    rsInfo.setPlan(queryPlan);                   
                } catch (Exception e) {
                    throw new TeiidRuntimeException(e);
                }
            }
        };
View Full Code Here

    }
   
    static void planQueries(MappingSourceNode sourceNode, XMLPlannerEnvironment planEnv)
        throws QueryPlannerException, QueryMetadataException, TeiidComponentException {

        ResultSetInfo rsInfo = sourceNode.getResultSetInfo();
       
        // Create sql:  SELECT * FROM rsName           
        Query rsQuery = (Query)rsInfo.getCommand();
       
        // add user order by to base query
        rsQuery.setOrderBy(rsInfo.getOrderBy());

        // add user criteria to base query from model
        Criteria crit = rsInfo.getCriteria();
        try {
            if(crit != null) {
                planQueryWithCriteria(sourceNode, planEnv);
            }
        } catch (QueryResolverException e) {
            throw new TeiidComponentException(e);
        }

        if (rsInfo.getUserRowLimit() != -1) {
            int limit = rsInfo.getUserRowLimit();
            if (rsInfo.exceptionOnRowlimit()) {
                limit++;
            }
            rsQuery.setLimit(new Limit(null, new Constant(new Integer(limit))));
        }
       
        //prepareQuery(sourceNode, planEnv, rsQuery);
       
        // this query is not eligible for staging; proceed normally.
        rsInfo.setCommand(rsQuery);           
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.mapping.xml.ResultSetInfo

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.