Author: shawkins
Date: 2011-05-04 10:35:56 -0400 (Wed, 04 May 2011)
New Revision: 3147
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
Log:
TEIID-1576 minor enhancement to more eagerly use the index join.
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java 2011-05-04
14:34:23 UTC (rev 3146)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java 2011-05-04
14:35:56 UTC (rev 3147)
@@ -224,7 +224,8 @@
int schemaSize =
this.joinNode.getBufferManager().getSchemaSize(other.getSource().getOutputElements());
int toReserve = this.joinNode.getBufferManager().getMaxProcessingKB();
//check if the other side can be sorted in memory
- if (other.getRowCount()/this.joinNode.getBatchSize() < toReserve/schemaSize) {
+ if (other.getRowCount() <= this.joinNode.getBatchSize()
+ || (possibleIndex.getRowCount() > this.joinNode.getBatchSize() &&
other.getRowCount()/this.joinNode.getBatchSize() < toReserve/schemaSize)) {
return false;
}
boolean useIndex = false;
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2011-05-04
14:34:23 UTC (rev 3146)
+++
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2011-05-04
14:35:56 UTC (rev 3147)
@@ -247,11 +247,10 @@
while(true) {
try {
TupleBatch batch = join.nextBatch();
- for(int row = currentRow; row <= batch.getEndRow(); row++) {
- List tuple = batch.getTuple(row);
- assertEquals("Rows don't match at " + row,
expectedResults[row-1], tuple); //$NON-NLS-1$
+ for(;currentRow <= batch.getEndRow(); currentRow++) {
+ List tuple = batch.getTuple(currentRow);
+ assertEquals("Rows don't match at " + currentRow,
expectedResults[currentRow-1], tuple); //$NON-NLS-1$
}
- currentRow += batch.getRowCount();
if(batch.getTerminationFlag()) {
break;
}
@@ -599,7 +598,7 @@
}
@Test public void testMergeJoinOptimization() throws Exception {
- helpTestEnhancedSortMergeJoin(100);
+ helpTestEnhancedSortMergeJoin(99);
}
private void helpTestEnhancedSortMergeJoin(int batchSize)
@@ -679,13 +678,13 @@
Arrays.asList(new Object[] { 7, 7 }),
Arrays.asList(new Object[] { 2, 2 }),
Arrays.asList(new Object[] { 6, 6 }),
- Arrays.asList(new Object[] { 1, 1 })
+ Arrays.asList(new Object[] { 1, 1 }),
};
helpCreateJoin();
this.joinStrategy = new EnhancedSortMergeJoinStrategy(SortOption.SORT,
SortOption.SORT);
this.join.setJoinStrategy(joinStrategy);
//this.join.setRightDistinct(true);
- helpTestJoinDirect(expected, 100, 1);
+ helpTestJoinDirect(expected, 40, 1);
}
@Test public void testMergeJoinOptimizationWithDistinctAlreadySorted() throws
Exception {
@@ -717,7 +716,7 @@
helpCreateJoin();
this.joinStrategy = new EnhancedSortMergeJoinStrategy(SortOption.SORT,
SortOption.ALREADY_SORTED);
this.join.setJoinStrategy(joinStrategy);
- helpTestJoinDirect(expected, 100, 1);
+ helpTestJoinDirect(expected, 40, 1);
}
@Test public void testRepeatedMerge() throws Exception {
Show replies by date