use of org.teiid.common.buffer.BufferManager in project teiid by teiid.
the class TestTempTables method testForeignTemp.
@Test
public void testForeignTemp() throws Exception {
HardcodedDataManager hdm = new HardcodedDataManager(metadata);
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0);
cache.setTupleBufferCache(bm);
dataManager = new TempTableDataManager(hdm, bm, cache);
// $NON-NLS-1$
execute("create foreign temporary table x (e1 string options (nameinsource 'a'), e2 integer, e3 string, primary key (e1)) options (cardinality 1000, updatable true, \"other\" 'prop') on pm1", new List[] { Arrays.asList(0) });
TempMetadataID id = this.tempStore.getMetadataStore().getData().get("x");
// ensure that we're using the actual metadata
assertNotNull(id);
assertNotNull(this.metadata.getPrimaryKey(id));
assertEquals(1000, this.metadata.getCardinality(id), 0);
assertEquals("pm1", this.metadata.getName(this.metadata.getModelID(id)));
assertEquals("prop", this.metadata.getExtensionProperty(id, "other", false));
hdm.addData("SELECT x.a, x.e2, x.e3 FROM x", new List[] { Arrays.asList(1, 2, "3") });
// $NON-NLS-1$
execute("select * from x", new List[] { Arrays.asList(1, 2, "3") });
hdm.addData("SELECT g_0.e2 AS c_0, g_0.e3 AS c_1, g_0.a AS c_2 FROM x AS g_0 ORDER BY c_1, c_0", new List[] { Arrays.asList(2, "3", "1") });
hdm.addData("SELECT g_0.e3, g_0.e2 FROM x AS g_0", new List[] { Arrays.asList("3", 2) });
hdm.addData("DELETE FROM x WHERE x.a = '1'", new List[] { Arrays.asList(1) });
// ensure compensation behaves as if physical - not temp
// $NON-NLS-1$
execute("delete from x where e2 = (select max(e2) from x as z where e3 = x.e3)", new List[] { Arrays.asList(1) }, TestOptimizer.getGenericFinder());
hdm.addData("SELECT g_0.e1 FROM g1 AS g_0, x AS g_1 WHERE g_1.a = g_0.e1", new List[] { Arrays.asList(1) });
// ensure pushdown support
// $NON-NLS-1$
execute("select g1.e1 from pm1.g1 g1, x where x.e1 = g1.e1", new List[] { Arrays.asList(1) }, TestOptimizer.getGenericFinder());
try {
// $NON-NLS-1$
execute("create local temporary table x (e1 string)", new List[] { Arrays.asList(0) });
fail();
} catch (QueryResolverException e) {
}
// ensure that drop works
execute("drop table x", new List[] { Arrays.asList(0) });
try {
execute("drop table x", new List[] { Arrays.asList(0) });
fail();
} catch (QueryResolverException e) {
}
}
use of org.teiid.common.buffer.BufferManager in project teiid by teiid.
the class TestQueryProcessor method helpTestProcessor.
public void helpTestProcessor(FakeProcessorPlan plan, List[] expectedResults) throws TeiidException {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
FakeDataManager dataManager = new FakeDataManager();
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "group", null, null, 1);
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
BatchCollector collector = processor.createBatchCollector();
TupleBuffer tsID = null;
while (true) {
try {
tsID = collector.collectTuples();
break;
} catch (BlockedException e) {
}
}
// Compare # of rows in actual and expected
// $NON-NLS-1$
assertEquals("Did not get expected # of rows", expectedResults.length, tsID.getRowCount());
// Compare actual with expected results
TupleSource actual = tsID.createIndexedTupleSource();
if (expectedResults.length > 0) {
for (int i = 0; i < expectedResults.length; i++) {
List actRecord = actual.nextTuple();
List expRecord = expectedResults[i];
// $NON-NLS-1$
assertEquals("Did not match row at row index " + i, expRecord, actRecord);
}
}
tsID.remove();
}
use of org.teiid.common.buffer.BufferManager in project teiid by teiid.
the class TestAccessNode method helpTestOpen.
private void helpTestOpen(Command command, String expectedCommand, boolean shouldRegisterRequest) throws Exception {
// Setup
AccessNode node = new AccessNode(1);
node.setCommand(command);
CommandContext context = new CommandContext();
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
node.setElements(command.getProjectedSymbols());
node.initialize(context, bm, dataManager);
node.setShouldEvaluateExpressions(true);
// Call open()
node.open();
if (shouldRegisterRequest) {
assertEquals(Arrays.asList(expectedCommand), dataManager.getQueries());
} else {
assertEquals(0, dataManager.getQueries().size());
}
}
use of org.teiid.common.buffer.BufferManager in project teiid by teiid.
the class TestGroupingNode method test2.
@Test
public void test2() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
GroupingNode node = getExampleGroupingNode();
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
List[] expected = new List[] { Arrays.asList(new Object[] { null, new Integer(1) }), Arrays.asList(new Object[] { new Integer(0), new Integer(1) }), Arrays.asList(new Object[] { new Integer(1), new Integer(1) }), Arrays.asList(new Object[] { new Integer(2), new Integer(2) }), Arrays.asList(new Object[] { new Integer(3), new Integer(1) }), Arrays.asList(new Object[] { new Integer(4), new Integer(2) }), Arrays.asList(new Object[] { new Integer(5), new Integer(1) }), Arrays.asList(new Object[] { new Integer(6), new Integer(2) }) };
helpProcess(mgr, node, context, expected, null);
}
use of org.teiid.common.buffer.BufferManager in project teiid by teiid.
the class TestGroupingNode method testDupSort.
@Test
public void testDupSort() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
GroupingNode node = getExampleGroupingNode();
node.setRemoveDuplicates(true);
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
List[] expected = new List[] { Arrays.asList(new Object[] { null, new Integer(1) }), Arrays.asList(new Object[] { new Integer(0), new Integer(1) }), Arrays.asList(new Object[] { new Integer(1), new Integer(1) }), Arrays.asList(new Object[] { new Integer(2), new Integer(2) }), Arrays.asList(new Object[] { new Integer(3), new Integer(1) }), Arrays.asList(new Object[] { new Integer(4), new Integer(2) }), Arrays.asList(new Object[] { new Integer(5), new Integer(1) }), Arrays.asList(new Object[] { new Integer(6), new Integer(2) }) };
helpProcess(mgr, node, context, expected, null);
}
Aggregations