Author: shawkins
Date: 2012-09-05 13:59:08 -0400 (Wed, 05 Sep 2012)
New Revision: 4399
Modified:
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
trunk/engine/src/test/java/org/teiid/common/buffer/TestSTree.java
Log:
TEIID-2186 correcting the valid check
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java 2012-09-04
14:10:43 UTC (rev 4398)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java 2012-09-05
17:59:08 UTC (rev 4399)
@@ -53,6 +53,8 @@
private boolean inPartial;
+ private List<Object> cachedBound;
+
private ArrayList<SearchResult> places = new ArrayList<SearchResult>();
/**
@@ -111,7 +113,7 @@
if (!direction) {
values = upper.values;
}
- if (lowerBound != null) {
+ if (lowerBound != null && page == bound) {
valid = index<=boundIndex;
}
} else {
@@ -172,7 +174,12 @@
return null;
}
if (newValue.size() < tree.getKeyLength()) {
- init(new ArrayList<Object>(newValue), newValue, true);
+ if (cachedBound == null) {
+ cachedBound = new ArrayList<Object>(tree.getKeyLength());
+ }
+ cachedBound.clear();
+ cachedBound.addAll(newValue);
+ init(cachedBound, newValue, true);
inPartial = true;
continue;
}
Modified: trunk/engine/src/test/java/org/teiid/common/buffer/TestSTree.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/buffer/TestSTree.java 2012-09-04 14:10:43
UTC (rev 4398)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/TestSTree.java 2012-09-05 17:59:08
UTC (rev 4399)
@@ -25,6 +25,7 @@
import static org.junit.Assert.*;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.junit.Test;
@@ -32,6 +33,8 @@
import org.teiid.common.buffer.impl.BufferFrontedFileStoreCache;
import org.teiid.common.buffer.impl.BufferManagerImpl;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.sql.symbol.ElementSymbol;
@SuppressWarnings({"nls", "unchecked"})
@@ -130,4 +133,28 @@
}
+ @Test public void testSearch() throws TeiidComponentException, TeiidProcessingException
{
+ BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
+ bm.setProcessorBatchSize(1);
+
+ ElementSymbol e1 = new ElementSymbol("x");
+ e1.setType(Integer.class);
+ ElementSymbol e2 = new ElementSymbol("x");
+ e1.setType(Integer.class);
+ List elements = Arrays.asList(e1, e2);
+ STree map = bm.createSTree(elements, "1", 2);
+
+ int size = 1<<16;
+ for (int i = 0; i < size; i++) {
+ assertNull(map.insert(Arrays.asList(i, i), InsertMode.NEW, -1));
+ assertEquals(i + 1, map.getRowCount());
+ }
+ map.compact();
+ for (int i = 0; i < size; i++) {
+ TupleBrowser tb = new TupleBrowser(map, new
CollectionTupleSource(Collections.singletonList(Arrays.asList(i)).iterator()), true);
+ assertNotNull(tb.nextTuple());
+ assertNull(tb.nextTuple());
+ }
+ }
+
}
Show replies by date