[teiid/teiid] f210d3: TEIID-2504 adding a limited multi-batch fetch and ...
by shawkins
Branch: refs/heads/master
Home: https://github.com/teiid/teiid
Commit: f210d360561cbde9ac2088f3e5de3e1c48a547cc
https://github.com/teiid/teiid/commit/f210d360561cbde9ac2088f3e5de3e1c48a...
Author: shawkins <shawkins(a)redhat.com>
Date: 2013-05-15 (Wed, 15 May 2013)
Changed paths:
M build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
M client/src/main/java/org/teiid/client/RequestMessage.java
M client/src/main/java/org/teiid/client/ResultsMessage.java
M client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
M client/src/main/java/org/teiid/jdbc/StatementImpl.java
M client/src/main/java/org/teiid/net/ServerConnection.java
M client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
M client/src/test/java/org/teiid/client/TestRequestMessage.java
M client/src/test/java/org/teiid/jdbc/TestResultSet.java
M engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
M engine/src/test/java/org/teiid/dqp/message/TestResultsMessage.java
M engine/src/test/java/org/teiid/query/processor/TestRowBasedSecurity.java
M runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
Log Message:
-----------
TEIID-2504 adding a limited multi-batch fetch and a prefetch that can be
run before full deserialization
11 years, 5 months
teiid SVN: r4567 - in branches/7.7.x/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2013-05-14 15:02:36 -0400 (Tue, 14 May 2013)
New Revision: 4567
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java
Log:
TEIID-2455: fix for unrelated sort of view
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2013-05-14 16:35:36 UTC (rev 4566)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2013-05-14 19:02:36 UTC (rev 4567)
@@ -44,10 +44,10 @@
import org.teiid.query.optimizer.relational.OptimizerRule;
import org.teiid.query.optimizer.relational.RuleStack;
import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.optimizer.relational.plantree.NodeEditor;
import org.teiid.query.optimizer.relational.plantree.NodeFactory;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
-import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.processor.relational.RelationalNode;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Criteria;
@@ -203,6 +203,7 @@
break;
}
default: {
+ PlanNode sortNode = null;
if (root.getType() == NodeConstants.Types.PROJECT) {
GroupSymbol intoGroup = (GroupSymbol)root.getProperty(NodeConstants.Info.INTO_GROUP);
if (intoGroup != null) { //if this is a project into, treat the nodes under the source as a new plan root
@@ -211,28 +212,13 @@
return;
}
List<SingleElementSymbol> projectCols = outputElements;
- boolean modifiedProject = false;
- PlanNode sortNode = NodeEditor.findParent(root, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
- if (sortNode != null && sortNode.hasBooleanProperty(NodeConstants.Info.UNRELATED_SORT)) {
- //if this is the initial rule run, remove unrelated order before changing the project cols
- if (!finalRun) {
- OrderBy elements = (OrderBy) sortNode.getProperty(NodeConstants.Info.SORT_ORDER);
- projectCols = new ArrayList<SingleElementSymbol>(projectCols);
- for (OrderByItem item : elements.getOrderByItems()) {
- if (item.getExpressionPosition() == -1) {
- projectCols.remove(item.getSymbol());
- }
- }
- } else {
- modifiedProject = true;
- }
+ sortNode = NodeEditor.findParent(root, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
+ if (finalRun && sortNode != null && sortNode.hasBooleanProperty(NodeConstants.Info.UNRELATED_SORT)) {
+ root.getGroups().clear();
+ root.addGroups(GroupsUsedByElementsVisitor.getGroups(projectCols));
+ root.addGroups(GroupsUsedByElementsVisitor.getGroups(root.getCorrelatedReferenceElements()));
}
root.setProperty(NodeConstants.Info.PROJECT_COLS, projectCols);
- if (modifiedProject) {
- root.getGroups().clear();
- root.addGroups(GroupsUsedByElementsVisitor.getGroups(projectCols));
- root.addGroups(GroupsUsedByElementsVisitor.getGroups(root.getCorrelatedReferenceElements()));
- }
if (root.hasBooleanProperty(Info.HAS_WINDOW_FUNCTIONS)) {
Set<WindowFunction> windowFunctions = getWindowFunctions(projectCols);
if (windowFunctions.isEmpty()) {
@@ -275,6 +261,17 @@
// Call children recursively
if(root.getChildCount() == 1) {
assignOutputElements(root.getLastChild(), requiredInput, metadata, capFinder, rules, analysisRecord, context);
+ if (!finalRun && root.getType() == NodeConstants.Types.PROJECT && sortNode != null && sortNode.hasBooleanProperty(NodeConstants.Info.UNRELATED_SORT)) {
+ //if this is the initial rule run, remove unrelated order to preserve the original projection
+ OrderBy elements = (OrderBy) sortNode.getProperty(NodeConstants.Info.SORT_ORDER);
+ outputElements = new ArrayList<SingleElementSymbol>(outputElements);
+ for (OrderByItem item : elements.getOrderByItems()) {
+ if (item.getExpressionPosition() == -1) {
+ outputElements.remove(item.getSymbol());
+ }
+ }
+ root.setProperty(NodeConstants.Info.PROJECT_COLS, outputElements);
+ }
} else {
//determine which elements go to each side of the join
for (PlanNode childNode : root.getChildren()) {
@@ -406,7 +403,7 @@
boolean updateGroups = outputColumns.size() != originalOrder.size();
boolean[] seenIndex = new boolean[outputColumns.size()];
boolean newSymbols = false;
-
+ int newSymbolIndex = 0;
for (int i = 0; i < outputColumns.size(); i++) {
Expression expr = outputColumns.get(i);
filteredIndex[i] = originalOrder.indexOf(expr);
@@ -414,6 +411,8 @@
updateGroups = true;
//we're adding this symbol, which needs to be updated against respective symbol maps
newSymbols = true;
+ } else {
+ newSymbolIndex++;
}
if (!updateGroups) {
seenIndex[filteredIndex[i]] = true;
@@ -445,7 +444,7 @@
SingleElementSymbol ex = (SingleElementSymbol) outputColumns.get(j).clone();
ExpressionMappingVisitor.mapExpressions(ex, childMap.asMap());
newCols.set(j, ex);
- filteredIndex[j] = j;
+ filteredIndex[j] = newSymbolIndex++;
}
}
@@ -471,7 +470,10 @@
List<Expression> originalExpressionOrder = symbolMap.getValues();
for (int i = 0; i < filteredIndex.length; i++) {
- newMap.addMapping(originalOrder.get(filteredIndex[i]), originalExpressionOrder.get(filteredIndex[i]));
+ if (filteredIndex[i] < originalOrder.size()) {
+ newMap.addMapping(originalOrder.get(filteredIndex[i]), originalExpressionOrder.get(filteredIndex[i]));
+ }
+ //else TODO: we may need to create a fake symbol
}
sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, newMap);
}
@@ -621,10 +623,10 @@
requiredSymbols.addAll(tempRequired);
*/
// Add any columns to required that are in this node's output but were not created here
- for (SingleElementSymbol currentOutputSymbol : outputCols) {
- if(!(createdSymbols.contains(currentOutputSymbol)) ) {
- requiredSymbols.add(currentOutputSymbol);
- }
+ for (Expression currentOutputSymbol : outputCols) {
+ if (!createdSymbols.contains(currentOutputSymbol) && (finalRun || node.getType() != NodeConstants.Types.PROJECT || currentOutputSymbol instanceof ElementSymbol)) {
+ requiredSymbols.add((SingleElementSymbol) currentOutputSymbol);
+ }
}
//further minimize the required symbols based upon underlying expression (accounts for aliasing)
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java 2013-05-14 16:35:36 UTC (rev 4566)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOrderByProcessing.java 2013-05-14 19:02:36 UTC (rev 4567)
@@ -205,5 +205,24 @@
ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select e1 from pm1.g1 order by e1 desc, e2 asc", metadata, null), metadata, capFinder, null, true, cc);
TestOptimizer.checkAtomicQueries(new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC NULLS LAST, g_0.e2 NULLS FIRST"}, plan); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
+ }
+
+ @Test public void testSortFunctionOverView() {
+ String sql = "select * from (select * from pm1.g1) as x order by cast(e2 as string) limit 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
+ FakeDataManager fdm = new FakeDataManager();
+ sampleData1(fdm);
+ helpProcess(plan, fdm, new List[] {Arrays.asList("a", 0, false, 2.0d)});
+ }
+
+ @Test public void testSortFunctionOverView1() {
+ String sql = "select e1 from (select * from pm1.g1) as x order by cast(e3 as string) desc, cast(e2 as string) limit 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
+ FakeDataManager fdm = new FakeDataManager();
+ sampleData1(fdm);
+ helpProcess(plan, fdm, new List[] {Arrays.asList("c")});
+ }
+
}
11 years, 5 months
teiid SVN: r4566 - in branches/7.7.x: engine/src/main/java/org/teiid/common/buffer/impl and 4 other directories.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2013-05-14 12:35:36 -0400 (Tue, 14 May 2013)
New Revision: 4566
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/Cache.java
branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferFrontedFileStoreCache.java
branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/MemoryStorageManager.java
branches/7.7.x/engine/src/main/resources/org/teiid/query/i18n.properties
branches/7.7.x/engine/src/test/java/org/teiid/common/buffer/BufferManagerFactory.java
branches/7.7.x/engine/src/test/java/org/teiid/common/buffer/impl/TestBufferFrontedFileStoreCache.java
branches/7.7.x/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
Log:
TEIID-2460: Weird behavior when Max buffer space restriction is hit
Modified: branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/Cache.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/Cache.java 2013-05-14 15:12:39 UTC (rev 4565)
+++ branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/Cache.java 2013-05-14 16:35:36 UTC (rev 4566)
@@ -51,8 +51,9 @@
* Must be called prior to adding an entry
* @param gid
* @param oid
+ * @return if the add was successful
*/
- void addToCacheGroup(Long gid, Long oid);
+ boolean addToCacheGroup(Long gid, Long oid);
/**
* Lock the object for load and return an identifier/lock
Modified: branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferFrontedFileStoreCache.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferFrontedFileStoreCache.java 2013-05-14 15:12:39 UTC (rev 4565)
+++ branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferFrontedFileStoreCache.java 2013-05-14 16:35:36 UTC (rev 4566)
@@ -495,6 +495,7 @@
private AtomicLong storageReads = new AtomicLong();
private long minDefrag = DEFAULT_MIN_DEFRAG;
+ private BufferManagerImpl bufferManager;
@Override
public void initialize() throws TeiidComponentException {
@@ -815,12 +816,13 @@
}
@Override
- public void addToCacheGroup(Long gid, Long oid) {
+ public boolean addToCacheGroup(Long gid, Long oid) {
Map<Long, PhysicalInfo> map = physicalMapping.get(gid);
if (map == null) {
- return;
+ return false;
}
map.put(oid, null);
+ return true;
}
@Override
@@ -905,7 +907,11 @@
block = blockStore.writeToStorageBlock(info, is);
}
} catch (IOException e) {
- LogManager.logError(LogConstants.CTX_BUFFER_MGR, e, "Error transferring block to storage " + oid); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logError(LogConstants.CTX_BUFFER_MGR, e, "Error transferring block to storage " + oid + " " + info.gid); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ LogManager.logError(LogConstants.CTX_BUFFER_MGR, "Error transferring block to storage " + oid + " " + info.gid + " " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
} finally {
//ensure post conditions
synchronized (info) {
@@ -950,6 +956,10 @@
freedLock.unlock();
}
}
+ if (block == EMPTY_ADDRESS && demote && this.bufferManager != null) {
+ //failed to demote
+ this.bufferManager.invalidCacheGroup(info.gid);
+ }
}
}
return result;
@@ -1083,5 +1093,9 @@
public int getMaxMemoryBlocks() {
return maxMemoryBlocks;
}
+
+ public void setBufferManager(BufferManagerImpl bufferManager) {
+ this.bufferManager = bufferManager;
+ }
}
\ No newline at end of file
Modified: branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2013-05-14 15:12:39 UTC (rev 4565)
+++ branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2013-05-14 16:35:36 UTC (rev 4566)
@@ -54,12 +54,13 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.DataTypeManager.WeakReferenceHashedValueCache;
import org.teiid.core.types.Streamable;
-import org.teiid.core.types.DataTypeManager.WeakReferenceHashedValueCache;
import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.QueryPlugin;
import org.teiid.query.processor.relational.ListNestedSortComparator;
import org.teiid.query.sql.symbol.Expression;
@@ -205,7 +206,10 @@
}
maxReserveBytes.addAndGet(-BATCH_OVERHEAD);
reserveBatchBytes.addAndGet(-BATCH_OVERHEAD);
- cache.addToCacheGroup(id, ce.getId());
+ if (!cache.addToCacheGroup(id, ce.getId())) {
+ this.remove();
+ throw new TeiidComponentException(QueryPlugin.Util.getString("TEIID31138", id));
+ }
addMemoryEntry(ce, true);
return oid;
}
@@ -769,7 +773,7 @@
/**
* Get a CacheEntry without hitting storage
*/
- CacheEntry fastGet(Long batch, boolean prefersMemory, boolean retain) {
+ CacheEntry fastGet(Long batch, Boolean prefersMemory, boolean retain) {
CacheEntry ce = null;
if (retain) {
ce = memoryEntries.get(batch);
@@ -793,7 +797,7 @@
}
return ce;
}
- if (prefersMemory) {
+ if (prefersMemory == null || prefersMemory) {
BatchSoftReference bsr = softCache.remove(batch);
if (bsr != null) {
ce = bsr.get();
@@ -801,7 +805,8 @@
clearSoftReference(bsr);
}
}
- } else if (useWeakReferences) {
+ }
+ if (ce == null && (prefersMemory == null || !prefersMemory) && useWeakReferences) {
ce = weakReferenceCache.getByHash(batch);
if (ce == null || !ce.getId().equals(batch)) {
return null;
@@ -861,7 +866,7 @@
activeBatchBytes.getAndAdd(ce.getSizeEstimate());
}
- void removeCacheGroup(Long id, boolean prefersMemory) {
+ void removeCacheGroup(Long id, Boolean prefersMemory) {
cleanSoftReferences();
Collection<Long> vals = cache.removeCacheGroup(id);
long overhead = vals.size() * BATCH_OVERHEAD;
@@ -993,5 +998,9 @@
byte[] bytes) throws TeiidComponentException {
return LobManager.persistLob(lob, store, bytes, inlineLobs, DataTypeManager.MAX_LOB_MEMORY_BYTES);
}
+
+ public void invalidCacheGroup(Long gid) {
+ removeCacheGroup(gid, null);
+ }
}
Modified: branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/MemoryStorageManager.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/MemoryStorageManager.java 2013-05-14 15:12:39 UTC (rev 4565)
+++ branches/7.7.x/engine/src/main/java/org/teiid/common/buffer/impl/MemoryStorageManager.java 2013-05-14 16:35:36 UTC (rev 4566)
@@ -121,11 +121,13 @@
}
@Override
- public void addToCacheGroup(Long gid, Long oid) {
+ public boolean addToCacheGroup(Long gid, Long oid) {
Map<Long, CacheEntry> group = groups.get(gid);
if (group != null) {
group.put(oid, null);
+ return true;
}
+ return false;
}
@Override
Modified: branches/7.7.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.7.x/engine/src/main/resources/org/teiid/query/i18n.properties 2013-05-14 15:12:39 UTC (rev 4565)
+++ branches/7.7.x/engine/src/main/resources/org/teiid/query/i18n.properties 2013-05-14 16:35:36 UTC (rev 4566)
@@ -952,4 +952,5 @@
invalid_schema=Invalid schema from translator metadata expected {0}, but the returned MetadataStore contained no such schema or more than 1 schema.
invalid_table=Invalid table {0}. A table must have 1 or more columns.
-query_timeout=Cancelling query {0} since it has exceeded the timeout of {1} milliseconds.
\ No newline at end of file
+query_timeout=Cancelling query {0} since it has exceeded the timeout of {1} milliseconds.
+TEIID31138=Cannot add batch to invalidated cache group "{1}". Check prior logs to see if there was an error persisting a batch.
\ No newline at end of file
Modified: branches/7.7.x/engine/src/test/java/org/teiid/common/buffer/BufferManagerFactory.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/common/buffer/BufferManagerFactory.java 2013-05-14 15:12:39 UTC (rev 4565)
+++ branches/7.7.x/engine/src/test/java/org/teiid/common/buffer/BufferManagerFactory.java 2013-05-14 16:35:36 UTC (rev 4566)
@@ -86,6 +86,7 @@
SplittableStorageManager ssm = new SplittableStorageManager(storageManager);
ssm.setMaxFileSizeDirect(MemoryStorageManager.MAX_FILE_SIZE);
BufferFrontedFileStoreCache fsc = new BufferFrontedFileStoreCache();
+ fsc.setBufferManager(bufferManager);
//use conservative allocations
fsc.setDirect(false); //allow the space to be GCed easily
fsc.setMaxStorageObjectSize(1<<20);
Modified: branches/7.7.x/engine/src/test/java/org/teiid/common/buffer/impl/TestBufferFrontedFileStoreCache.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/common/buffer/impl/TestBufferFrontedFileStoreCache.java 2013-05-14 15:12:39 UTC (rev 4565)
+++ branches/7.7.x/engine/src/test/java/org/teiid/common/buffer/impl/TestBufferFrontedFileStoreCache.java 2013-05-14 16:35:36 UTC (rev 4566)
@@ -30,8 +30,11 @@
import java.lang.ref.WeakReference;
import org.junit.Test;
+import org.mockito.Mockito;
import org.teiid.common.buffer.CacheEntry;
+import org.teiid.common.buffer.FileStore;
import org.teiid.common.buffer.Serializer;
+import org.teiid.common.buffer.StorageManager;
import org.teiid.core.TeiidComponentException;
public class TestBufferFrontedFileStoreCache {
@@ -68,7 +71,7 @@
}
@Test public void testAddGetMultiBlock() throws Exception {
- BufferFrontedFileStoreCache cache = createLayeredCache(1 << 26, 1 << 26);
+ BufferFrontedFileStoreCache cache = createLayeredCache(1 << 26, 1 << 26, true);
CacheEntry ce = new CacheEntry(2l);
Serializer<Integer> s = new SimpleSerializer();
@@ -147,7 +150,7 @@
}
@Test public void testEviction() throws Exception {
- BufferFrontedFileStoreCache cache = createLayeredCache(1<<15, 1<<15);
+ BufferFrontedFileStoreCache cache = createLayeredCache(1<<15, 1<<15, true);
assertEquals(3, cache.getMaxMemoryBlocks());
CacheEntry ce = new CacheEntry(2l);
@@ -176,15 +179,77 @@
ce = get(cache, 3l, s);
assertEquals(Integer.valueOf(5001), ce.getObject());
}
+
+ @Test public void testEvictionFails() throws Exception {
+ BufferFrontedFileStoreCache cache = createLayeredCache(1<<15, 1<<15, false);
+ BufferManagerImpl bmi = Mockito.mock(BufferManagerImpl.class);
+ cache.setBufferManager(bmi);
+ Serializer<Integer> s = new SimpleSerializer();
+ WeakReference<? extends Serializer<?>> ref = new WeakReference<Serializer<?>>(s);
+ cache.createCacheGroup(s.getId());
+
+ for (int i = 0; i < 3; i++) {
+ add(cache, s, ref, i);
+ }
+ Mockito.verify(bmi, Mockito.atLeastOnce()).invalidCacheGroup(Long.valueOf(1));
+ }
- private static BufferFrontedFileStoreCache createLayeredCache(int bufferSpace, int objectSize) throws TeiidComponentException {
+ private void add(BufferFrontedFileStoreCache cache, Serializer<Integer> s,
+ WeakReference<? extends Serializer<?>> ref, int i) {
+ CacheEntry ce = new CacheEntry(Long.valueOf(i));
+ ce.setSerializer(ref);
+ Integer cacheObject = Integer.valueOf(5000 + i);
+ ce.setObject(cacheObject);
+ cache.addToCacheGroup(s.getId(), ce.getId());
+ cache.add(ce, s);
+ }
+
+ private static BufferFrontedFileStoreCache createLayeredCache(int bufferSpace, int objectSize, boolean memStorage) throws TeiidComponentException {
BufferFrontedFileStoreCache fsc = new BufferFrontedFileStoreCache();
fsc.setMemoryBufferSpace(bufferSpace);
fsc.setMaxStorageObjectSize(objectSize);
fsc.setDirect(false);
- SplittableStorageManager ssm = new SplittableStorageManager(new MemoryStorageManager());
- ssm.setMaxFileSizeDirect(MemoryStorageManager.MAX_FILE_SIZE);
- fsc.setStorageManager(ssm);
+ if (memStorage) {
+ SplittableStorageManager ssm = new SplittableStorageManager(new MemoryStorageManager());
+ ssm.setMaxFileSizeDirect(MemoryStorageManager.MAX_FILE_SIZE);
+ fsc.setStorageManager(ssm);
+ } else {
+ StorageManager sm = new StorageManager() {
+
+ @Override
+ public void initialize() throws TeiidComponentException {
+
+ }
+
+ @Override
+ public FileStore createFileStore(String name) {
+ return new FileStore() {
+
+ @Override
+ public void setLength(long length) throws IOException {
+ throw new IOException();
+ }
+
+ @Override
+ protected void removeDirect() {
+
+ }
+
+ @Override
+ protected int readWrite(long fileOffset, byte[] b, int offSet, int length,
+ boolean write) throws IOException {
+ return 0;
+ }
+
+ @Override
+ public long getLength() {
+ return 0;
+ }
+ };
+ }
+ };
+ fsc.setStorageManager(sm);
+ }
fsc.initialize();
return fsc;
}
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
===================================================================
--- branches/7.7.x/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2013-05-14 15:12:39 UTC (rev 4565)
+++ branches/7.7.x/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2013-05-14 16:35:36 UTC (rev 4566)
@@ -110,6 +110,7 @@
SplittableStorageManager ssm = new SplittableStorageManager(fsm);
ssm.setMaxFileSize(maxFileSize);
BufferFrontedFileStoreCache fsc = new BufferFrontedFileStoreCache();
+ fsc.setBufferManager(this.bufferMgr);
fsc.setMaxStorageObjectSize(maxStorageObjectSize);
fsc.setDirect(memoryBufferOffHeap);
int batchOverheadKB = (int)(this.memoryBufferSpace<0?(this.bufferMgr.getMaxReserveKB()<<8):this.memoryBufferSpace)>>20;
11 years, 5 months
teiid SVN: r4565 - in branches/7.7.x/engine/src: test/java/org/teiid/query/processor/relational and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2013-05-14 11:12:39 -0400 (Tue, 14 May 2013)
New Revision: 4565
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
Log:
TEIID-2363: proactive buffering not occurring for the inner side of an outer join on "MERGE JOIN (SORT/ALREADY_SORTED)"
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2013-05-14 14:53:25 UTC (rev 4564)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2013-05-14 15:12:39 UTC (rev 4565)
@@ -170,63 +170,61 @@
return clonedNode;
}
- /**
- * @see org.teiid.query.processor.relational.RelationalNode#nextBatchDirect()
- * @since 4.2
- */
- protected TupleBatch nextBatchDirect() throws BlockedException,
- TeiidComponentException, TeiidProcessingException {
- try {
- if (state == State.LOAD_LEFT) {
- if (this.joinType != JoinType.JOIN_FULL_OUTER) {
- this.joinStrategy.leftSource
- .setImplicitBuffer(ImplicitBuffer.NONE);
- }
- // left child was already opened by the join node
- this.joinStrategy.loadLeft();
- if (isDependent()) {
- TupleBuffer buffer = this.joinStrategy.leftSource
- .getTupleBuffer();
- // the tuplebuffer may be from a lower node, so pass in the
- // schema
- dvs = new DependentValueSource(buffer);
- dvs.setDistinct(this.joinStrategy.leftSource.isDistinct());
- this.getContext().getVariableContext()
- .setGlobalValue(this.dependentValueSource, dvs);
- }
- state = State.LOAD_RIGHT;
- }
- } catch (BlockedException e) {
- if (!isDependent()) {
- this.joinStrategy.openRight();
- this.joinStrategy.loadRight();
- }
- throw e;
- }
- try {
- if (state == State.LOAD_RIGHT) {
- this.joinStrategy.openRight();
- this.joinStrategy.loadRight();
- state = State.EXECUTE;
- }
- this.joinStrategy.process();
- this.terminateBatches();
- } catch (BatchAvailableException e) {
- // pull the batch
- } catch (BlockedException e) {
- // TODO: this leads to duplicate exceptions, we
- // could track which side is blocking
- try {
- this.joinStrategy.leftSource.prefetch(true);
- } catch (BlockedException e1) {
+ /**
+ * @see org.teiid.query.processor.relational.RelationalNode#nextBatchDirect()
+ * @since 4.2
+ */
+ protected TupleBatch nextBatchDirect() throws BlockedException,
+ TeiidComponentException,
+ TeiidProcessingException {
+ try {
+ if (state == State.LOAD_LEFT) {
+ if (this.joinType != JoinType.JOIN_FULL_OUTER) {
+ this.joinStrategy.leftSource.setImplicitBuffer(ImplicitBuffer.NONE);
+ }
+ //left child was already opened by the join node
+ this.joinStrategy.loadLeft();
+ if (isDependent()) {
+ TupleBuffer buffer = this.joinStrategy.leftSource.getTupleBuffer();
+ //the tuplebuffer may be from a lower node, so pass in the schema
+ dvs = new DependentValueSource(buffer);
+ dvs.setDistinct(this.joinStrategy.leftSource.isDistinct());
+ this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, dvs);
+ }
+ state = State.LOAD_RIGHT;
+ }
+ } catch (BlockedException e) {
+ if (!isDependent()) {
+ this.joinStrategy.openRight();
+ this.joinStrategy.loadRight();
+ this.joinStrategy.rightSource.prefetch(true);
+ }
+ throw e;
+ }
+ try {
+ if (state == State.LOAD_RIGHT) {
+ this.joinStrategy.openRight();
+ this.joinStrategy.loadRight();
+ state = State.EXECUTE;
+ }
+ this.joinStrategy.process();
+ this.terminateBatches();
+ } catch (BatchAvailableException e) {
+ //pull the batch
+ } catch (BlockedException e) {
+ //TODO: this leads to duplicate exceptions, we
+ //could track which side is blocking
+ try {
+ this.joinStrategy.leftSource.prefetch(true);
+ } catch (BlockedException e1) {
+
+ }
+ this.joinStrategy.rightSource.prefetch(true);
+ throw e;
+ }
+ return pullBatch();
+ }
- }
- this.joinStrategy.rightSource.prefetch(true);
- throw e;
- }
- return pullBatch();
- }
-
/**
* @see org.teiid.query.processor.relational.RelationalNode#getDescriptionProperties()
* @since 4.2
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2013-05-14 14:53:25 UTC (rev 4564)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2013-05-14 15:12:39 UTC (rev 4565)
@@ -69,7 +69,7 @@
protected JoinNode join;
protected JoinStrategy joinStrategy;
- private RelationalNode leftNode;
+ private BlockingFakeRelationalNode leftNode;
private RelationalNode rightNode;
private FakeDataManager dataMgr;
@@ -791,6 +791,52 @@
this.join.setJoinStrategy(joinStrategy);
helpTestJoinDirect(expected, 40, 1);
}
+
+ @Test public void testMergeJoinPrefetchAlreadySorted() throws Exception {
+ this.joinType = JoinType.JOIN_INNER;
+ int rows = 50;
+ List[] data = new List[rows];
+ for(int i=0; i<rows; i++) {
+ data[i] = new ArrayList();
+ Integer value = new Integer((i*17) % 47);
+ data[i].add(value);
+ }
+ this.leftTuples = data;
+ this.rightTuples = new List[] {
+ Arrays.asList(1),
+ Arrays.asList(2),
+ Arrays.asList(4),
+ Arrays.asList(6),
+ Arrays.asList(7),
+ Arrays.asList(8),
+ };
+ expected = new List[] {
+ Arrays.asList(new Object[] { 1, 1 }),
+ Arrays.asList(new Object[] { 2, 2 }),
+ Arrays.asList(new Object[] { 4, 4 }),
+ Arrays.asList(new Object[] { 6, 6 }),
+ Arrays.asList(new Object[] { 7, 7 }),
+ Arrays.asList(new Object[] { 8, 8 }),
+ };
+ helpCreateJoin();
+ this.joinStrategy = new MergeJoinStrategy(SortOption.SORT, SortOption.ALREADY_SORTED, false);
+ FakeRelationalNode newNode = new FakeRelationalNode(2, rightTuples) {
+ @Override
+ public TupleBatch nextBatchDirect() throws BlockedException,
+ TeiidComponentException, TeiidProcessingException {
+ TupleBatch tb = super.nextBatchDirect();
+ if (tb.getTerminationFlag()) {
+ assertFalse(leftNode.isClosed());
+ }
+ return tb;
+ }
+ };
+ newNode.setElements(rightNode.getElements());
+ rightNode = newNode;
+
+ this.join.setJoinStrategy(joinStrategy);
+ helpTestJoinDirect(expected, 5, 1);
+ }
@Test public void testRepeatedMerge() throws Exception {
helpTestRepeatedMerge(false);
11 years, 5 months
teiid SVN: r4564 - in branches/7.7.x: engine/src/main/java/org/teiid/query/processor/relational and 3 other directories.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2013-05-14 10:53:25 -0400 (Tue, 14 May 2013)
New Revision: 4564
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
branches/7.7.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java
Log:
TEIID-2482: Allow the use of the enhanced join for left outer joins
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2013-05-08 18:29:01 UTC (rev 4563)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2013-05-14 14:53:25 UTC (rev 4564)
@@ -42,13 +42,13 @@
import org.teiid.query.optimizer.relational.OptimizerRule;
import org.teiid.query.optimizer.relational.RuleStack;
import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.optimizer.relational.plantree.NodeEditor;
import org.teiid.query.optimizer.relational.plantree.NodeFactory;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
-import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
-import org.teiid.query.processor.relational.RelationalNode;
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
+import org.teiid.query.processor.relational.RelationalNode;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.CompoundCriteria;
import org.teiid.query.sql.lang.Criteria;
@@ -202,8 +202,8 @@
}
boolean pushedRight = insertSort(joinNode.getLastChild(), rightExpressions, joinNode, metadata, capabilitiesFinder, pushRight);
-
- if (joinNode.getProperty(NodeConstants.Info.JOIN_TYPE) == JoinType.JOIN_INNER && (!pushedRight || !pushedLeft)) {
+ JoinType joinType = (JoinType) joinNode.getProperty(NodeConstants.Info.JOIN_TYPE);
+ if ((!pushedRight || !pushedLeft) && (joinType == JoinType.JOIN_INNER || (joinType == JoinType.JOIN_LEFT_OUTER && !pushedLeft))) {
joinNode.setProperty(NodeConstants.Info.JOIN_STRATEGY, JoinStrategyType.ENHANCED_SORT);
}
}
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java 2013-05-08 18:29:01 UTC (rev 4563)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java 2013-05-14 14:53:25 UTC (rev 4564)
@@ -41,6 +41,7 @@
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.query.processor.relational.SourceState.ImplicitBuffer;
+import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.SingleElementSymbol;
@@ -100,6 +101,7 @@
private SourceState sortedSource;
private SourceState notSortedSource;
private List<?> currentTuple;
+ private boolean matched;
private TupleBrowser tb;
private SingleTupleSource keyTs;
private int reserved;
@@ -240,14 +242,14 @@
protected void loadRight() throws TeiidComponentException,
TeiidProcessingException {
//the checks are done in a particular order to ensure we don't buffer if possible
- if (processingSortRight == SortOption.SORT && shouldIndexIfSmall(this.leftSource)) {
+ if (processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && shouldIndexIfSmall(this.leftSource)) {
this.processingSortRight = SortOption.NOT_SORTED;
} else if (!this.leftSource.hasBuffer() && processingSortLeft == SortOption.SORT && shouldIndexIfSmall(this.rightSource)) {
this.processingSortLeft = SortOption.NOT_SORTED;
} else {
- if (!this.rightSource.hasBuffer() && processingSortRight == SortOption.SORT && shouldIndexIfSmall(this.leftSource)) {
+ if (!this.rightSource.hasBuffer() && processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && shouldIndexIfSmall(this.leftSource)) {
this.processingSortRight = SortOption.NOT_SORTED;
- } else if (processingSortRight == SortOption.SORT && shouldIndex(this.leftSource, this.rightSource)) {
+ } else if (processingSortRight == SortOption.SORT && this.joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER && shouldIndex(this.leftSource, this.rightSource)) {
this.processingSortRight = SortOption.NOT_SORTED;
} else if (processingSortLeft == SortOption.SORT && shouldIndex(this.rightSource, this.leftSource)) {
this.processingSortLeft = SortOption.NOT_SORTED;
@@ -302,15 +304,34 @@
}
private boolean shouldIndex(SourceState possibleIndex, SourceState other) throws TeiidComponentException, TeiidProcessingException {
- if (possibleIndex.getRowCount() * 4 > other.getRowCount()) {
+ long size = joinNode.getBatchSize();
+ int indexSize = possibleIndex.hasBuffer()?possibleIndex.getRowCount():-1;
+ int otherSize = other.hasBuffer()?other.getRowCount():-1;
+ //determine sizes in an incremental fashion as to avoid a full buffer of the unsorted side
+ while (size < Integer.MAX_VALUE && (indexSize == -1 || otherSize == -1)) {
+ if (indexSize == -1 && (possibleIndex.rowCountLE((int)size) || possibleIndex.hasBuffer())) {
+ indexSize = possibleIndex.getRowCount();
+ }
+ if (otherSize == -1 && (other.rowCountLE((int)size) || other.hasBuffer())) {
+ otherSize = other.getRowCount();
+ }
+ if (indexSize == -1 && otherSize != -1 && size * 4 > otherSize) {
+ return false;
+ }
+ if (indexSize != -1 && otherSize == -1 && indexSize * 4 <= size) {
+ break;
+ }
+ size *=2;
+ }
+ if ((size > Integer.MAX_VALUE && (indexSize == -1 || otherSize == -1)) || (indexSize != -1 && otherSize != -1 && indexSize * 4 > otherSize)) {
return false; //index is too large
}
int schemaSize = this.joinNode.getBufferManager().getSchemaSize(other.getSource().getOutputElements());
int toReserve = this.joinNode.getBufferManager().getMaxProcessingSize();
//check if the other side can be sorted in memory
- if (other.getRowCount() <= this.joinNode.getBatchSize()
- || (possibleIndex.getRowCount() > this.joinNode.getBatchSize() && other.getRowCount()/this.joinNode.getBatchSize() < toReserve/schemaSize)) {
- return false;
+ if (other.hasBuffer() && ((other.getRowCount() <= this.joinNode.getBatchSize())
+ || (possibleIndex.getRowCount() > this.joinNode.getBatchSize() && other.getRowCount()/this.joinNode.getBatchSize() < toReserve/schemaSize))) {
+ return false; //just use a merge join
}
boolean useIndex = false;
int indexSchemaSize = this.joinNode.getBufferManager().getSchemaSize(possibleIndex.getSource().getOutputElements());
@@ -323,8 +344,14 @@
}
if (useIndex) {
reserved = this.joinNode.getBufferManager().reserveBuffers(toReserve, BufferReserveMode.FORCE);
+ if (other.hasBuffer()) {
+ other.getTupleBuffer().setForwardOnly(true);
+ }
return true;
}
+ if (joinNode.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
+ return false; //repeated is not supported as it could produce multiple outer matches
+ }
this.repeatedMerge = true;
possibleIndex.setImplicitBuffer(ImplicitBuffer.FULL);
return true;
@@ -342,7 +369,7 @@
super.process();
return;
}
- if (this.sortedSource.getRowCount() == 0) {
+ if (this.sortedSource.getRowCount() == 0 && joinNode.getJoinType() != JoinType.JOIN_LEFT_OUTER) {
return;
}
if (repeatedMerge) {
@@ -361,9 +388,15 @@
while (true) {
if (this.currentTuple == null) {
currentTuple = this.currentSource.nextTuple();
+ matched = false;
if (currentTuple == null) {
return;
}
+ //short-cut when a match is not possible
+ if (this.sortedSource.getRowCount() == 0 && joinNode.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
+ outerMatch();
+ continue;
+ }
if (validSemiDep) {
List<?> tuple = this.currentTuple;
this.currentTuple = null;
@@ -377,7 +410,7 @@
sortedTuple = tb.nextTuple();
if (sortedTuple == null) {
- currentTuple = null;
+ outerMatch();
continue;
}
}
@@ -387,10 +420,19 @@
boolean matches = this.joinNode.matchesCriteria(outputTuple);
this.sortedTuple = null;
if (matches) {
+ matched = true;
this.joinNode.addBatchRow(outputTuple);
}
}
}
+
+ private void outerMatch() {
+ List<?> tuple = currentTuple;
+ currentTuple = null;
+ if (!matched && joinNode.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
+ this.joinNode.addBatchRow(outputTuple(tuple, this.rightSource.getOuterVals()));
+ }
+ }
@Override
public EnhancedSortMergeJoinStrategy clone() {
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java 2013-05-08 18:29:01 UTC (rev 4563)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java 2013-05-14 14:53:25 UTC (rev 4564)
@@ -26,10 +26,9 @@
import java.util.List;
import org.junit.Test;
-import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.unittest.RealMetadataFactory;
-
+@SuppressWarnings("rawtypes")
public class TestOptionalJoins {
@Test public void testOptionalJoinNode1() {
@@ -134,10 +133,10 @@
@Test public void testOptionalJoinNode5() {
// Create query
- String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
+ String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1 order by e1"; //$NON-NLS-1$
// Create expected results
- List[] expected = new List[] {
+ List<?>[] expected = new List<?>[] {
Arrays.asList(new Object[] { null }),
Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
@@ -165,7 +164,7 @@
@Test public void testOptionalJoinNode6() {
// Create query
- String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
+ String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1 order by e1"; //$NON-NLS-1$
// Create expected results
List[] expected = new List[] {
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2013-05-08 18:29:01 UTC (rev 4563)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2013-05-14 14:53:25 UTC (rev 4564)
@@ -51,7 +51,7 @@
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
-@SuppressWarnings("unchecked")
+@SuppressWarnings({"unchecked", "rawtypes"})
public class TestJoinNode {
private static final int NO_CRITERIA = 0;
private static final int EQUAL_CRITERIA = 1;
@@ -640,6 +640,77 @@
this.join.setJoinStrategy(joinStrategy);
helpTestJoinDirect(expected, batchSize, 1);
}
+
+ @Test public void testMergeJoinOptimizationLeftOuter() throws Exception {
+ this.joinType = JoinType.JOIN_LEFT_OUTER;
+ int rows = 12;
+ List[] data = new List[rows];
+ for(int i=0; i<rows; i++) {
+ data[i] = new ArrayList();
+ Integer value = new Integer((i*17) % 45);
+ data[i].add(value);
+ }
+ this.leftTuples = data;
+ this.rightTuples = createTuples2();
+ expected = new List[] {
+ Arrays.asList(new Object[] { 0, null }),
+ Arrays.asList(new Object[] {17, null }),
+ Arrays.asList(new Object[] {34, null }),
+ Arrays.asList(new Object[] { 6, 6 }),
+ Arrays.asList(new Object[] {23, null }),
+ Arrays.asList(new Object[] {40, null }),
+ Arrays.asList(new Object[] {12, null }),
+ Arrays.asList(new Object[] {29, null }),
+ Arrays.asList(new Object[] { 1, 1 }),
+ Arrays.asList(new Object[] {18, null }),
+ Arrays.asList(new Object[] {35, null }),
+ Arrays.asList(new Object[] { 7, 7 }),
+ Arrays.asList(new Object[] { 7, 7 }),
+ };
+
+ System.out.println(Arrays.toString(this.leftTuples));
+ helpCreateJoin();
+ EnhancedSortMergeJoinStrategy esmjs = new EnhancedSortMergeJoinStrategy(SortOption.NOT_SORTED, SortOption.SORT);
+ this.joinStrategy = esmjs;
+ this.join.setJoinStrategy(joinStrategy);
+
+ helpTestJoinDirect(expected, 10, 1);
+ }
+
+ @Test public void testMergeJoinOptimizationLeftOuterEmpty() throws Exception {
+ this.joinType = JoinType.JOIN_LEFT_OUTER;
+ int rows = 12;
+ List[] data = new List[rows];
+ for(int i=0; i<rows; i++) {
+ data[i] = new ArrayList();
+ Integer value = new Integer((i*17) % 45);
+ data[i].add(value);
+ }
+ this.leftTuples = data;
+ this.rightTuples = new List[0];
+ expected = new List[] {
+ Arrays.asList(new Object[] { 0, null }),
+ Arrays.asList(new Object[] {17, null }),
+ Arrays.asList(new Object[] {34, null }),
+ Arrays.asList(new Object[] { 6, null }),
+ Arrays.asList(new Object[] {23, null }),
+ Arrays.asList(new Object[] {40, null }),
+ Arrays.asList(new Object[] {12, null }),
+ Arrays.asList(new Object[] {29, null }),
+ Arrays.asList(new Object[] { 1, null }),
+ Arrays.asList(new Object[] {18, null }),
+ Arrays.asList(new Object[] {35, null }),
+ Arrays.asList(new Object[] { 7, null }),
+ };
+
+ System.out.println(Arrays.toString(this.leftTuples));
+ helpCreateJoin();
+ EnhancedSortMergeJoinStrategy esmjs = new EnhancedSortMergeJoinStrategy(SortOption.NOT_SORTED, SortOption.SORT);
+ this.joinStrategy = esmjs;
+ this.join.setJoinStrategy(joinStrategy);
+
+ helpTestJoinDirect(expected, 10, 1);
+ }
@Test public void testMergeJoinOptimizationMultiBatch() throws Exception {
helpTestEnhancedSortMergeJoin(10);
Modified: branches/7.7.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java
===================================================================
--- branches/7.7.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java 2013-05-08 18:29:01 UTC (rev 4563)
+++ branches/7.7.x/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java 2013-05-14 14:53:25 UTC (rev 4564)
@@ -31,7 +31,7 @@
}
@Test public void test_PG_ATTRDEF() throws Exception {
- execute("select * FROM pg_attrdef"); //$NON-NLS-1$
+ execute("select * FROM pg_attrdef order by adrelid, adnum"); //$NON-NLS-1$
TestMMDatabaseMetaData.compareResultSet(this.internalResultSet);
}
11 years, 5 months