Author: shawkins
Date: 2012-01-03 15:04:59 -0500 (Tue, 03 Jan 2012)
New Revision: 3764
Modified:
branches/7.6.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
branches/7.6.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
TEIID-1884 fixing final row count when using foward only
Modified:
branches/7.6.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
---
branches/7.6.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-01-03
19:40:57 UTC (rev 3763)
+++
branches/7.6.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-01-03
20:04:59 UTC (rev 3764)
@@ -536,8 +536,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()
&& transactionState != TransactionState.ACTIVE
&& this.getTupleBuffer().getManagedRowCount() >=
OUTPUT_BUFFER_MAX_BATCHES * this.getTupleBuffer().getBatchSize()) {
Modified:
branches/7.6.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
---
branches/7.6.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-03
19:40:57 UTC (rev 3763)
+++
branches/7.6.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-03
20:04:59 UTC (rev 3764)
@@ -360,6 +360,24 @@
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.getResultsList().size());
+ RequestWorkItem item =
core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
+ assertEquals(10, item.resultsBuffer.getRowCount());
+ }
+
@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 " +
Show replies by date