Author: shawkins
Date: 2010-12-06 21:15:42 -0500 (Mon, 06 Dec 2010)
New Revision: 2762
Modified:
trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
minor changes to the determinism level
Modified: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2010-12-07 02:13:52 UTC
(rev 2761)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2010-12-07 02:15:42 UTC
(rev 2762)
@@ -87,24 +87,12 @@
* processing time.
*/
public enum Determinism{
-
DETERMINISTIC(0),VDB_DETERMINISTIC(1),USER_DETERMINISTIC(2),SESSION_DETERMINISTIC(3),COMMAND_DETERMINISTIC(4),NONDETERMINISTIC(5);
- private int value;
-
- Determinism(int value){
- this.value = value;
- }
-
- public boolean isRestrictiveThan(Determinism that) {
- return this.value > that.value;
- }
-
- public boolean isRestrictiveThanOrEqual(Determinism that) {
- return this.value >= that.value;
- }
-
- public static Determinism restrictiveOf(Determinism scopeOne, Determinism scopeTwo)
{
- return (scopeOne.value > scopeTwo.value)?scopeOne:scopeTwo;
- }
+ NONDETERMINISTIC,
+ COMMAND_DETERMINISTIC,
+ SESSION_DETERMINISTIC,
+ USER_DETERMINISTIC,
+ VDB_DETERMINISTIC,
+ DETERMINISTIC;
}
Modified:
trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml
===================================================================
---
trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml 2010-12-07
02:13:52 UTC (rev 2761)
+++
trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml 2010-12-07
02:15:42 UTC (rev 2762)
@@ -24,8 +24,8 @@
</para></listitem>
<listitem><para><emphasis>updatable</emphasis> - if present
indicates that the cached results can be updated. This is currently only applicable to
materialized views.
</para></listitem>
- <listitem><para><emphasis>scope</emphasis> - if
present indicates the override scope of query results. Using this flag, user can override
the computed scope, to improve or force the results to cache.
- There are three different cache scopes, session - cached only for current
session, user - cached for any session by the current user, vdb - cached for any user
connected to the same vdb.
+ <listitem><para><emphasis>scope</emphasis> - if
present indicates the override scope of query results. Using this flag, the user can
override the computed scope.
+ There are three different cache scopes: session - cached only for current
session, user - cached for any session by the current user, vdb - cached for any user
connected to the same vdb.
</para></listitem>
</itemizedlist>
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-12-07
02:13:52 UTC (rev 2761)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -142,13 +142,13 @@
prepPlan.setPlan(processPlan.clone());
prepPlan.setAnalysisRecord(analysisRecord);
- Determinism hintDeterminismLevel = null;
+ Determinism determinismLevel = this.context.getDeterminismLevel();
if (userCommand.getCacheHint() != null &&
userCommand.getCacheHint().getDeterminism() != null) {
- hintDeterminismLevel = userCommand.getCacheHint().getDeterminism();
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified
the query determinism from ",this.context.getDeterminismLevel(), " to ",
hintDeterminismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified
the query determinism from ",this.context.getDeterminismLevel(), " to ",
determinismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
+ determinismLevel = userCommand.getCacheHint().getDeterminism();
}
- this.prepPlanCache.put(id, hintDeterminismLevel!=
null?hintDeterminismLevel:this.context.getDeterminismLevel(), prepPlan,
userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
+ this.prepPlanCache.put(id, determinismLevel, prepPlan,
userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
}
} else {
ProcessorPlan cachedPlan = prepPlan.getPlan();
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-12-07
02:13:52 UTC (rev 2761)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -396,7 +396,7 @@
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified
the query determinism from ",processor.getContext().getDeterminismLevel(), " to
", determinismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
}
- if
(determinismLevel.isRestrictiveThan(Determinism.SESSION_DETERMINISTIC)) {
+ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <=
0) {
LogManager.logInfo(LogConstants.CTX_DQP,
QueryPlugin.Util.getString("RequestWorkItem.cache_nondeterministic",
originalCommand)); //$NON-NLS-1$
}
dqpCore.getRsCache().put(cid, determinismLevel, cr,
originalCommand.getCacheHint() != null?originalCommand.getCacheHint().getTtl():null);
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-12-07
02:13:52 UTC (rev 2761)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -143,7 +143,7 @@
}
public void put(CacheID id, Determinism determinismLevel, T t, Long ttl){
- if (determinismLevel.isRestrictiveThanOrEqual(Determinism.SESSION_DETERMINISTIC)) {
+ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) {
id.setSessionId(id.originalSessionId);
LogManager.logTrace(LogConstants.CTX_DQP, "Adding to session/local cache",
id); //$NON-NLS-1$
this.localCache.put(id, t, ttl);
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-12-07
02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -239,7 +239,7 @@
throw new FunctionExecutionException("ERR.015.001.0002",
QueryPlugin.Util.getString("ERR.015.001.0002", getName())); //$NON-NLS-1$
//$NON-NLS-2$
}
- if (getDeterministic().isRestrictiveThanOrEqual(Determinism.USER_DETERMINISTIC)
&& values.length > 0 && values[0] instanceof CommandContext) {
+ if (getDeterministic().compareTo(Determinism.USER_DETERMINISTIC) <= 0
&& values.length > 0 && values[0] instanceof CommandContext) {
CommandContext cc = (CommandContext)values[0];
cc.setDeterminismLevel(getDeterministic());
}
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-12-07
02:13:52 UTC (rev 2761)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -350,7 +350,7 @@
// TEIID-16: We do not want to merge a non-deterministic scalar function
Collection<Function> functions =
FunctionCollectorVisitor.getFunctions(symbol, true, true);
for (Function function : functions) {
- if (
function.getFunctionDescriptor().getDeterministic().isRestrictiveThanOrEqual(Determinism.NONDETERMINISTIC
)) {
+ if ( function.getFunctionDescriptor().getDeterministic() ==
Determinism.NONDETERMINISTIC) {
return false;
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2010-12-07
02:13:52 UTC (rev 2761)
+++
trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -73,7 +73,7 @@
evaluationNotPossible(EvaluationLevel.PUSH_DOWN);
} else if (obj.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)
//TODO: if we had the context here we could plan better for non-prepared
requests
- ||
obj.getFunctionDescriptor().getDeterministic().isRestrictiveThanOrEqual(Determinism.COMMAND_DETERMINISTIC))
{
+ ||
obj.getFunctionDescriptor().getDeterministic().compareTo(Determinism.COMMAND_DETERMINISTIC)
<= 0) {
evaluationNotPossible(EvaluationLevel.PROCESSING);
}
}
@@ -86,7 +86,9 @@
}
private void setDeterminismLevel(Determinism value) {
- determinismLevel = Determinism.restrictiveOf(determinismLevel, value);
+ if (determinismLevel == null || value.compareTo(determinismLevel) < 0) {
+ determinismLevel = value;
+ }
}
private void evaluationNotPossible(EvaluationLevel newLevel) {
@@ -197,7 +199,7 @@
EvaluatableVisitor visitor = new EvaluatableVisitor();
visitor.targetLevel = EvaluationLevel.PROCESSING;
PreOrderNavigator.doVisit(obj, visitor);
- if (pushdown && (visitor.hasCorrelatedReferences ||
visitor.determinismLevel.isRestrictiveThanOrEqual(Determinism.NONDETERMINISTIC))) {
+ if (pushdown && (visitor.hasCorrelatedReferences ||
visitor.determinismLevel == Determinism.NONDETERMINISTIC)) {
return false;
}
return visitor.isEvaluationPossible();
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-12-07
02:13:52 UTC (rev 2761)
+++
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -285,12 +285,11 @@
CachedResults cr = new CachedResults();
cr.setResults(tb);
cr.setHint(hint);
- Determinism hintDeterminismLevel = null;
if (hint != null && hint.getDeterminism() != null) {
- hintDeterminismLevel = hint.getDeterminism();
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the
query determinism from ",determinismLevel, " to ", hintDeterminismLevel });
//$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the
query determinism from ",determinismLevel, " to ", hint.getDeterminism()
}); //$NON-NLS-1$ //$NON-NLS-2$
+ determinismLevel = hint.getDeterminism();
}
- cache.put(cid, hintDeterminismLevel !=
null?hintDeterminismLevel:context.getDeterminismLevel(), cr, hint !=
null?hint.getTtl():null);
+ cache.put(cid, determinismLevel, cr, hint != null?hint.getTtl():null);
context.setDeterminismLevel(determinismLevel);
return tb.createIndexedTupleSource();
}
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-12-07
02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -163,7 +163,9 @@
}
public void setDeterminismLevel(Determinism level) {
- globalState.determinismLevel =
Determinism.restrictiveOf(globalState.determinismLevel, level);
+ if (globalState.determinismLevel == null ||
level.compareTo(globalState.determinismLevel) < 0) {
+ globalState.determinismLevel = level;
+ }
}
/**
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-12-07
02:13:52 UTC (rev 2761)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-12-07
02:15:42 UTC (rev 2762)
@@ -59,7 +59,7 @@
CommandContext cc = TestProcessor.createCommandContext();
cc.setTempTableStore(tempStore);
TestProcessor.doProcess(processorPlan, dataManager, expectedResults, cc);
- assertTrue(Determinism.SESSION_DETERMINISTIC.isRestrictiveThanOrEqual(cc.getDeterminismLevel()));
+ assertTrue(Determinism.SESSION_DETERMINISTIC.compareTo(cc.getDeterminismLevel()) <=
0);
}
@Before public void setUp() {