[teiid-commits] teiid SVN: r4518 - trunk/engine/src/main/java/org/teiid/query/processor/relational.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Oct 5 10:12:08 EDT 2012


Author: shawkins
Date: 2012-10-05 10:12:08 -0400 (Fri, 05 Oct 2012)
New Revision: 4518

Modified:
   trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java
Log:
TEIID-2171 reusing the existing buffer if possible

Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java	2012-10-05 14:10:27 UTC (rev 4517)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java	2012-10-05 14:12:08 UTC (rev 4518)
@@ -98,7 +98,7 @@
         return currentTuple;
     }
     
-    public void reset() throws TeiidComponentException {
+    public void reset() throws TeiidComponentException, TeiidProcessingException {
         this.getIterator().reset();
         this.getIterator().mark();
         this.currentTuple = null;
@@ -127,17 +127,22 @@
     	return this.getTupleBuffer().getRowCount();
     }
 
-    IndexedTupleSource getIterator() throws TeiidComponentException {
+    IndexedTupleSource getIterator() throws TeiidComponentException, TeiidProcessingException {
         if (this.iterator == null) {
             if (this.buffer != null) {
                 iterator = buffer.createIndexedTupleSource();
             } else {
-                // return a TupleBatch tuplesource iterator
-                BatchIterator bi = new BatchIterator(this.source);
-                if (implicitBuffer != ImplicitBuffer.NONE) {
-                	bi.setBuffer(createSourceTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK);
-                }
-                this.iterator = bi;
+            	if (this.source.hasFinalBuffer()) {
+            		this.buffer = this.source.getFinalBuffer(-1);
+                    iterator = buffer.createIndexedTupleSource();
+            	} else {
+	                // return a TupleBatch tuplesource iterator
+	                BatchIterator bi = new BatchIterator(this.source);
+	                if (implicitBuffer != ImplicitBuffer.NONE) {
+	                	bi.setBuffer(createSourceTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK);
+	                }
+	                this.iterator = bi;
+            	}
             }
         }
         return this.iterator;
@@ -239,7 +244,7 @@
 		this.maxProbeMatch = 1;
 	}
 	
-	public void setMaxProbePosition() throws TeiidComponentException {
+	public void setMaxProbePosition() throws TeiidComponentException, TeiidProcessingException {
 		this.getIterator().setPosition(this.getMaxProbeMatch());
 		this.currentTuple = null;
 	}



More information about the teiid-commits mailing list