Author: shawkins
Date: 2011-08-29 15:06:14 -0400 (Mon, 29 Aug 2011)
New Revision: 3431
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
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/service/AutoGenDataService.java
Log:
TEIID-1686 fix for assertionerror in tuplebuffer
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-08-29
18:37:36 UTC (rev 3430)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-08-29
19:06:14 UTC (rev 3431)
@@ -120,11 +120,12 @@
private TupleBuffer buffer;
private boolean forwardOnly;
- public BatchCollector(BatchProducer sourceNode, BufferManager bm, CommandContext
context, boolean fowardOnly) throws TeiidComponentException {
+ public BatchCollector(BatchProducer sourceNode, BufferManager bm, CommandContext
context, boolean forwardOnly) throws TeiidComponentException {
this.sourceNode = sourceNode;
+ this.forwardOnly = forwardOnly;
if (!this.sourceNode.hasFinalBuffer()) {
this.buffer = bm.createTupleBuffer(sourceNode.getOutputElements(),
context.getConnectionID(), TupleSourceType.PROCESSOR);
- this.buffer.setForwardOnly(fowardOnly);
+ this.buffer.setForwardOnly(forwardOnly);
}
}
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2011-08-29
18:37:36 UTC (rev 3430)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2011-08-29
19:06:14 UTC (rev 3431)
@@ -133,7 +133,9 @@
public void closeDirect() {
if(this.output != null) {
- this.output.remove();
+ if (!usingOutput) {
+ this.output.remove();
+ }
this.output = null;
}
this.outputTs = null;
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2011-08-29
18:37:36 UTC (rev 3430)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2011-08-29
19:06:14 UTC (rev 3431)
@@ -95,7 +95,9 @@
public void closeDirect() {
super.closeDirect();
if(this.buffer != null) {
- this.buffer.remove();
+ if (!usingOutput) {
+ this.buffer.remove();
+ }
this.buffer = null;
}
reset();
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 2011-08-29
18:37:36 UTC (rev 3430)
+++
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-08-29
19:06:14 UTC (rev 3431)
@@ -333,6 +333,37 @@
assertEquals(100, 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 " +
+ "union " +
+ "SELECT IntKey FROM bqt1.smalla"; //$NON-NLS-1$
+ String userName = "1"; //$NON-NLS-1$
+ String sessionid = "1"; //$NON-NLS-1$
+ agds.sleep = 500;
+ agds.setUseIntCounter(true);
+ RequestMessage reqMsg = exampleRequestMessage(sql);
+ 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(5, rm.getResults().length);
+
+ message = core.processCursorRequest(reqMsg.getExecutionId(), 6, 5);
+ rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+
+ message = core.processCursorRequest(reqMsg.getExecutionId(), 11, 5);
+ rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+ }
+
@Test public void testSourceConcurrency() throws Exception {
//setup default of 2
agds.setSleep(100);
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2011-08-29
18:37:36 UTC (rev 3430)
+++
branches/7.4.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2011-08-29
19:06:14 UTC (rev 3431)
@@ -59,13 +59,17 @@
public int sleep;
private final AtomicInteger executeCount = new AtomicInteger();
private final AtomicInteger closeCount = new AtomicInteger();
+ private boolean useIntCounter;
-
public AutoGenDataService() {
super("FakeConnector","FakeConnector"); //$NON-NLS-1$
//$NON-NLS-2$
caps = TestOptimizer.getTypicalCapabilities();
}
+ public void setUseIntCounter(boolean useIntCounter) {
+ this.useIntCounter = useIntCounter;
+ }
+
public void setSleep(int sleep) {
this.sleep = sleep;
}
@@ -151,7 +155,7 @@
while(iter.hasNext()) {
SingleElementSymbol symbol = (SingleElementSymbol) iter.next();
Class type = symbol.getType();
- row.add( getValue(type) );
+ row.add( getValue(type, i) );
}
rows[i] = row;
}
@@ -174,11 +178,11 @@
private static final java.sql.Time TIME_VAL = new java.sql.Time(0);
private static final java.sql.Timestamp TIMESTAMP_VAL = new java.sql.Timestamp(0);
- private Object getValue(Class<?> type) {
+ private Object getValue(Class<?> type, int row) {
if(type.equals(DataTypeManager.DefaultDataClasses.STRING)) {
return STRING_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.INTEGER)) {
- return INTEGER_VAL;
+ return useIntCounter?row:INTEGER_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.SHORT)) {
return SHORT_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.LONG)) {
Show replies by date