Author: jolee
Date: 2012-01-06 15:06:41 -0500 (Fri, 06 Jan 2012)
New Revision: 3779
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
TEIID-1884 fixing final row count when using foward only and fix of unit test to avoid
in-process thread during row count.
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-01-05
21:59:14 UTC (rev 3778)
+++
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-01-06
20:06:41 UTC (rev 3779)
@@ -503,8 +503,9 @@
return;
}
super.flushBatchDirect(batch, add);
- //restrict the buffer size for forward only results
- if (add && !processor.hasFinalBuffer()
+ if (!add && !processor.hasFinalBuffer()) {
+ resultsBuffer.setRowCount(batch.getEndRow());
+ } else if (!processor.hasFinalBuffer() //restrict the buffer size for forward only
results
&& !batch.getTerminationFlag()
&& this.getTupleBuffer().getManagedRowCount() >=
OUTPUT_BUFFER_MAX_BATCHES * this.getTupleBuffer().getBatchSize()) {
if (!dqpCore.hasWaitingPlans(RequestWorkItem.this)) {
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-05
21:59:14 UTC (rev 3778)
+++
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-06
20:06:41 UTC (rev 3779)
@@ -333,6 +333,25 @@
assertEquals(100, item.resultsBuffer.getRowCount());
}
+ @Test public void testFinalRow() throws Exception {
+ String sql = "SELECT A.IntKey FROM BQT1.SmallA as A"; //$NON-NLS-1$
+ String userName = "1"; //$NON-NLS-1$
+ String sessionid = "1"; //$NON-NLS-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.getResults().length);
+ RequestWorkItem item =
core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
+ while(item.isProcessing());
+ assertEquals(10, item.resultsBuffer.getRowCount());
+ }
+
@Test public void testBufferReuse1() throws Exception {
//the sql should return 100 rows
String sql = "SELECT IntKey FROM texttable('11\n12\n13\n14\n15'
columns intkey integer) t " +
Show replies by date