use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestDQPCore method testLimitCompensation.
@Test
public void testLimitCompensation() throws Exception {
// $NON-NLS-1$
String sql = "SELECT * FROM VQT.SmallA_2589g LIMIT 1, 1";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
agds.setCaps(caps);
// $NON-NLS-1$
ResultsMessage rm = helpExecute(sql, "a");
// we test for > 0 here because the autogen service doesn't obey the limit
assertTrue(rm.getResultsList().size() > 0);
}
use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestDQPCore method testBufferLimit.
@Test
public void testBufferLimit() throws Exception {
// the sql should return 400 rows
// $NON-NLS-1$
String sql = "SELECT A.IntKey FROM BQT1.SmallA as A, BQT1.SmallA as B, (select intkey from BQT1.SmallA limit 4) as C";
// $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());
int rowsPerBatch = 8;
assertEquals(rowsPerBatch, rm.getResultsList().size());
RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
message = core.processCursorRequest(reqMsg.getExecutionId(), 9, rowsPerBatch);
rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(rowsPerBatch, rm.getResultsList().size());
// ensure that we are idle
for (int i = 0; i < 10 && item.getThreadState() != ThreadState.IDLE; i++) {
Thread.sleep(100);
}
assertEquals(ThreadState.IDLE, item.getThreadState());
assertTrue(item.resultsBuffer.getManagedRowCount() <= rowsPerBatch * 23);
// pull the rest of the results
int start = 17;
while (true) {
item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
message = core.processCursorRequest(reqMsg.getExecutionId(), start, rowsPerBatch);
rm = message.get(5000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertTrue(rowsPerBatch >= rm.getResultsList().size());
start += rm.getResultsList().size();
if (rm.getFinalRow() == rm.getLastRow()) {
break;
}
}
// insensitive should not block
reqMsg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
reqMsg.setExecutionId(id++);
message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(rowsPerBatch, rm.getResultsList().size());
item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
message = core.processCursorRequest(reqMsg.getExecutionId(), 9, rowsPerBatch);
rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(rowsPerBatch, rm.getResultsList().size());
// ensure that we are idle
for (int i = 0; i < 10 && item.getThreadState() != ThreadState.IDLE; i++) {
Thread.sleep(100);
}
assertEquals(ThreadState.IDLE, item.getThreadState());
// should buffer the same as forward only until a further batch is requested
assertTrue(item.resultsBuffer.getManagedRowCount() <= rowsPerBatch * 23);
// local should not buffer
reqMsg = exampleRequestMessage(sql);
reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
reqMsg.setSync(true);
message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
rm = message.get(0, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(rowsPerBatch, rm.getResultsList().size());
item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
assertEquals(0, item.resultsBuffer.getManagedRowCount());
assertEquals(8, item.resultsBuffer.getRowCount());
}
use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestDQPCore method testUsingFinalBuffer.
@Test
public void testUsingFinalBuffer() throws Exception {
String sql = "select intkey from bqt1.smalla order by intkey";
((BufferManagerImpl) core.getBufferManager()).setProcessorBatchSize(2);
agds.sleep = 50;
RequestMessage reqMsg = exampleRequestMessage(sql);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(10, rm.getResultsList().size());
message = core.processCursorRequest(reqMsg.getExecutionId(), 3, 2);
rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(2, rm.getResultsList().size());
}
use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestDQPCore method helpTestPlanInvalidation.
private void helpTestPlanInvalidation(String query) throws InterruptedException, ExecutionException, TimeoutException, TeiidProcessingException {
// $NON-NLS-1$
String sql = "insert into #temp select * FROM vqt.SmallB";
// $NON-NLS-1$
String userName = "1";
// $NON-NLS-1$
int sessionid = 1;
RequestMessage reqMsg = exampleRequestMessage(sql);
ResultsMessage rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(1, rm.getResultsList().size());
sql = query;
reqMsg = exampleRequestMessage(sql);
reqMsg.setStatementType(StatementType.PREPARED);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(10, rm.getResultsList().size());
sql = query;
reqMsg = exampleRequestMessage(sql);
reqMsg.setStatementType(StatementType.PREPARED);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(10, rm.getResultsList().size());
assertEquals(1, this.core.getPrepPlanCache().getCacheHitCount());
Thread.sleep(100);
// perform a minor update, we should still use the cache
// $NON-NLS-1$
sql = "delete from #temp where a12345 = '11'";
reqMsg = exampleRequestMessage(sql);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(1, rm.getResultsList().size());
sql = query;
reqMsg = exampleRequestMessage(sql);
reqMsg.setStatementType(StatementType.PREPARED);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(10, rm.getResultsList().size());
assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount());
// perform a major update, it might purge the plan
// $NON-NLS-1$
sql = "delete from #temp";
reqMsg = exampleRequestMessage(sql);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(1, rm.getResultsList().size());
sql = query;
reqMsg = exampleRequestMessage(sql);
reqMsg.setStatementType(StatementType.PREPARED);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(0, rm.getResultsList().size());
}
use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestDQPCore method testBufferReuse1.
@Test
public void testBufferReuse1() throws Exception {
// the sql should return 100 rows
String sql = "SELECT IntKey FROM texttable('1112131415' columns intkey integer width 2 no row delimiter) t " + "union " + // $NON-NLS-1$
"SELECT IntKey FROM bqt1.smalla order by intkey";
// $NON-NLS-1$
String userName = "1";
// $NON-NLS-1$
String sessionid = "1";
agds.sleep = 50;
agds.setUseIntCounter(true);
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setRowLimit(11);
reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
DQPWorkContext.getWorkContext().getSession().setUserName(userName);
BufferManagerImpl bufferManager = (BufferManagerImpl) core.getBufferManager();
bufferManager.setProcessorBatchSize(20);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(10, rm.getResultsList().size());
message = core.processCursorRequest(reqMsg.getExecutionId(), 6, 5);
rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(5, rm.getResultsList().size());
message = core.processCursorRequest(reqMsg.getExecutionId(), 11, 5);
rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(1, rm.getResultsList().size());
assertEquals(11, rm.getFirstRow());
assertEquals(11, rm.getFinalRow());
}
Aggregations