use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestWithClauseProcessing method testWithImplicitIndexing.
@Test
public void testWithImplicitIndexing() throws Exception {
// $NON-NLS-1$
String sql = "with a (x, y, z) as /*+ no_inline */ (select e1, e2, e3 from pm1.g1) select (select max(x) from a where y = pm1.g2.e2), pm1.g2.* from pm1.g2";
HardcodedDataManager dataManager = new HardcodedDataManager();
ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached());
List<?>[] rows = new List<?>[20480];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i), i);
}
dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", rows);
rows = new List<?>[20480];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList("a", i, true, 1.1);
}
dataManager.addData("SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2", rows);
List<?>[] expected = new List[20480];
for (int i = 0; i < rows.length; i++) {
expected[i] = Arrays.asList(String.valueOf(i), "a", i, true, 1.1);
}
CommandContext cc = createCommandContext();
BufferManagerImpl bm = (BufferManagerImpl) cc.getBufferManager();
long reads = bm.getReadAttempts();
helpProcess(plan, cc, dataManager, expected);
reads = bm.getReadAttempts() - reads;
assertTrue(reads < 500000);
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestGroupingNode method helpTestLookupFunctionInAggregate.
private void helpTestLookupFunctionInAggregate(int batchSize) throws Exception {
BufferManagerImpl mgr = BufferManagerFactory.createBufferManager();
mgr.setProcessorBatchSize(batchSize);
// Set up
GroupingNode node = new GroupingNode(1);
List outputElements = new ArrayList();
// $NON-NLS-1$
ElementSymbol col1 = new ElementSymbol("col1");
col1.setType(Integer.class);
// $NON-NLS-1$
ElementSymbol col2 = new ElementSymbol("col2");
col2.setType(Integer.class);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), col2 });
// $NON-NLS-1$
FunctionDescriptor desc = RealMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class });
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
outputElements.add(col1);
// $NON-NLS-1$ //$NON-NLS-2$
outputElements.add(new AggregateSymbol("COUNT", false, func));
// $NON-NLS-1$ //$NON-NLS-2$
outputElements.add(new AggregateSymbol("SUM", false, func));
// $NON-NLS-1$ //$NON-NLS-2$
outputElements.add(new AggregateSymbol("SUM", true, func));
node.setElements(outputElements);
List groupingElements = new ArrayList();
groupingElements.add(col1);
node.setOrderBy(new OrderBy(groupingElements).getOrderByItems());
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
FakeDataManager dataMgr = new FakeDataManager();
dataMgr.setThrowBlocked(true);
Map valueMap = new HashMap();
valueMap.put(new Integer(0), new Integer(1));
valueMap.put(new Integer(1), new Integer(2));
valueMap.put(new Integer(2), new Integer(3));
valueMap.put(new Integer(3), new Integer(4));
valueMap.put(new Integer(4), new Integer(5));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
dataMgr.defineCodeTable("pm1.g1", "e1", "e2", valueMap);
List[] expected = new List[] { Arrays.asList(new Object[] { null, new Integer(1), new Long(4), new Long(4) }), Arrays.asList(new Object[] { new Integer(0), new Integer(1), new Long(5), new Long(5) }), Arrays.asList(new Object[] { new Integer(1), new Integer(1), new Long(3), new Long(3) }), Arrays.asList(new Object[] { new Integer(2), new Integer(4), new Long(9), new Long(5) }), Arrays.asList(new Object[] { new Integer(3), new Integer(1), new Long(1), new Long(1) }), Arrays.asList(new Object[] { new Integer(4), new Integer(2), new Long(7), new Long(7) }), Arrays.asList(new Object[] { new Integer(5), new Integer(1), new Long(4), new Long(4) }), Arrays.asList(new Object[] { new Integer(6), new Integer(2), new Long(9), new Long(9) }) };
helpProcess(mgr, node, context, expected, dataMgr);
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestJoinNode method testEnhancedWithLimit.
@Test
public void testEnhancedWithLimit() throws Exception {
// $NON-NLS-1$
String sql = "select a.e1, b.e2 from pm1.g1 as a, pm2.g2 as b where a.e1 = b.e1 limit 10";
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
HardcodedDataManager hdm = new HardcodedDataManager();
List<?>[] rows = new List<?>[50];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i));
}
hdm.addData("SELECT pm1.g1.e1 FROM pm1.g1", rows);
rows = new List<?>[200];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i), i);
}
hdm.addData("SELECT pm2.g2.e1, pm2.g2.e2 FROM pm2.g2", rows);
BufferManagerImpl mgr = BufferManagerFactory.getTestBufferManager(1, 2);
mgr.setTargetBytesPerRow(100);
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
context.setBufferManager(mgr);
rows = new List<?>[10];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i), i);
}
TestProcessor.helpProcess(plan, context, hdm, rows);
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestJoinNode method helpTestJoinDirect.
public void helpTestJoinDirect(List[] expectedResults, int batchSize, int processingBytes) throws TeiidComponentException, TeiidProcessingException {
BufferManagerImpl mgr = BufferManagerFactory.getTestBufferManager(processingBytes, batchSize);
mgr.setTargetBytesPerRow(100);
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
join.addChild(leftNode);
join.addChild(rightNode);
leftNode.initialize(context, mgr, dataMgr);
rightNode.initialize(context, mgr, dataMgr);
join.initialize(context, mgr, dataMgr);
process(expectedResults);
join.reset();
process(expectedResults);
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestJoinNode method testEnhancedWithSortDistinct.
@Test
public void testEnhancedWithSortDistinct() throws Exception {
// $NON-NLS-1$
String sql = "select a.e1, b.e2 from pm1.g1 as a, (select e1, e2 from pm2.g2 union select e1, e2 from pm2.g2) as b where a.e1 = b.e1";
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
HardcodedDataManager hdm = new HardcodedDataManager();
List<?>[] rows = new List<?>[10];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i));
}
hdm.addData("SELECT pm1.g1.e1 FROM pm1.g1", rows);
rows = new List<?>[10];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i), i);
}
hdm.addData("SELECT pm2.g2.e1, pm2.g2.e2 FROM pm2.g2", rows);
BufferManagerImpl mgr = BufferManagerFactory.getTestBufferManager(1, 2);
mgr.setTargetBytesPerRow(100);
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
context.setBufferManager(mgr);
TestProcessor.helpProcess(plan, context, hdm, rows);
}
Aggregations