Author: shawkins
Date: 2012-01-25 16:22:18 -0500 (Wed, 25 Jan 2012)
New Revision: 3823
Modified:
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestDependentCriteriaProcessor.java
Log:
TEIID-1912 using better defaults for pg dependent join in values
Modified:
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
===================================================================
---
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2012-01-25
21:10:12 UTC (rev 3822)
+++
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2012-01-25
21:22:18 UTC (rev 3823)
@@ -70,6 +70,8 @@
public PostgreSQLExecutionFactory() {
setDatabaseVersion(EIGHT_0);
+ setMaxDependentInPredicates(1);
+ setMaxInCriteriaSize(Short.MAX_VALUE - 50); //set a value that is safely smaller than
the max in case there are other parameters
}
public void start() throws TranslatorException {
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
===================================================================
---
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-01-25
21:10:12 UTC (rev 3822)
+++
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-01-25
21:22:18 UTC (rev 3823)
@@ -22,17 +22,7 @@
package org.teiid.query.processor.relational;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.common.buffer.BlockedException;
@@ -183,7 +173,7 @@
if (criteria instanceof SetCriteria) {
SetCriteria setCriteria = (SetCriteria)criteria;
- if (setCriteria.isNegated() || setCriteria.getNumberOfValues() <=
maxSetSize) {
+ if (setCriteria.isNegated() || setCriteria.getNumberOfValues() <=
maxSetSize || !setCriteria.isAllConstants()) {
continue;
}
SetState state = new SetState();
@@ -286,7 +276,7 @@
* @throws TeiidComponentException
*/
private void replaceDependentValueIterators() throws TeiidComponentException {
- int totalPredicates = sources.size();
+ int totalPredicates = setStates.size();
if (this.maxPredicates > 0) {
//We have a bin packing problem if totalPredicates < sources - We'll
address that case later.
//TODO: better handling for the correlated composite case
@@ -295,6 +285,11 @@
long maxSize = Integer.MAX_VALUE;
if (this.maxSetSize > 0) {
maxSize = this.maxSetSize;
+ if (this.maxPredicates > 0 && totalPredicates > this.maxPredicates)
{
+ //scale the max based upon the number of predicates - this is not perfect, but
sufficient for most situations
+ long maxParams = this.maxPredicates * this.maxSetSize;
+ maxSize = Math.max(1, maxParams/totalPredicates);
+ }
}
int currentPredicates = 0;
for (int run = 0; currentPredicates < totalPredicates; run++) {
Modified:
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
===================================================================
---
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2012-01-25
21:10:12 UTC (rev 3822)
+++
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2012-01-25
21:22:18 UTC (rev 3823)
@@ -626,6 +626,10 @@
helpTestLargeSetInDepAccessMultiJoinCriteria(1, -1, 1, 2);
}
+ @Test public void testLargeSetInDepAccessMultiJoinCriteriaSetConstraint() throws
Exception {
+ helpTestLargeSetInDepAccessMultiJoinCriteria(1, 1, 1, 2);
+ }
+
@Test public void testLargeSetInDepAccessMultiJoinCriteriaConcurrent() throws
Exception {
//allows concurrent
helpTestLargeSetInDepAccessMultiJoinCriteria(1, -1, 4, 4);
Modified:
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestDependentCriteriaProcessor.java
===================================================================
---
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestDependentCriteriaProcessor.java 2012-01-25
21:10:12 UTC (rev 3822)
+++
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestDependentCriteriaProcessor.java 2012-01-25
21:22:18 UTC (rev 3823)
@@ -42,8 +42,20 @@
@Test public void testNegatedSetCriteria() throws Exception {
DependentAccessNode dan = new DependentAccessNode(0);
SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new
Constant(1), new Constant(2))); //$NON-NLS-1$
+ sc.setAllConstants(true);
+ sc.negate();
DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
Criteria result = dcp.prepareCriteria();
+ assertEquals(sc, result);
+ assertFalse(dcp.hasNextCommand());
+ }
+
+ @Test public void testSetCriteria() throws Exception {
+ DependentAccessNode dan = new DependentAccessNode(0);
+ SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new
Constant(1), new Constant(2))); //$NON-NLS-1$
+ sc.setAllConstants(true);
+ DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
+ Criteria result = dcp.prepareCriteria();
assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ,
new Constant(1)), result); //$NON-NLS-1$
assertTrue(dcp.hasNextCommand());
}
@@ -57,6 +69,7 @@
cc.getVariableContext().setGlobalValue(reference.getContextSymbol(), 1);
}
SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), references);
//$NON-NLS-1$
+ sc.setAllConstants(true);
DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
Criteria result = dcp.prepareCriteria();
assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ,
new Constant(1)), result); //$NON-NLS-1$