use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestTupleSourceCache method testNodeId.
@Test
public void testNodeId() throws Exception {
TupleSourceCache tsc = new TupleSourceCache();
HardcodedDataManager pdm = new HardcodedDataManager() {
@Override
public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
assertEquals(1, parameterObject.nodeID);
return Mockito.mock(TupleSource.class);
}
};
CommandContext context = TestProcessor.createCommandContext();
BufferManagerImpl bufferMgr = BufferManagerFactory.createBufferManager();
Command command = new Insert();
RegisterRequestParameter parameterObject = new RegisterRequestParameter("z", 1, 1);
parameterObject.info = new RegisterRequestParameter.SharedAccessInfo();
tsc.getSharedTupleSource(context, command, "x", parameterObject, bufferMgr, pdm);
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestDQPCore method testFinalRow.
@Test
public void testFinalRow() throws Exception {
// $NON-NLS-1$
String sql = "SELECT A.IntKey FROM BQT1.SmallA as A";
// $NON-NLS-1$
String userName = "1";
// $NON-NLS-1$
String sessionid = "1";
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
DQPWorkContext.getWorkContext().getSession().setUserName(userName);
((BufferManagerImpl) core.getBufferManager()).setProcessorBatchSize(10);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(10, rm.getResultsList().size());
RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
while (item.isProcessing()) ;
synchronized (item) {
for (int i = 0; i < 100; i++) {
Thread.sleep(10);
}
}
assertEquals(10, item.resultsBuffer.getRowCount());
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestDQPCore method testBufferReuse.
@Test
public void testBufferReuse() throws Exception {
// the sql should return 100 rows
// $NON-NLS-1$
String sql = "SELECT A.IntKey FROM BQT1.SmallA as A, BQT1.SmallA as B ORDER BY A.IntKey";
// $NON-NLS-1$
String userName = "1";
// $NON-NLS-1$
String sessionid = "1";
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
DQPWorkContext.getWorkContext().getSession().setUserName(userName);
((BufferManagerImpl) core.getBufferManager()).setProcessorBatchSize(1);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(8, rm.getResultsList().size());
RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
assertEquals(100, item.resultsBuffer.getRowCount());
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestSTree method testOrderedInsert.
@Test
public void testOrderedInsert() throws TeiidComponentException {
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setProcessorBatchSize(4);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
List<ElementSymbol> elements = Arrays.asList(e1);
STree map = bm.createSTree(elements, "1", 1);
int size = (1 << 16) + (1 << 4) + 1;
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(i), InsertMode.ORDERED, size));
assertEquals(i + 1, map.getRowCount());
}
assertEquals(4, map.getHeight());
for (int i = 0; i < size; i++) {
assertNotNull(map.remove(Arrays.asList(i)));
}
}
use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.
the class TestSTree method testUnOrderedInsert.
@Test
public void testUnOrderedInsert() throws TeiidComponentException {
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setProcessorBatchSize(16);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
List elements = Arrays.asList(e1);
STree map = bm.createSTree(elements, "1", 1);
int size = (1 << 16) + (1 << 4) + 1;
int logSize = map.getExpectedHeight(size);
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(i), InsertMode.NEW, logSize));
assertEquals(i + 1, map.getRowCount());
}
assertTrue(5 >= map.getHeight());
}
Aggregations