Package org.teiid.query.util

Examples of org.teiid.query.util.CommandContext


            Arrays.asList(3),
            Arrays.asList(4),
           
        });
        ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
        CommandContext cc = createCommandContext();
        cc.setProcessorBatchSize(2);
        helpProcess(plan, cc, hdm, expected);
    }
View Full Code Here


        g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
        FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
        g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
       
        Command command = helpParse(sql);  
        CommandContext context = createCommandContext();
        context.setMetadata(metadata);
        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder,context);
       
        //Verify a dependent join (not merge join) was used
        assertTrue(plan instanceof RelationalPlan);
        RelationalPlan relationalPlan = (RelationalPlan)plan;
View Full Code Here

        g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
        FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
        g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
       
        Command command = helpParse(sql);  
        CommandContext context = createCommandContext();
        context.setMetadata(metadata);
        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
       
        //Verify a dependent join (not merge join) was used
        assertTrue(plan instanceof RelationalPlan);
        RelationalPlan relationalPlan = (RelationalPlan)plan;
View Full Code Here

  static void processPreparedStatement(String sql, List[] expected,
      ProcessorDataManager dataManager, CapabilitiesFinder capFinder,
      QueryMetadataInterface metadata, List<?> values) throws Exception {
    Command command = helpParse(sql);  
        CommandContext context = createCommandContext();
        context.setMetadata(metadata);       
        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
       
        // Collect reference, set value
        VariableContext vc = new VariableContext();
        Iterator<?> valIter = values.iterator();
        for (Reference ref : ReferenceCollectorVisitor.getReferences(command)) {
            vc.setGlobalValue(ref.getContextSymbol(),  valIter.next()); //$NON-NLS-1$
    }
        context.setVariableContext(vc);
        // Run query
        helpProcess(plan, context, dataManager, expected);
  }   
View Full Code Here

        // Plan query
        String sql = "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 0) = e1";//$NON-NLS-1$
        QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
        Command command = TestProcessor.helpParse(sql);  
        CommandContext context = createCommandContext();
        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
       
        // Run query
        List[] expected = new List[] {
            Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
View Full Code Here

    private void helpTestOpen(Command command, String expectedCommand, boolean shouldRegisterRequest) throws Exception {
        // Setup
        AccessNode node = new AccessNode(1);
        node.setCommand(command);
        CommandContext context = new CommandContext();
        context.setProcessorID("processorID"); //$NON-NLS-1$
        BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
        FakeDataManager dataManager = new FakeDataManager();
        TestProcessor.sampleData1(dataManager);
        node.setElements(command.getProjectedSymbols());
        node.initialize(context, bm, dataManager);
View Full Code Here

    @Test public void testExecCount()throws Exception{
        // Setup
        AccessNode node = new AccessNode(1);
      Query query = (Query)TestResolver.helpResolve("SELECT e1, e2 FROM pm1.g1 WHERE e2 = 5", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
        node.setCommand(query);
        CommandContext context = new CommandContext();
        context.setProcessorID("processorID"); //$NON-NLS-1$
        BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
        FakeDataManager dataManager = new FakeDataManager();
        TestProcessor.sampleData1(dataManager);
        node.setElements(query.getProjectedSymbols());
        node.initialize(context, bm, dataManager);
View Full Code Here

      List<Boolean> shouldEvaluate = new ArrayList<Boolean>(commands.size());
      for (Command command : commands) {
      shouldEvaluate.add(EvaluatableVisitor.needsProcessingEvaluation(command));
    }
        BatchedUpdateNode node = new BatchedUpdateNode(1, commands, Collections.EMPTY_LIST, shouldEvaluate, "myModelName"); //$NON-NLS-1$
        CommandContext context = new CommandContext();
        context.setProcessorID("myProcessorID"); //$NON-NLS-1$
        context.setMetadata(md);
        node.initialize(context, Mockito.mock(BufferManager.class), pdm);
        return node;
    }
View Full Code Here

   
    public static final int BATCH_SIZE = 100;
   
    private void helpTestSort(List elements, List[] data, List sortElements, List sortTypes, List[] expected, Mode mode) throws TeiidComponentException, TeiidProcessingException {
        BufferManager mgr = NodeTestUtil.getTestBufferManager(100, BATCH_SIZE, BATCH_SIZE);
        CommandContext context = new CommandContext ("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
       
        BlockingFakeRelationalNode dataNode = new BlockingFakeRelationalNode(2, data);
        dataNode.setReturnPeriod(3);
        dataNode.setElements(elements);
        dataNode.initialize(context, mgr, null);   
View Full Code Here

   
   
    private Expression helpTestRewriteExpression(String original, String expected, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException {
      Expression actualExp = QueryParser.getQueryParser().parseExpression(original);
      ResolverVisitor.resolveLanguageObject(actualExp, metadata);
      CommandContext context = new CommandContext();
      context.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
      actualExp = QueryRewriter.rewriteExpression(actualExp, null, context, metadata);
      if (expected != null) {
        Expression expectedExp = QueryParser.getQueryParser().parseExpression(expected);
        ResolverVisitor.resolveLanguageObject(expectedExp, metadata);
        assertEquals(expectedExp, actualExp);
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.