Search in sources :

Example 1 with ProcessorDataManager

use of org.teiid.query.processor.ProcessorDataManager in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testMultiReplacement.

@Test
public void testMultiReplacement() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT * FROM MultiModel.Phys";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 3;
    final List<?>[] expected = new List<?>[] { Arrays.asList(new Object[] { null, null }), Arrays.asList(new Object[] { null, null }), Arrays.asList(new Object[] { null, null }) };
    final ProcessorDataManager dataMgr = new MultiSourceDataManager();
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
Also used : ProcessorDataManager(org.teiid.query.processor.ProcessorDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 2 with ProcessorDataManager

use of org.teiid.query.processor.ProcessorDataManager in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testSingleReplacementInDynamicCommand.

@Test
public void testSingleReplacementInDynamicCommand() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "exec Virt.sq1('a')";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 3;
    final List<?>[] expected = new List<?>[] { Arrays.asList(new Object[] { null, null }) };
    final ProcessorDataManager dataMgr = new MultiSourceDataManager();
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
Also used : ProcessorDataManager(org.teiid.query.processor.ProcessorDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 3 with ProcessorDataManager

use of org.teiid.query.processor.ProcessorDataManager in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testNoReplacement.

@Test
public void testNoReplacement() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT * FROM MultiModel.Phys WHERE SOURCE_NAME = 'bogus'";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List[0];
    final ProcessorDataManager dataMgr = new MultiSourceDataManager();
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
Also used : ProcessorDataManager(org.teiid.query.processor.ProcessorDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 4 with ProcessorDataManager

use of org.teiid.query.processor.ProcessorDataManager in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testSingleReplacementInDynamicCommandNullValue.

@Test
public void testSingleReplacementInDynamicCommandNullValue() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "exec Virt.sq1(null)";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 3;
    final List<?>[] expected = new List[0];
    final ProcessorDataManager dataMgr = new MultiSourceDataManager();
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
Also used : ProcessorDataManager(org.teiid.query.processor.ProcessorDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 5 with ProcessorDataManager

use of org.teiid.query.processor.ProcessorDataManager in project teiid by teiid.

the class TestProjectIntoNode method helpTestNextBatch.

private void helpTestNextBatch(int tupleBatchSize, Mode mode) throws Exception {
    ProjectIntoNode node = new ProjectIntoNode(2);
    TupleSource tupleSource = new FakeDataTupleSource(NUM_ROWS);
    RelationalNode child = new FakeRelationalNode(1, tupleSource, tupleBatchSize);
    node.addChild(child);
    // $NON-NLS-1$
    node.setIntoGroup(new GroupSymbol("myGroup"));
    // $NON-NLS-1$
    ElementSymbol elementSymbol_1 = new ElementSymbol("myGroup.myElement1");
    // $NON-NLS-1$
    ElementSymbol elementSymbol_2 = new ElementSymbol("myGroup.myElement2");
    elementSymbol_1.setType(Integer.class);
    elementSymbol_2.setType(String.class);
    List<ElementSymbol> elements = Arrays.asList(elementSymbol_1, elementSymbol_2);
    node.setIntoElements(elements);
    child.setElements(elements);
    node.setMode(mode);
    // $NON-NLS-1$
    node.setModelName("myModel");
    CommandContext context = new CommandContext();
    BufferManager bm = BufferManagerFactory.getTestBufferManager(tupleBatchSize, tupleBatchSize);
    ProcessorDataManager dataManager = new FakePDM(tupleBatchSize);
    child.initialize(context, bm, dataManager);
    node.initialize(context, bm, dataManager);
    node.open();
    TupleBatch batch = null;
    // Do the remaining batches
    while (true) {
        try {
            batch = node.nextBatch();
            break;
        } catch (BlockedException e) {
        // Normal
        }
    }
    assertNotNull(batch);
    List[] tuples = batch.getAllTuples();
    assertEquals(1, tuples.length);
    Object[] columns = tuples[0].toArray();
    assertNotNull(columns);
    assertEquals(1, columns.length);
    // Should have inserted all rows
    assertEquals(new Integer(NUM_ROWS), columns[0]);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) CommandContext(org.teiid.query.util.CommandContext) ProcessorDataManager(org.teiid.query.processor.ProcessorDataManager) BufferManager(org.teiid.common.buffer.BufferManager) BlockedException(org.teiid.common.buffer.BlockedException) CollectionTupleSource(org.teiid.query.processor.CollectionTupleSource) TupleSource(org.teiid.common.buffer.TupleSource) FakeTupleSource(org.teiid.query.processor.FakeTupleSource) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) List(java.util.List) TupleBatch(org.teiid.common.buffer.TupleBatch)

Aggregations

List (java.util.List)5 ProcessorDataManager (org.teiid.query.processor.ProcessorDataManager)5 Test (org.junit.Test)4 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)4 ArrayList (java.util.ArrayList)1 BlockedException (org.teiid.common.buffer.BlockedException)1 BufferManager (org.teiid.common.buffer.BufferManager)1 TupleBatch (org.teiid.common.buffer.TupleBatch)1 TupleSource (org.teiid.common.buffer.TupleSource)1 CollectionTupleSource (org.teiid.query.processor.CollectionTupleSource)1 FakeTupleSource (org.teiid.query.processor.FakeTupleSource)1 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)1 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)1 CommandContext (org.teiid.query.util.CommandContext)1