Package org.teiid.query.util

Examples of org.teiid.query.util.CommandContext


       
        QueryMetadataInterface metadata = RealMetadataFactory.exampleMaterializedView();
        AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
       
        Command command = helpGetCommand(userSql, metadata, null);
        CommandContext cc = new CommandContext();
        cc.setGlobalTableStore(new TempTableStore("SYSTEM"));
        ProcessorPlan plan = TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
        TestOptimizer.checkAtomicQueries(new String[] {"SELECT #MAT_MATVIEW.VGROUP4.x FROM #MAT_MATVIEW.VGROUP4"}, plan);
        Collection<Annotation> annotations = analysis.getAnnotations();
        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
        assertEquals("Expected one annotation", 2, annotations.size()); //$NON-NLS-1$
View Full Code Here


    if (analysisRecord == null) {
      analysisRecord = new AnalysisRecord(false, false);
    }
   
    if (context == null) {
      context = new CommandContext();
    }
   
    if (!(capFinder instanceof TempCapabilitiesFinder)) {
      capFinder = new TempCapabilitiesFinder(capFinder);
    }
   
        boolean debug = analysisRecord.recordDebug();
       
        Map tempMetadata = command.getTemporaryMetadata();
        metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(tempMetadata));
               
        // Create an ID generator that can be used for all plans to generate unique data node IDs
        if(idGenerator == null) {
            idGenerator = new IDGenerator();
            idGenerator.setDefaultFactory(new IntegerIDFactory());
        }
       
    if(debug) {
      analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
            analysisRecord.println("OPTIMIZE: \n" + command); //$NON-NLS-1$
    }  
                                  
    ProcessorPlan result = null;

    switch (command.getType()) {
    case Command.TYPE_UPDATE_PROCEDURE:
      CreateUpdateProcedureCommand cupc = (CreateUpdateProcedureCommand)command;
      if (cupc.isUpdateProcedure()) {
        result = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, context);
      } else {
        StoredProcedure c = (StoredProcedure)cupc.getUserCommand();
        Object pid = cupc.getVirtualGroup().getMetadataID();
        if (c != null) {
          pid = c.getProcedureID();
        }
        String fullName = metadata.getFullName(pid);
        fullName = "procedure cache:" + fullName; //$NON-NLS-1$
        PreparedPlan pp = context.getPlan(fullName);
        if (pp == null) {
          Determinism determinismLevel = context.resetDeterminismLevel();
          CommandContext clone = context.clone();
          ProcessorPlan plan = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, clone);
          //note that this is not a full prepared plan.  It is not usable by user queries.
          if (pid instanceof Procedure) {
            clone.accessedPlanningObject(pid);
          }
          pp = new PreparedPlan();
          pp.setPlan(plan, clone);
          context.putPlan(fullName, pp, context.getDeterminismLevel());
          context.setDeterminismLevel(determinismLevel);
View Full Code Here

    Command query = QueryParser.getQueryParser().parseCommand(command);
    QueryResolver.resolveCommand(query, METADATA);
   
    //Generate canonical plan
      RelationalPlanner p = new RelationalPlanner();
      p.initialize(query, null, METADATA, FINDER, null, new CommandContext());
      PlanNode planNode = p.generatePlan(query);
      RelationalPlanner planner = new RelationalPlanner();
    final RuleStack rules = planner.buildRules();

    PlanNode testPlan = helpExecuteRules(rules, planNode, METADATA, DEBUG);
View Full Code Here

  /**
   * Simulate execution of the QueryOptimizer rules stack
   */
  private static PlanNode helpExecuteRules(RuleStack rules, PlanNode plan, QueryMetadataInterface metadata, boolean debug)
    throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
    CommandContext context = new CommandContext();
    while(! rules.isEmpty()) {
      if(debug) {
        System.out.println("\n============================================================================"); //$NON-NLS-1$
      }
      OptimizerRule rule = rules.pop();
View Full Code Here

        capFinder.addCapabilities("pm1", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
        capFinder.addCapabilities("pm2", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
        capFinder.addCapabilities("pm3", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
        capFinder.addCapabilities("pm4", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
       
        rule.execute(bogusParentNode, metadata, capFinder, new RuleStack(), null, new CommandContext());

        if (DEBUG){
            System.out.println("Done."); //$NON-NLS-1$
            System.out.println(bogusParentNode);
        }
View Full Code Here

    static ProcessorPlan helpTestProcess(String sql, FakeMetadataFacade metadata, FakeDataManager dataMgr, Class expectedException, CapabilitiesFinder capFinder, String... expectedDoc) throws Exception{
        Command command = helpGetCommand(sql, metadata);
        AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);

        try {
            CommandContext planningContext = new CommandContext(); //this should be the same as the processing context, but that's not easy to do
            planningContext.setMetadata(new TempMetadataAdapter(metadata, new TempMetadataStore()));
            ProcessorPlan plan = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, planningContext);
           
            if(DEBUG) {
                System.out.println(analysisRecord.getDebugLog());
            }
View Full Code Here

       
        Command command = helpGetCommand("SELECT * FROM xmltest.doc6", metadata); //$NON-NLS-1$
        XMLPlan plan = TestXMLPlanner.preparePlan(command, metadata, new DefaultCapabilitiesFinder(), null);

        BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
        CommandContext context = new CommandContext("pID", null, null, null, 1);                                 //$NON-NLS-1$
        QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
        processor.setNonBlocking(true);
        BatchCollector collector = processor.createBatchCollector();
        TeiidComponentException failOnDefaultException = null;
        try{
View Full Code Here

        if (state == null) {
          if (this.currentState == null) {
            //this may not be the first time the plan is being run
            command.reset();
   
            CommandContext subContext = getContext().clone();
            subContext.setVariableContext(this.currentVarContext);
            subContext.setTempTableStore(getTempTableStore());
            state = new CursorState();
            state.processor = new QueryProcessor(command, subContext, this.bufferMgr, this.dataMgr);
            state.ts = new BatchIterator(state.processor);
            if (procAssignments != null && state.processor.getOutputElements().size() - procAssignments.size() > 0) {
              state.resultsBuffer = bufferMgr.createTupleBuffer(state.processor.getOutputElements().subList(0, state.processor.getOutputElements().size() - procAssignments.size()), getContext().getConnectionID(), TupleSourceType.PROCESSOR);
View Full Code Here

        boolean exists = this.cursorStates.containsKey(rsKey);
        return exists;
    }

    public CommandContext getContext() {
      CommandContext context = super.getContext();
      if (evaluatedParams) {
        context.setVariableContext(currentVarContext);
      }
      return context;
    }
View Full Code Here

       
        this.resultInfo = resultInfo;
        this.bufferMgr = bufferMgr;
       
        ProcessorPlan plan = resultInfo.getPlan();
        CommandContext subContext = context.clone();
        subContext.pushVariableContext(new VariableContext());
        this.internalProcessor = new QueryProcessor(plan, subContext, bufferMgr, dataMgr);
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.util.CommandContext

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.