teiid SVN: r4215 - in trunk: engine/src/main/java/org/teiid/dqp/internal/process and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-29 16:04:55 -0400 (Fri, 29 Jun 2012)
New Revision: 4215
Modified:
trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/UnionAllNode.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java
Log:
TEIID-2089 fix for query hanging with enhanced merge join
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -22,6 +22,8 @@
package org.teiid.common.buffer;
+import java.util.Arrays;
+
import org.teiid.core.TeiidComponentException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -45,9 +47,20 @@
public static BlockedException block(Object... msg) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, msg);
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, msg);
}
return INSTANCE;
}
+
+ public static BlockedException blockWithTrace(Object... msg) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ BlockedException be = new BlockedException();
+ if (be.getStackTrace().length > 0) {
+ be.setStackTrace(Arrays.copyOfRange(be.getStackTrace(), 1, Math.max(0, Math.min(8, be.getStackTrace().length))));
+ }
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, be, msg);
+ }
+ return INSTANCE;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -318,7 +318,7 @@
if(isFinal) {
return null;
}
- throw BlockedException.block("Blocking on non-final TupleBuffer", tupleSourceID); //$NON-NLS-1$
+ throw BlockedException.blockWithTrace("Blocking on non-final TupleBuffer", tupleSourceID, "size", getRowCount()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -261,7 +261,7 @@
} else if (this.cwi.isDataAvailable()) {
continue;
}
- throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on DataNotAvailableException"); //$NON-NLS-1$
+ throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on DataNotAvailableException", aqr.getAtomicRequestID()); //$NON-NLS-1$
}
receiveResults(results, partial);
}
@@ -312,7 +312,7 @@
addWork();
}
if (!futureResult.isDone()) {
- throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on source query"); //$NON-NLS-1$
+ throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on source query", aqr.getAtomicRequestID()); //$NON-NLS-1$
}
FutureWork<AtomicResultsMessage> currentResults = futureResult;
futureResult = null;
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 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -571,7 +571,8 @@
&& this.getTupleBuffer().getManagedRowCount() >= OUTPUT_BUFFER_MAX_BATCHES * this.getTupleBuffer().getBatchSize()) {
if (!dqpCore.hasWaitingPlans(RequestWorkItem.this)) {
//requestMore will trigger more processing
- throw BlockedException.block(requestID, "Blocking due to full results buffer."); //$NON-NLS-1$
+ throw BlockedException.block(requestID, "Blocking due to full results TupleBuffer", //$NON-NLS-1$
+ this.getTupleBuffer().getId(), "rows", this.getTupleBuffer().getManagedRowCount(), "batch size", this.getTupleBuffer().getBatchSize()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, requestID, "Exceeding buffer limit since there are pending active plans."); //$NON-NLS-1$
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 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -37,6 +37,9 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
import org.teiid.query.optimizer.relational.rules.NewCalculateCostUtil;
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -56,7 +59,7 @@
*/
public class EnhancedSortMergeJoinStrategy extends MergeJoinStrategy {
- private final class SingleTupleSource extends AbstractList<Object> implements TupleSource {
+ private static final class SingleTupleSource extends AbstractList<Object> implements TupleSource {
boolean returned;
private int[] indexes;
private List<?> keyTuple;
@@ -256,6 +259,9 @@
if (this.processingSortLeft != SortOption.NOT_SORTED && this.processingSortRight != SortOption.NOT_SORTED) {
super.loadRight();
super.loadLeft();
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "degrading to merged join", this.joinNode.getID()); //$NON-NLS-1$
+ }
return; //degrade to merge join
}
if (this.processingSortLeft == SortOption.NOT_SORTED) {
@@ -267,6 +273,9 @@
} else {
super.loadRight(); //sort if needed
this.notSortedSource.sort(SortOption.NOT_SORTED); //do a single sort pass
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "performing single pass sort right", this.joinNode.getID()); //$NON-NLS-1$
+ }
}
} else if (this.processingSortRight == SortOption.NOT_SORTED) {
this.sortedSource = this.leftSource;
@@ -288,6 +297,9 @@
} else {
super.loadLeft(); //sort if needed
this.notSortedSource.sort(SortOption.NOT_SORTED); //do a single sort pass
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "performing single pass sort left", this.joinNode.nodeToString()); //$NON-NLS-1$
+ }
}
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/UnionAllNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/UnionAllNode.java 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/UnionAllNode.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -129,7 +129,7 @@
} else if(activeSources > 0) {
// Didn't get a batch but there are active sources so we are blocked
- throw BlockedException.block(getContext().getRequestId(), "Blocking on union source."); //$NON-NLS-1$
+ throw BlockedException.block(getContext().getRequestId(), "Blocking on union source.", getID()); //$NON-NLS-1$
} else {
// No batch and no active sources - return empty termination batch (should never happen but just in case)
outputBatch = new TupleBatch(outputRow, Collections.EMPTY_LIST);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -132,7 +132,7 @@
insert.setTupleSource(new TempLoadTupleSource());
this.dataManager.registerRequest(this.internalProcessor.getContext(), insert, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
if (!doneLoading) {
- throw BlockedException.block("Blocking on result set load"); //$NON-NLS-1$
+ throw BlockedException.block(resultInfo.getResultSetName(), "Blocking on result set load"); //$NON-NLS-1$
}
internalProcessor.closeProcessing();
AlterTempTable att = new AlterTempTable(tempTable);
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 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -743,25 +743,25 @@
this.rightTuples = data;
this.leftTuples = new List[17];
for (int i = 0; i < this.leftTuples.length; i++) {
- this.leftTuples[i] = Arrays.asList(i);
+ this.leftTuples[i] = Arrays.asList(i*4);
}
if (!indexDistinct) {
- this.leftTuples[1] = Arrays.asList(0);
+ this.leftTuples[3] = Arrays.asList(0);
}
this.leftTuples[11] = Arrays.asList((Integer)null);
expected = new List[] {
- Arrays.asList(13, 13),
- Arrays.asList(2, 2),
+ Arrays.asList(64, 64),
+ Arrays.asList(36, 36),
Arrays.asList(8, 8),
- Arrays.asList(14, 14),
- Arrays.asList(3, 3),
- Arrays.asList(9, 9),
- Arrays.asList(15, 15),
+ Arrays.asList(48, 48),
+ Arrays.asList(20, 20),
+ Arrays.asList(60, 60),
+ Arrays.asList(32, 32),
Arrays.asList(4, 4),
- Arrays.asList(10, 10),
Arrays.asList(16, 16),
- Arrays.asList(5, 5),
+ Arrays.asList(56, 56),
+ Arrays.asList(28, 28),
Arrays.asList(0, 0),
Arrays.asList(0, 0),
};
Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java 2012-06-29 13:44:31 UTC (rev 4214)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java 2012-06-29 20:04:55 UTC (rev 4215)
@@ -86,7 +86,7 @@
})});
- List[] expected = new List[] { Arrays.asList(new Object[] {"<?xml version=\"1.0\" encoding=\"UTF-8\"?><XSDTypesNS:test xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:XSDTypesNS=\"http://www.metamatrix.com/XMLSchema/DataSets/XSDTypes\"><book><datetime>1903-04-04T11:06:10.006Z</datetime><double>-INF</double><float>INF</float><gday>---100</gday><gmonth>--100</gmonth><gmonthday>--04-04</gmonthday><gyear>0100</gyear><gyearmonth>1903-04Z</gyearmonth><string>1</string></book></XSDTypesNS:test>" })}; //$NON-NLS-1$
+ List<?>[] expected = new List[] { Arrays.asList(new Object[] {"<?xml version=\"1.0\" encoding=\"UTF-8\"?><XSDTypesNS:test xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:XSDTypesNS=\"http://www.metamatrix.com/XMLSchema/DataSets/XSDTypes\"><book><datetime>1903-04-04T11:06:10.006Z</datetime><double>-INF</double><float>INF</float><gday>---100</gday><gmonth>--100</gmonth><gmonthday>--04-04</gmonthday><gyear>0100</gyear><gyearmonth>1903-04Z</gyearmonth><string>1</string></book></XSDTypesNS:test>" })}; //$NON-NLS-1$
doProcess(metadata,
sql,
finder, dataMgr , expected, DEBUG);
12 years, 6 months
teiid SVN: r4214 - branches/7.7.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-29 09:44:31 -0400 (Fri, 29 Jun 2012)
New Revision: 4214
Added:
branches/7.7.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java
Log:
TEIID-2088 adding missing 1.6 class
Added: branches/7.7.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java
===================================================================
--- branches/7.7.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java (rev 0)
+++ branches/7.7.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java 2012-06-29 13:44:31 UTC (rev 4214)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @author tags. See the COPYRIGHT.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package net.sf.retrotranslator.runtime.java.sql;
+
+public enum RowIdLifetime_ {
+ ROWID_UNSUPPORTED,
+ ROWID_VALID_OTHER,
+ ROWID_VALID_SESSION,
+ ROWID_VALID_TRANSACTION,
+ ROWID_VALID_FOREVER
+}
Property changes on: branches/7.7.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 6 months
teiid SVN: r4213 - in branches/7.7.x/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2012-06-29 09:21:46 -0400 (Fri, 29 Jun 2012)
New Revision: 4213
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
Log:
TEIID-2087: Order by clause causes org.teiid.core.TeiidException
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2012-06-28 20:02:25 UTC (rev 4212)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2012-06-29 13:21:46 UTC (rev 4213)
@@ -276,16 +276,11 @@
}
correctOrderBy(frame, selectSymbols, parentProject);
+
PlanNode parentSource = NodeEditor.findParent(frame, NodeConstants.Types.SOURCE);
- PlanNode parentSetOp = NodeEditor.findParent(parentProject, NodeConstants.Types.SET_OP, NodeConstants.Types.SOURCE);
- if (parentSetOp == null || NodeEditor.findNodePreOrder(parentSetOp, NodeConstants.Types.PROJECT) == parentProject) {
- if (parentSource != null) {
- FrameUtil.correctSymbolMap(((SymbolMap)frame.getProperty(NodeConstants.Info.SYMBOL_MAP)).asMap(), parentSource);
- }
- if (parentSetOp != null) {
- correctOrderBy(frame, selectSymbols, parentSetOp);
- }
+ if (parentSource != null && NodeEditor.findNodePreOrder(parentSource, NodeConstants.Types.PROJECT) == parentProject) {
+ FrameUtil.correctSymbolMap(((SymbolMap)frame.getProperty(NodeConstants.Info.SYMBOL_MAP)).asMap(), parentSource);
}
prepareFrame(frame);
@@ -301,18 +296,22 @@
return root;
}
+ /**
+ * special handling is needed since we are retaining the child aliases
+ */
private static void correctOrderBy(PlanNode frame,
- List<SingleElementSymbol> selectSymbols, PlanNode startNode) {
- PlanNode sort = NodeEditor.findParent(startNode, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE | NodeConstants.Types.SET_OP);
- if (sort != null) { //special handling is needed since we are retaining the child aliases
- List<SingleElementSymbol> childProject = (List<SingleElementSymbol>)NodeEditor.findNodePreOrder(frame, NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
- OrderBy elements = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
- for (OrderByItem item : elements.getOrderByItems()) {
- item.setSymbol(childProject.get(selectSymbols.indexOf(item.getSymbol())));
- }
- sort.getGroups().clear();
- sort.addGroups(GroupsUsedByElementsVisitor.getGroups(elements));
+ List<SingleElementSymbol> selectSymbols, PlanNode parentProject) {
+ PlanNode sort = NodeEditor.findParent(parentProject, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
+ if (sort == null || NodeEditor.findNodePreOrder(sort, NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE) != parentProject) {
+ return;
}
+ List<SingleElementSymbol> childProject = (List<SingleElementSymbol>)NodeEditor.findNodePreOrder(frame, NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
+ OrderBy elements = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
+ for (OrderByItem item : elements.getOrderByItems()) {
+ item.setSymbol(childProject.get(selectSymbols.indexOf(item.getSymbol())));
+ }
+ sort.getGroups().clear();
+ sort.addGroups(GroupsUsedByElementsVisitor.getGroups(elements));
}
/**
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2012-06-28 20:02:25 UTC (rev 4212)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2012-06-29 13:21:46 UTC (rev 4213)
@@ -408,5 +408,28 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
+
+ @Test public void testSortOverUnion() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from (select max(e1) as e1 from pm1.g1 having 1 = 0) as y union all select e2 from pm1.g1 union all select e1 from pm1.g1 order by e1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(),
+ new String[] {
+ "SELECT pm1.g1.e2 FROM pm1.g1", "SELECT pm1.g1.e1 FROM pm1.g1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 1 // UnionAll
+ });
+ }
}
12 years, 6 months
teiid SVN: r4212 - in trunk: client/src/main/java/org/teiid/jdbc and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-28 16:02:25 -0400 (Thu, 28 Jun 2012)
New Revision: 4212
Modified:
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
Log:
TEIID-2059 refining the wait logic with additional configuration options
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-06-28 20:02:25 UTC (rev 4212)
@@ -47,6 +47,7 @@
<li>VDB.getUrl has been removed.
<li>VDB.Status now has three states - LOADING, ACTIVE, REMOVED. To check for validity use the isValid method, rather than checking for the VALID state.
<li>The standalone and cli configuration files specify a setting for the teiid subsystem policy-decider-module. If a module is not specified, then data roles will not be checked.
+ <li>local connections specifying a VDB version will wait for their VDB to finish loading before allowing a connection.
<ul>
<h4>from 7.x</h4>
Modified: trunk/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -33,14 +33,13 @@
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.PropertiesUtils;
import org.teiid.core.util.ReflectionHelper;
-import org.teiid.net.CommunicationException;
-import org.teiid.net.ConnectionException;
import org.teiid.net.ServerConnection;
public class EmbeddedProfile implements ConnectionProfile {
public static final String USE_CALLING_THREAD = "useCallingThread"; //$NON-NLS-1$
+ public static final String WAIT_FOR_LOAD = "waitForLoad"; //$NON-NLS-1$
/**
* This method tries to make a connection to the given URL. This class
@@ -56,10 +55,6 @@
return new ConnectionImpl(sc, info, url);
} catch (TeiidRuntimeException e) {
throw TeiidSQLException.create(e);
- } catch (ConnectionException e) {
- throw TeiidSQLException.create(e);
- } catch (CommunicationException e) {
- throw TeiidSQLException.create(e);
} catch (TeiidException e) {
throw TeiidSQLException.create(e);
}
@@ -67,14 +62,12 @@
protected ServerConnection createServerConnection(Properties info) throws TeiidException {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- try {
- final Module module = Module.getCallerModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.teiid")); //$NON-NLS-1$
- Thread.currentThread().setContextClassLoader(module.getClassLoader());
- return (ServerConnection)ReflectionHelper.create("org.teiid.transport.LocalServerConnection", Arrays.asList(info, PropertiesUtils.getBooleanProperty(info, USE_CALLING_THREAD, true)), Thread.currentThread().getContextClassLoader()); //$NON-NLS-1$
- } catch (ModuleLoadException e) {
- throw new TeiidRuntimeException(JDBCPlugin.Event.TEIID20008, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20008));
- }
+ try {
+ final Module module = Module.getCallerModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.teiid")); //$NON-NLS-1$
+ Thread.currentThread().setContextClassLoader(module.getClassLoader());
+ return (ServerConnection)ReflectionHelper.create("org.teiid.transport.LocalServerConnection", Arrays.asList(info, PropertiesUtils.getBooleanProperty(info, USE_CALLING_THREAD, true)), Thread.currentThread().getContextClassLoader()); //$NON-NLS-1$
+ } catch (ModuleLoadException e) {
+ throw new TeiidRuntimeException(JDBCPlugin.Event.TEIID20008, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20008));
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -71,6 +71,7 @@
BaseDataSource.VDB_VERSION,
BaseDataSource.USER_NAME,
BaseDataSource.PASSWORD,
+ EmbeddedProfile.WAIT_FOR_LOAD,
TeiidURL.CONNECTION.AUTO_FAILOVER,
TeiidURL.CONNECTION.DISCOVERY_STRATEGY,
TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION,
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -138,7 +138,7 @@
@Test public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb@mm://localhost:12345;applicationName=x", null); //$NON-NLS-1$
- assertEquals(24, info.length);
+ assertEquals(25, info.length);
assertEquals(false, info[0].required);
assertEquals("ApplicationName", info[0].name); //$NON-NLS-1$
assertEquals("x", info[0].value); //$NON-NLS-1$
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -55,6 +55,7 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.net.ConnectionException;
import org.teiid.net.socket.AuthenticationType;
import org.teiid.security.SecurityHelper;
import org.teiid.services.SessionServiceImpl;
@@ -104,13 +105,10 @@
}
@Override
- public void waitForFinished(String vdbName, int vdbVersion) {
+ public void waitForFinished(String vdbName, int vdbVersion,
+ int timeOutMillis) throws ConnectionException {
VDBRepository repo = this.vdbRepositoryInjector.getValue();
- try {
- repo.waitForFinished(vdbName, vdbVersion);
- } catch (InterruptedException e) {
- return; //just allow the thread to continue/error
- }
+ repo.waitForFinished(vdbName, vdbVersion, timeOutMillis);
}
@Override
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -32,6 +31,7 @@
import java.util.NavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@@ -41,12 +41,14 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.core.CoreConstants;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Datatype;
import org.teiid.metadata.MetadataStore;
+import org.teiid.net.ConnectionException;
import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.metadata.MetadataValidator;
import org.teiid.query.metadata.TransformationMetadata.Resource;
@@ -60,10 +62,8 @@
* Repository for VDBs
*/
public class VDBRepository implements Serializable{
- private static final int DEPLOY_TIMEOUT = 60000;
- private static final int LOAD_TIMEOUT = 600000;
-
private static final long serialVersionUID = 312177538191772674L;
+ private static final int DEFAULT_TIMEOUT_MILLIS = PropertiesUtils.getIntProperty(System.getProperties(), "org.teiid.clientVdbLoadTimeoutMillis", 300000); //$NON-NLS-1$
private NavigableMap<VDBKey, CompositeVDB> vdbRepo = new ConcurrentSkipListMap<VDBKey, CompositeVDB>();
private MetadataStore systemStore;
@@ -108,25 +108,43 @@
notifyAdd(vdb.getName(), vdb.getVersion(), cvdb);
}
- public void waitForFinished(String vdbName, int vdbVersion) throws InterruptedException {
+ public void waitForFinished(String vdbName, int vdbVersion, int timeOutMillis) throws ConnectionException {
CompositeVDB cvdb = null;
VDBKey key = new VDBKey(vdbName, vdbVersion);
- Date toWait = new Date(System.currentTimeMillis() + DEPLOY_TIMEOUT);
+ long timeOutNanos = 0;
+ if (timeOutMillis >= 0) {
+ timeOutNanos = TimeUnit.MILLISECONDS.toNanos(DEFAULT_TIMEOUT_MILLIS);
+ } else {
+ //TODO allow a configurable default
+ timeOutNanos = TimeUnit.MINUTES.toNanos(10);
+ }
lock.lock();
try {
- while (cvdb == null) {
- cvdb = this.vdbRepo.get(key);
- if (cvdb == null && !vdbAdded.awaitUntil(toWait)) {
- return; //TODO: should there be a message/exception
+ while ((cvdb = this.vdbRepo.get(key)) == null) {
+ if (timeOutNanos <= 0) {
+ throw new ConnectionException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40096, timeOutMillis, vdbName, vdbVersion));
}
+ timeOutNanos = this.vdbAdded.awaitNanos(timeOutNanos);
+
}
+ } catch (InterruptedException e) {
+ return;
} finally {
lock.unlock();
}
VDBMetaData vdb = cvdb.getVDB();
+ long finishNanos = System.nanoTime() + timeOutNanos;
synchronized (vdb) {
- while (vdb.isLoading()) {
- vdb.wait(LOAD_TIMEOUT);
+ while (vdb.getStatus() != Status.ACTIVE) {
+ if (timeOutNanos <= 0) {
+ throw new ConnectionException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40097, timeOutMillis, vdbName, vdbVersion, vdb.getValidityErrors()));
+ }
+ try {
+ vdb.wait(timeOutNanos);
+ } catch (InterruptedException e) {
+ return;
+ }
+ timeOutNanos = finishNanos - System.nanoTime();
}
}
}
Modified: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -221,7 +221,14 @@
protected ObjectReplicator replicator;
protected BufferServiceImpl bufferService = new BufferServiceImpl();
protected TransactionDetectingTransactionServer transactionService = new TransactionDetectingTransactionServer();
- protected ClientServiceRegistryImpl services = new ClientServiceRegistryImpl();
+ protected boolean waitForLoad;
+ protected ClientServiceRegistryImpl services = new ClientServiceRegistryImpl() {
+ public void waitForFinished(String vdbName, int vdbVersion, int timeOutMillis) throws ConnectionException {
+ if (waitForLoad) {
+ repo.waitForFinished(vdbName, vdbVersion, timeOutMillis);
+ }
+ };
+ };
protected LogonImpl logon;
private TeiidDriver driver = new TeiidDriver();
protected ConnectorManagerRepository cmr = new ProviderAwareConnectorManagerRepository();
Modified: trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -108,5 +108,7 @@
TEIID40093, //no sources
TEIID40094, //invalid metadata repso
TEIID40095, //deployment failed
+ TEIID40096, //vdb deploy timeout
+ TEIID40097, //vdb finish timeout
}
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -23,6 +23,7 @@
package org.teiid.transport;
import org.teiid.core.ComponentNotFoundException;
+import org.teiid.net.ConnectionException;
import org.teiid.net.socket.AuthenticationType;
import org.teiid.security.SecurityHelper;
@@ -38,7 +39,7 @@
SecurityHelper getSecurityHelper();
AuthenticationType getAuthenticationType();
+
+ void waitForFinished(String vdbName, int vdbVersion, int timeOutMillis) throws ConnectionException;
- void waitForFinished(String vdbName, int vdbVersion);
-
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -26,6 +26,7 @@
import org.teiid.core.ComponentNotFoundException;
import org.teiid.core.util.ReflectionHelper;
+import org.teiid.net.ConnectionException;
import org.teiid.net.socket.AuthenticationType;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.security.SecurityHelper;
@@ -105,7 +106,8 @@
}
@Override
- public void waitForFinished(String vdbName, int vdbVersion) {
+ public void waitForFinished(String vdbName, int vdbVersion,
+ int timeOutMillis) throws ConnectionException {
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -40,7 +40,9 @@
import org.teiid.client.util.ExceptionUtil;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.jdbc.EmbeddedProfile;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.ServerConnection;
@@ -71,8 +73,12 @@
vdbName = vdbName.substring(0, firstIndex);
}
if (vdbVersion != null) {
- this.csr.waitForFinished(connectionProperties.getProperty(TeiidURL.JDBC.VDB_NAME), Integer.valueOf(vdbVersion));
+ int waitForLoad = PropertiesUtils.getIntProperty(connectionProperties, EmbeddedProfile.WAIT_FOR_LOAD, -1);
+ if (waitForLoad != 0) {
+ this.csr.waitForFinished(vdbName, Integer.valueOf(vdbVersion), waitForLoad);
+ }
}
+
workContext.setSecurityHelper(csr.getSecurityHelper());
workContext.setUseCallingThread(useCallingThread);
authenticate();
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-28 20:02:25 UTC (rev 4212)
@@ -97,3 +97,6 @@
TEIID40092=Policy {0} not found in VDB {1}.{2}
TEIID40093=Model {0} specified with no source information in VDB {1}.{2}
TEIID40094=No metadata repository of type {3} defined for model {0} for VDB {1}.{2}
+
+TEIID40096=Waited {0} for VDB {1}.{2} to be deployed, but it never was. Please check to see if the deployment is missing or is in error.
+TEIID40097=Waited {0} for VDB {1}.{2} to be ACTIVE, but it never was. Please check it's sources - {3}.
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -75,6 +75,7 @@
@SuppressWarnings("serial")
public FakeServer(boolean start) {
+ waitForLoad = true;
cmr = new ProviderAwareConnectorManagerRepository() {
@Override
public ConnectorManager getConnectorManager(String connectorName) {
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-06-28 19:58:01 UTC (rev 4211)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-06-28 20:02:25 UTC (rev 4212)
@@ -43,6 +43,7 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.teiid.client.util.ResultsFuture;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
@@ -336,4 +337,34 @@
}
}
+ @Test public void testWaitForLoad() throws Exception {
+ final ResultsFuture<Void> future = new ResultsFuture<Void>();
+
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ server.createConnection("jdbc:teiid:not_there.1");
+ future.getResultsReceiver().receiveResults(null);
+ } catch (Exception e) {
+ future.getResultsReceiver().exceptionOccurred(e);
+ }
+ }
+ };
+ t.setDaemon(true);
+ t.start();
+ assertFalse(future.isDone());
+ try {
+ server.deployVDB("not_there", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
+ future.get(5000, TimeUnit.SECONDS);
+ } finally {
+ server.undeployVDB("not_there");
+ }
+ try {
+ server.createConnection("jdbc:teiid:not_there.1;waitForLoad=0");
+ fail();
+ } catch (TeiidSQLException e) {
+
+ }
+ }
+
}
12 years, 6 months
teiid SVN: r4211 - branches/7.7.x/build/kits/jboss-container.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-28 15:58:01 -0400 (Thu, 28 Jun 2012)
New Revision: 4211
Modified:
branches/7.7.x/build/kits/jboss-container/teiid-releasenotes.html
Log:
TEIID-2059 adding logic for local connection to wait until vdbs are active
Modified: branches/7.7.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.7.x/build/kits/jboss-container/teiid-releasenotes.html 2012-06-28 19:54:38 UTC (rev 4210)
+++ branches/7.7.x/build/kits/jboss-container/teiid-releasenotes.html 2012-06-28 19:58:01 UTC (rev 4211)
@@ -43,12 +43,12 @@
<li>Support for named parameter syntax using param=value has been deprecated, since it is ambiguous with a comparison predicate boolean value expression. param<b>=></b>value should be used instead.
<li>Support for using the FROM clause post item hints MAKEDEP/MAKENOTDEP has been deprecated. Use the pre item comment hint syntax instead, e.g. /*+ MAKEDEP */ tbl
<li>decodeinteger/decodestring have been deprecated. A CASE expression should be used instead.
- <li>local connections specifying a VDB version will wait for their VDB to finish loading before allowing a connection. See the connection property waitForLoad or the system property org.teiid.clientVdbLoadTimeoutMillis for more.
</ul>
<h4>from 7.7</h4>
<ul>
<li>parse/formatdate and parse/formattime are no longer pushdown functions. They are converted into parse/formattimestamp.
+ <li>local connections specifying a VDB version will wait for their VDB to finish loading before allowing a connection. See the connection property waitForLoad or the system property org.teiid.clientVdbLoadTimeoutMillis for more.
</ul>
<h4>from 7.5</h4>
12 years, 6 months
teiid SVN: r4210 - in branches/7.7.x: client/src/main/java/org/teiid/jdbc and 8 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-28 15:54:38 -0400 (Thu, 28 Jun 2012)
New Revision: 4210
Modified:
branches/7.7.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.7.x/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
branches/7.7.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java
branches/7.7.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
branches/7.7.x/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml
branches/7.7.x/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
branches/7.7.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/7.7.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
branches/7.7.x/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
branches/7.7.x/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
branches/7.7.x/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
branches/7.7.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties
branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
Log:
TEIID-2059 adding logic for local connection to wait until vdbs are active
Modified: branches/7.7.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.7.x/build/kits/jboss-container/teiid-releasenotes.html 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/build/kits/jboss-container/teiid-releasenotes.html 2012-06-28 19:54:38 UTC (rev 4210)
@@ -43,6 +43,7 @@
<li>Support for named parameter syntax using param=value has been deprecated, since it is ambiguous with a comparison predicate boolean value expression. param<b>=></b>value should be used instead.
<li>Support for using the FROM clause post item hints MAKEDEP/MAKENOTDEP has been deprecated. Use the pre item comment hint syntax instead, e.g. /*+ MAKEDEP */ tbl
<li>decodeinteger/decodestring have been deprecated. A CASE expression should be used instead.
+ <li>local connections specifying a VDB version will wait for their VDB to finish loading before allowing a connection. See the connection property waitForLoad or the system property org.teiid.clientVdbLoadTimeoutMillis for more.
</ul>
<h4>from 7.7</h4>
Modified: branches/7.7.x/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- branches/7.7.x/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/client/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -38,6 +38,7 @@
public class EmbeddedProfile implements ConnectionProfile {
public static final String USE_CALLING_THREAD = "useCallingThread"; //$NON-NLS-1$
+ public static final String WAIT_FOR_LOAD = "waitForLoad"; //$NON-NLS-1$
/**
* This method tries to make a connection to the given URL. This class
Modified: branches/7.7.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- branches/7.7.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -71,6 +71,7 @@
BaseDataSource.VDB_VERSION,
BaseDataSource.USER_NAME,
BaseDataSource.PASSWORD,
+ EmbeddedProfile.WAIT_FOR_LOAD,
TeiidURL.CONNECTION.AUTO_FAILOVER,
TeiidURL.CONNECTION.DISCOVERY_STRATEGY,
TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION,
Modified: branches/7.7.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- branches/7.7.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -138,7 +138,7 @@
@Test public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb@mm://localhost:12345;applicationName=x", null); //$NON-NLS-1$
- assertEquals(24, info.length);
+ assertEquals(25, info.length);
assertEquals(false, info[0].required);
assertEquals("ApplicationName", info[0].name); //$NON-NLS-1$
assertEquals("x", info[0].value); //$NON-NLS-1$
Modified: branches/7.7.x/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml
===================================================================
--- branches/7.7.x/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml 2012-06-28 19:54:38 UTC (rev 4210)
@@ -51,5 +51,10 @@
</para>
<note><para>For Teiid 8.x this property no longer exists and the default behavior is to add only the Warning root.</para></note>
</listitem>
+ <listitem>
+ <para><emphasis>org.teiid.clientVdbLoadTimeoutMillis</emphasis> - defaults to 5 minutes.
+ The default amount of time a client (currently only local clients) will wait to make a connection to an active VDB before throwing an exception. Clients may override this setting via the waitForLoad connection property.
+ </para>
+ </listitem>
</itemizedlist>
</appendix>
\ No newline at end of file
Modified: branches/7.7.x/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
===================================================================
--- branches/7.7.x/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2012-06-28 19:54:38 UTC (rev 4210)
@@ -232,6 +232,15 @@
<code>boolean</code>
</entry>
<entry>Only applies to "local" connections. When this option is set to "true" (the default), then the calling thread will be used to process the query. If false, then an engine thread will be used.</entry>
+ </row>
+ <row>
+ <entry>
+ <code>waitForLoad</code>
+ </entry>
+ <entry>
+ <code>integer</code>
+ </entry>
+ <entry>Only applies to "local" connections. When this option is set to a non-negative value the connection will wait that number of milliseconds for the VDB to become active. Setting to a negative number will use the system default setting. Needs to be specified using AdditionalProperties if set via a DataSource property.</entry>
</row>
<row>
<entry>
Modified: branches/7.7.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/7.7.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -113,6 +113,7 @@
import org.teiid.metadata.Table;
import org.teiid.metadata.TableStats;
import org.teiid.metadata.Table.TriggerEvent;
+import org.teiid.net.ConnectionException;
import org.teiid.net.TeiidURL;
import org.teiid.net.socket.AuthenticationType;
import org.teiid.query.ObjectReplicator;
@@ -883,4 +884,14 @@
public AuthenticationType getAuthenticationType() {
return this.sessionService.getAuthType();
}
+
+ @Override
+ public void waitForFinished(String vdbName, int vdbVersion,
+ int timeOutMillis) throws ConnectionException {
+ try {
+ vdbRepository.waitForFinished(vdbName, vdbVersion, timeOutMillis);
+ } catch (InterruptedException e) {
+ return; //just allow the thread to continue/error
+ }
+ }
}
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- branches/7.7.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -22,39 +22,26 @@
package org.teiid.deployers;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.NavigableMap;
-import java.util.Properties;
+import java.util.*;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
import org.jboss.deployers.spi.DeploymentException;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.VDB.Status;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.core.CoreConstants;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.metadata.AbstractMetadataRecord;
-import org.teiid.metadata.Column;
-import org.teiid.metadata.ColumnStats;
-import org.teiid.metadata.Datatype;
-import org.teiid.metadata.MetadataRepository;
-import org.teiid.metadata.MetadataStore;
-import org.teiid.metadata.Procedure;
-import org.teiid.metadata.Schema;
-import org.teiid.metadata.Table;
-import org.teiid.metadata.TableStats;
+import org.teiid.metadata.*;
+import org.teiid.net.ConnectionException;
import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.metadata.TransformationMetadata.Resource;
import org.teiid.runtime.RuntimePlugin;
@@ -67,6 +54,7 @@
*/
public class VDBRepository implements Serializable{
private static final long serialVersionUID = 312177538191772674L;
+ private static final int DEFAULT_TIMEOUT_MILLIS = PropertiesUtils.getIntProperty(System.getProperties(), "org.teiid.clientVdbLoadTimeoutMillis", 300000); //$NON-NLS-1$
private NavigableMap<VDBKey, CompositeVDB> vdbRepo = new ConcurrentSkipListMap<VDBKey, CompositeVDB>();
private MetadataStore systemStore;
@@ -75,15 +63,15 @@
private List<VDBLifeCycleListener> listeners = new CopyOnWriteArrayList<VDBLifeCycleListener>();
private SystemFunctionManager systemFunctionManager;
private MetadataRepository metadataRepository;
+ private ReentrantLock lock = new ReentrantLock();
+ private Condition vdbAdded = lock.newCondition();
public MetadataRepository getMetadataRepository() {
return metadataRepository;
}
public void addVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String, Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr) throws DeploymentException {
- if (getVDB(vdb.getName(), vdb.getVersion()) != null) {
- throw new DeploymentException(RuntimePlugin.Util.getString("duplicate_vdb", vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
+ VDBKey key = vdbId(vdb);
// get the system VDB metadata store
if (this.systemStore == null) {
@@ -100,6 +88,16 @@
else {
cvdb = new CompositeVDB(vdb, stores, visibilityMap, udf, this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore, odbcStore);
}
+ lock.lock();
+ try {
+ if (vdbRepo.containsKey(key)) {
+ throw new DeploymentException(RuntimePlugin.Util.getString("duplicate_vdb", vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+ this.vdbRepo.put(key, cvdb);
+ vdbAdded.signalAll();
+ } finally {
+ lock.unlock();
+ }
this.vdbRepo.put(vdbId(vdb), cvdb);
notifyAdd(vdb.getName(), vdb.getVersion(), cvdb);
}
@@ -188,6 +186,40 @@
}
metadataRepository.endLoadVdb(vdbName, vdbVersion);
}
+
+ public void waitForFinished(String vdbName, int vdbVersion, int timeOutMillis) throws InterruptedException, ConnectionException {
+ CompositeVDB cvdb = null;
+ VDBKey key = new VDBKey(vdbName, vdbVersion);
+ long timeOutNanos = 0;
+ if (timeOutMillis >= 0) {
+ timeOutNanos = TimeUnit.MILLISECONDS.toNanos(DEFAULT_TIMEOUT_MILLIS);
+ } else {
+ //TODO allow a configurable default
+ timeOutNanos = TimeUnit.MINUTES.toNanos(10);
+ }
+ lock.lock();
+ try {
+ while ((cvdb = this.vdbRepo.get(key)) == null) {
+ if (timeOutNanos <= 0) {
+ throw new ConnectionException(RuntimePlugin.Util.getString("VDBRepository.no_vdb", timeOutMillis, vdbName, vdbVersion)); //$NON-NLS-1$
+ }
+ timeOutNanos = this.vdbAdded.awaitNanos(timeOutNanos);
+ }
+ } finally {
+ lock.unlock();
+ }
+ VDBMetaData vdb = cvdb.getVDB();
+ long finishNanos = System.nanoTime() + timeOutNanos;
+ synchronized (vdb) {
+ while (vdb.getStatus() != Status.ACTIVE) {
+ if (timeOutNanos <= 0) {
+ throw new ConnectionException(RuntimePlugin.Util.getString("VDBRepository.no_vdb", timeOutMillis, vdbName, vdbVersion, vdb.getValidityErrors())); //$NON-NLS-1$
+ }
+ vdb.wait(timeOutNanos);
+ timeOutNanos = finishNanos - System.nanoTime();
+ }
+ }
+ }
public VDBMetaData getVDB(String name, int version) {
CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
===================================================================
--- branches/7.7.x/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -23,6 +23,7 @@
package org.teiid.transport;
import org.teiid.core.ComponentNotFoundException;
+import org.teiid.net.ConnectionException;
import org.teiid.net.socket.AuthenticationType;
import org.teiid.security.SecurityHelper;
@@ -38,5 +39,7 @@
SecurityHelper getSecurityHelper();
AuthenticationType getAuthenticationType();
+
+ void waitForFinished(String vdbName, int vdbVersion, int timeOutMillis) throws ConnectionException;
}
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
===================================================================
--- branches/7.7.x/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -26,6 +26,7 @@
import org.teiid.core.ComponentNotFoundException;
import org.teiid.core.util.ReflectionHelper;
+import org.teiid.net.ConnectionException;
import org.teiid.net.socket.AuthenticationType;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.security.SecurityHelper;
@@ -103,5 +104,11 @@
public AuthenticationType getAuthenticationType() {
return authenticationType;
}
+
+ @Override
+ public void waitForFinished(String vdbName, int vdbVersion,
+ int timeOutMillis) throws ConnectionException {
+ }
+
}
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- branches/7.7.x/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -40,7 +40,9 @@
import org.teiid.client.util.ExceptionUtil;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.jdbc.EmbeddedProfile;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.ServerConnection;
@@ -61,6 +63,22 @@
public LocalServerConnection(Properties connectionProperties, boolean useCallingThread) throws CommunicationException, ConnectionException{
this.connectionProperties = connectionProperties;
this.csr = getClientServiceRegistry();
+
+ String vdbVersion = connectionProperties.getProperty(TeiidURL.JDBC.VDB_VERSION);
+ String vdbName = connectionProperties.getProperty(TeiidURL.JDBC.VDB_NAME);
+ int firstIndex = vdbName.indexOf('.');
+ int lastIndex = vdbName.lastIndexOf('.');
+ if (firstIndex != -1 && firstIndex == lastIndex) {
+ vdbVersion = vdbName.substring(firstIndex+1);
+ vdbName = vdbName.substring(0, firstIndex);
+ }
+ if (vdbVersion != null) {
+ int waitForLoad = PropertiesUtils.getIntProperty(connectionProperties, EmbeddedProfile.WAIT_FOR_LOAD, -1);
+ if (waitForLoad != 0) {
+ this.csr.waitForFinished(vdbName, Integer.valueOf(vdbVersion), waitForLoad);
+ }
+ }
+
workContext.setSecurityHelper(csr.getSecurityHelper());
workContext.setUseCallingThread(useCallingThread);
authenticate();
Modified: branches/7.7.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- branches/7.7.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-28 19:54:38 UTC (rev 4210)
@@ -101,4 +101,7 @@
wrong_logon_type_krb5 = Wrong logon method is being used. Server is not set up for Kerberos based authentication. Correct your client's 'AuthenticationType' property.
krb5_login_failed=Kerberos context login failed
no_security_domains=No security domain configured for Kerberos authentication. Can not authenticate.
-krb5_user_not_found=GSS authentication is in use, however authenticated user not found in the context to proceed.
\ No newline at end of file
+krb5_user_not_found=GSS authentication is in use, however authenticated user not found in the context to proceed.
+
+VDBRepository.no_vdb=Waited {0} for VDB {1}.{2} to be deployed, but it never was. Please check to see if the deployment is missing or is in error.
+VDBRepository.vdb_not_active=Waited {0} for VDB {1}.{2} to be ACTIVE, but it never was. Please check it's sources - {3}.
\ No newline at end of file
Modified: branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -299,4 +299,14 @@
return new ConnectionImpl(conn, info, url);
}
+ @Override
+ public void waitForFinished(String vdbName, int vdbVersion,
+ int timeOutMillis) throws ConnectionException {
+ try {
+ repo.waitForFinished(vdbName, vdbVersion, timeOutMillis);
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+
}
Modified: branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
--- branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-06-27 19:35:38 UTC (rev 4209)
+++ branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-06-28 19:54:38 UTC (rev 4210)
@@ -43,6 +43,7 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.teiid.client.util.ResultsFuture;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
@@ -334,4 +335,28 @@
}
}
+ @Test public void testWaitForLoad() throws Exception {
+ final ResultsFuture<Void> future = new ResultsFuture<Void>();
+
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ server.createConnection("jdbc:teiid:not_there.1");
+ future.getResultsReceiver().receiveResults(null);
+ } catch (Exception e) {
+ future.getResultsReceiver().exceptionOccurred(e);
+ }
+ }
+ };
+ t.setDaemon(true);
+ t.start();
+ assertFalse(future.isDone());
+ try {
+ server.deployVDB("not_there", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
+ future.get(5000, TimeUnit.SECONDS);
+ } finally {
+ server.undeployVDB("not_there");
+ }
+ }
+
}
12 years, 6 months
teiid SVN: r4209 - in trunk: build and 16 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-27 15:35:38 -0400 (Wed, 27 Jun 2012)
New Revision: 4209
Added:
trunk/engine/src/main/java/org/teiid/query/processor/RegisterRequestParameter.java
trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java
Modified:
trunk/api/src/main/java/org/teiid/translator/DataNotAvailableException.java
trunk/build/pom.xml
trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToByteTransform.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/TickerCollectorVisitor.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/query/processor/ProcessorDataManager.java
trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/BatchedUpdateNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.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/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestBatchedUpdateNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectIntoNode.java
Log:
TEIID-2077 adding intra-query reuse of source queries
Modified: trunk/api/src/main/java/org/teiid/translator/DataNotAvailableException.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/DataNotAvailableException.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/api/src/main/java/org/teiid/translator/DataNotAvailableException.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -26,6 +26,10 @@
/**
* Used by asynch connectors to indicate data is not available
* and results should be polled for after the given delay in milliseconds.
+ * <br>
+ * Note that delays are not guaranteed. The delay is the maximum amount of time before the plan will be re-queued for execution.
+ * There are several scenarios that would cause the delay to be shorter, such as multiple sources where one source returns a shorter
+ * delay or if the engine believes more work is to be done before allowing the plan to sit idle.
*/
public class DataNotAvailableException extends TeiidRuntimeException {
Modified: trunk/build/pom.xml
===================================================================
--- trunk/build/pom.xml 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/build/pom.xml 2012-06-27 19:35:38 UTC (rev 4209)
@@ -80,7 +80,33 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>net.sf.retrotranslator.transformer.Retrotranslator</mainClass>
+ <arguments>
+ <argument>-srcjar</argument>
+ <argument>${project.basedir}/target/teiid-${project.version}-jdbc.jar</argument>
+ <argument>-destjar</argument>
+ <argument>${project.basedir}/target/teiid-${project.version}-jdbc-jdk15.jar</argument>
+ <argument>-embed</argument>
+ <argument>org.teiid.retroruntime</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
@@ -105,32 +131,8 @@
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.1.1</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>net.sf.retrotranslator.transformer.Retrotranslator</mainClass>
- <arguments>
- <argument>-srcjar</argument>
- <argument>${project.basedir}/target/teiid-${project.version}-jdbc.jar</argument>
- <argument>-destjar</argument>
- <argument>${project.basedir}/target/teiid-${project.version}-jdbc-jdk15.jar</argument>
- <argument>-embed</argument>
- <argument>org.teiid.retroruntime</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
Modified: trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToByteTransform.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToByteTransform.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToByteTransform.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -48,7 +48,7 @@
* Type of the incoming value.
* @return Source type
*/
- public Class getSourceType() {
+ public Class<?> getSourceType() {
return String.class;
}
@@ -56,7 +56,7 @@
* Type of the outgoing value.
* @return Target type
*/
- public Class getTargetType() {
+ public Class<?> getTargetType() {
return Byte.class;
}
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/TickerCollectorVisitor.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/TickerCollectorVisitor.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/TickerCollectorVisitor.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -22,9 +22,15 @@
package org.teiid.translator.yahoo;
-import java.util.*;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
-import org.teiid.language.*;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.language.Expression;
+import org.teiid.language.In;
+import org.teiid.language.Literal;
import org.teiid.language.visitor.HierarchyVisitor;
import org.teiid.translator.TranslatorException;
@@ -33,21 +39,10 @@
*/
public class TickerCollectorVisitor extends HierarchyVisitor {
- private Set tickers = new HashSet();
+ private Set<String> tickers = new HashSet<String>();
private TranslatorException exception;
- /**
- *
- */
- public TickerCollectorVisitor() {
- super();
- }
-
- public void reset() {
- tickers = new HashSet();
- }
-
- public Set getTickers() {
+ public Set<String> getTickers() {
return this.tickers;
}
@@ -61,10 +56,8 @@
}
public void visit(In obj) {
- List exprs = obj.getRightExpressions();
- Iterator iter = exprs.iterator();
- while(iter.hasNext()) {
- Expression expr = (Expression) iter.next();
+ List<Expression> exprs = obj.getRightExpressions();
+ for (Expression expr : exprs) {
addTickerFromExpression(expr);
}
}
@@ -84,8 +77,7 @@
}
-
- public static Set getTickers(Condition crit) throws TranslatorException {
+ public static Set<String> getTickers(Condition crit) throws TranslatorException {
TickerCollectorVisitor visitor = new TickerCollectorVisitor();
crit.acceptVisitor(visitor);
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -46,10 +46,9 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
-import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.TranslatorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
/**
@@ -63,21 +62,17 @@
private static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy"); //$NON-NLS-1$
private static SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mma"); //$NON-NLS-1$
- // Connector resources
- private RuntimeMetadata metadata;
private Select command;
// Execution state
- List results;
+ Iterator<List<?>> results;
int[] neededColumns;
- int returnIndex = 0;
private Select query;
/**
*
*/
- public YahooExecution(Select query, RuntimeMetadata metadata) {
- this.metadata = metadata;
+ public YahooExecution(Select query) {
this.query = query;
}
@@ -90,22 +85,22 @@
String yahooUrl = translateIntoUrl(query);
// Execute url to get results
- this.results = executeUrl(yahooUrl);
+ this.results = executeUrl(yahooUrl).iterator();
// Determine needed columns in results
- this.neededColumns = getNeededColumns(query.getDerivedColumns(), this.metadata);
+ this.neededColumns = getNeededColumns(query.getDerivedColumns());
}
static String translateIntoUrl(Select query) throws TranslatorException {
StringBuffer url = new StringBuffer();
url.append(YahooPlugin.Util.getString("YahooExecution.URL_BEGIN")); //$NON-NLS-1$
- Set tickers = getTickers(query);
+ Set<String> tickers = getTickers(query);
if(tickers.size() == 0) {
throw new TranslatorException(YahooPlugin.Util.getString("YahooExecution.No_tickers")); //$NON-NLS-1$
}
String urlAppendChar = YahooPlugin.Util.getString("YahooExecution.URL_APPEND_CHAR"); //$NON-NLS-1$
- Iterator tickerIter = tickers.iterator();
+ Iterator<String> tickerIter = tickers.iterator();
url.append(tickerIter.next());
while(tickerIter.hasNext()) {
url.append(urlAppendChar);
@@ -119,7 +114,7 @@
/**
* @return
*/
- static Set getTickers(Select query) throws TranslatorException {
+ static Set<String> getTickers(Select query) throws TranslatorException {
Condition crit = query.getWhere();
if(crit == null) {
throw new TranslatorException(YahooPlugin.Util.getString("YahooExecution.Must_have_criteria")); //$NON-NLS-1$
@@ -131,8 +126,8 @@
* @param yahooUrl
* @return
*/
- protected List executeUrl(String yahooUrl) throws TranslatorException {
- List rows = new ArrayList();
+ protected List<List<?>> executeUrl(String yahooUrl) throws TranslatorException {
+ List<List<?>> rows = new ArrayList<List<?>>();
InputStreamReader inSR = null;
BufferedReader buffReader = null;
@@ -167,8 +162,12 @@
} catch(IOException e) {
throw new TranslatorException(e, e.getMessage());
} finally {
- buffReader = null;
- inSR = null;
+ if (buffReader != null) {
+ try {
+ buffReader.close();
+ } catch (IOException e) {
+ }
+ }
}
return rows;
@@ -178,8 +177,8 @@
* @param line
* @return
*/
- static List parseLine(String line) {
- List row = new ArrayList();
+ static List<Object> parseLine(String line) {
+ List<Object> row = new ArrayList<Object>();
StringTokenizer rowToken = new StringTokenizer(line,","); //$NON-NLS-1$
for(int i=0; rowToken.hasMoreTokens(); i++){
String data = rowToken.nextToken();
@@ -196,8 +195,10 @@
} else if(i==2) {
if(!data.equals("0")){ //$NON-NLS-1$
try {
- Date date = DATE_FORMAT.parse(data);
- row.add(new java.sql.Date(date.getTime()));
+ synchronized (DATE_FORMAT) {
+ Date date = DATE_FORMAT.parse(data);
+ row.add(new java.sql.Date(date.getTime()));
+ }
} catch(ParseException e) {
Object[] params = new Object[] { data, e.getMessage() };
LogManager.logWarning(LogConstants.CTX_CONNECTOR, YahooPlugin.Util.gs(YahooPlugin.Event.TEIID14001, params));
@@ -209,8 +210,10 @@
} else if(i==3) {
if(!data.equals("0")){ //$NON-NLS-1$
try {
- Date time = TIME_FORMAT.parse(data);
- row.add(new java.sql.Time(time.getTime()));
+ synchronized (TIME_FORMAT) {
+ Date time = TIME_FORMAT.parse(data);
+ row.add(new java.sql.Time(time.getTime()));
+ }
} catch(ParseException e) {
Object[] params = new Object[] { data, e.getMessage() };
LogManager.logWarning(LogConstants.CTX_CONNECTOR, YahooPlugin.Util.gs(YahooPlugin.Event.TEIID14002, params));
@@ -231,12 +234,13 @@
/**
* @param select
* @return
+ * @throws TranslatorException
*/
- static int[] getNeededColumns(List<DerivedColumn> select, RuntimeMetadata metadata) throws TranslatorException {
+ static int[] getNeededColumns(List<DerivedColumn> select) throws TranslatorException {
int[] cols = new int[select.size()];
- Iterator iter = select.iterator();
+ Iterator<DerivedColumn> iter = select.iterator();
for(int i=0; iter.hasNext(); i++) {
- DerivedColumn symbol = (DerivedColumn) iter.next();
+ DerivedColumn symbol = iter.next();
Expression expr = symbol.getExpression();
if(expr instanceof ColumnReference) {
Column element = ((ColumnReference)expr).getMetadataObject();
@@ -250,22 +254,19 @@
}
@Override
- public List next() throws TranslatorException, DataNotAvailableException {
- if (returnIndex < results.size()) {
- List row = (List) results.get(returnIndex++);
- return projectRow(row, neededColumns);
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ if (results.hasNext()) {
+ return projectRow(results.next(), neededColumns);
}
-
return null;
}
-
/**
* @param row
* @param neededColumns
*/
- static List projectRow(List row, int[] neededColumns) {
- List output = new ArrayList(neededColumns.length);
+ static List<Object> projectRow(List<?> row, int[] neededColumns) {
+ List<Object> output = new ArrayList<Object>(neededColumns.length);
for(int i=0; i<neededColumns.length; i++) {
output.add(row.get(neededColumns[i]-1));
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -23,15 +23,15 @@
package org.teiid.translator.yahoo;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
import org.teiid.core.types.DataTypeManager;
import org.teiid.language.QueryExpression;
import org.teiid.language.Select;
+import org.teiid.metadata.Column;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.Table;
+import org.teiid.metadata.Column.SearchType;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.ResultSetExecution;
@@ -53,13 +53,9 @@
@Override
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)
throws TranslatorException {
- return new YahooExecution((Select)command, metadata);
+ return new YahooExecution((Select)command);
}
- public List getSupportedFunctions() {
- return Collections.EMPTY_LIST;
- }
-
public boolean supportsCompareCriteriaEquals() {
return true;
}
@@ -77,14 +73,22 @@
public void getMetadata(MetadataFactory metadataFactory, Object connection) throws TranslatorException {
Table t = metadataFactory.addTable("Stock"); //$NON-NLS-1$
metadataFactory.addColumn("symbol", DataTypeManager.DefaultDataTypes.STRING, t); //$NON-NLS-1$
- metadataFactory.addColumn("last", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
- metadataFactory.addColumn("date", DataTypeManager.DefaultDataTypes.DATE, t); //$NON-NLS-1$
- metadataFactory.addColumn("time", DataTypeManager.DefaultDataTypes.TIME, t); //$NON-NLS-1$
- metadataFactory.addColumn("change", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
- metadataFactory.addColumn("open", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
- metadataFactory.addColumn("high", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
- metadataFactory.addColumn("low", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
- metadataFactory.addColumn("volume", DataTypeManager.DefaultDataTypes.BIG_INTEGER, t); //$NON-NLS-1$
+ Column c = metadataFactory.addColumn("last", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ c.setSearchType(SearchType.Unsearchable);
+ c = metadataFactory.addColumn("date", DataTypeManager.DefaultDataTypes.DATE, t); //$NON-NLS-1$
+ c.setSearchType(SearchType.Unsearchable);
+ c = metadataFactory.addColumn("time", DataTypeManager.DefaultDataTypes.TIME, t); //$NON-NLS-1$
+ c.setSearchType(SearchType.Unsearchable);
+ c = metadataFactory.addColumn("change", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ c.setSearchType(SearchType.Unsearchable);
+ c = metadataFactory.addColumn("open", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ c.setSearchType(SearchType.Unsearchable);
+ c = metadataFactory.addColumn("high", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ c.setSearchType(SearchType.Unsearchable);
+ c = metadataFactory.addColumn("low", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ c.setSearchType(SearchType.Unsearchable);
+ c = metadataFactory.addColumn("volume", DataTypeManager.DefaultDataTypes.BIG_INTEGER, t); //$NON-NLS-1$
+ c.setSearchType(SearchType.Unsearchable);
metadataFactory.addAccessPattern("needs_symbol", Arrays.asList("symbol"), t); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -69,6 +69,7 @@
import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.SourceHint;
@@ -163,22 +164,22 @@
return eventDistributor;
}
- public TupleSource registerRequest(CommandContext context, Command command, String modelName, String connectorBindingId, int nodeID, int limit) throws TeiidComponentException, TeiidProcessingException {
+ public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException, TeiidProcessingException {
RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)context.getProcessorID());
if(CoreConstants.SYSTEM_MODEL.equals(modelName) || CoreConstants.SYSTEM_ADMIN_MODEL.equals(modelName)) {
return processSystemQuery(context, command, workItem.getDqpWorkContext());
}
- AtomicRequestMessage aqr = createRequest(workItem, command, modelName, connectorBindingId, nodeID);
+ AtomicRequestMessage aqr = createRequest(workItem, command, modelName, parameterObject.connectorBindingId, parameterObject.nodeID);
aqr.setCommandContext(context);
SourceHint sh = context.getSourceHint();
if (sh != null) {
aqr.setGeneralHint(sh.getGeneralHint());
aqr.setHint(sh.getSourceHint(aqr.getConnectorName()));
}
- if (limit > 0) {
- aqr.setFetchSize(Math.min(limit, aqr.getFetchSize()));
+ if (parameterObject.limit > 0) {
+ aqr.setFetchSize(Math.min(parameterObject.limit, aqr.getFetchSize()));
}
if (context.getDataObjects() != null) {
for (GroupSymbol gs : GroupCollectorVisitor.getGroupsIgnoreInlineViews(command, false)) {
@@ -188,7 +189,7 @@
ConnectorManagerRepository cmr = workItem.getDqpWorkContext().getVDB().getAttachment(ConnectorManagerRepository.class);
ConnectorWork work = cmr.getConnectorManager(aqr.getConnectorName()).registerRequest(aqr);
work.setRequestWorkItem(workItem);
- return new DataTierTupleSource(aqr, workItem, work, this, limit);
+ return new DataTierTupleSource(aqr, workItem, work, this, parameterObject.limit);
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -68,6 +68,7 @@
public static final String PROP_GROUP_COLS = "Grouping Columns"; //$NON-NLS-1$
public static final String PROP_SQL = "Query"; //$NON-NLS-1$
public static final String PROP_MODEL_NAME = "Model Name"; //$NON-NLS-1$
+ public static final String PROP_SHARING_ID = "Sharing ID"; //$NON-NLS-1$
public static final String PROP_DEPENDENT = "Dependent Join"; //$NON-NLS-1$
public static final String PROP_JOIN_STRATEGY = "Join Strategy"; //$NON-NLS-1$
public static final String PROP_JOIN_TYPE = "Join Type"; //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -34,6 +35,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.id.IDGenerator;
import org.teiid.core.util.Assertion;
+import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -49,6 +51,7 @@
import org.teiid.query.optimizer.relational.rules.RuleAssignOutputElements;
import org.teiid.query.optimizer.relational.rules.RuleChooseJoinStrategy;
import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.processor.relational.*;
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
@@ -61,10 +64,13 @@
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.WindowFunction;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.EvaluatableVisitor;
import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.sql.visitor.EvaluatableVisitor.EvaluationLevel;
public class PlanToProcessConverter {
@@ -73,6 +79,15 @@
private AnalysisRecord analysisRecord;
private CapabilitiesFinder capFinder;
+ private Map<List<Object>, AccessNode> sharedCommands = new HashMap<List<Object>, AccessNode>();
+ private Map<List<Object>, Integer> topCount = new HashMap<List<Object>, Integer>();
+ private int sharedId;
+
+ public static class SharedStateKey {
+ int id;
+ int expectedReaders;
+ }
+
public PlanToProcessConverter(QueryMetadataInterface metadata, IDGenerator idGenerator, AnalysisRecord analysisRecord, CapabilitiesFinder capFinder) {
this.metadata = metadata;
this.idGenerator = idGenerator;
@@ -82,23 +97,27 @@
public RelationalPlan convert(PlanNode planNode)
throws QueryPlannerException, TeiidComponentException {
-
- boolean debug = analysisRecord.recordDebug();
- if(debug) {
- analysisRecord.println("\n============================================================================"); //$NON-NLS-1$
- analysisRecord.println("CONVERTING PLAN TREE TO PROCESS TREE"); //$NON-NLS-1$
- }
-
- // Convert plan tree nodes into process tree nodes
- RelationalNode processNode = convertPlan(planNode);
- if(debug) {
- analysisRecord.println("\nPROCESS PLAN = \n" + processNode); //$NON-NLS-1$
- analysisRecord.println("============================================================================"); //$NON-NLS-1$
- }
-
- RelationalPlan processPlan = new RelationalPlan(processNode);
- return processPlan;
-
+ try {
+ boolean debug = analysisRecord.recordDebug();
+ if(debug) {
+ analysisRecord.println("\n============================================================================"); //$NON-NLS-1$
+ analysisRecord.println("CONVERTING PLAN TREE TO PROCESS TREE"); //$NON-NLS-1$
+ }
+
+ // Convert plan tree nodes into process tree nodes
+ RelationalNode processNode = convertPlan(planNode);
+ if(debug) {
+ analysisRecord.println("\nPROCESS PLAN = \n" + processNode); //$NON-NLS-1$
+ analysisRecord.println("============================================================================"); //$NON-NLS-1$
+ }
+
+ RelationalPlan processPlan = new RelationalPlan(processNode);
+ return processPlan;
+ } finally {
+ sharedCommands.clear();
+ topCount.clear();
+ sharedId = 0;
+ }
}
private RelationalNode convertPlan(PlanNode planNode)
@@ -273,7 +292,7 @@
AccessNode aNode = null;
Command command = (Command) node.getProperty(NodeConstants.Info.ATOMIC_REQUEST);
Object modelID = node.getProperty(NodeConstants.Info.MODEL_ID);
-
+ EvaluatableVisitor ev = null;
if(node.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)) {
if (command instanceof StoredProcedure) {
List references = (List)node.getProperty(NodeConstants.Info.PROCEDURE_INPUTS);
@@ -310,7 +329,8 @@
} catch (QueryMetadataException err) {
throw new TeiidComponentException(QueryPlugin.Event.TEIID30248, err);
}
- aNode.setShouldEvaluateExpressions(EvaluatableVisitor.needsProcessingEvaluation(command));
+ ev = EvaluatableVisitor.needsEvaluation(command);
+ aNode.setShouldEvaluateExpressions(ev.requiresEvaluation(EvaluationLevel.PROCESSING));
}
if (command instanceof QueryCommand) {
@@ -330,6 +350,45 @@
aNode.minimizeProject(command);
}
setRoutingName(aNode, node);
+ //check if valid to share this with other nodes
+ if (ev != null && ev.getDeterminismLevel().compareTo(Determinism.COMMAND_DETERMINISTIC) >= 0 && command.returnsResultSet()) {
+ //create a top level key to avoid the full command toString
+ String modelName = aNode.getModelName();
+ Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, true);
+ List<Object> topKey = new ArrayList<Object>(groups.size() + 1);
+ topKey.add(modelName);
+ for (GroupSymbol groupSymbol : groups) {
+ topKey.add(groupSymbol.toString());
+ }
+
+ AccessNode other = sharedCommands.get(topKey);
+ if (other == null) {
+ sharedCommands.put(topKey, aNode);
+ topCount.put(topKey, 1);
+ } else {
+ int count = topCount.get(topKey);
+ if (count == 1) {
+ Command c = other.getCommand();
+ List<Object> key = getCommandKey(c);
+ sharedCommands.put(key, other);
+ }
+ topCount.put(topKey, ++count);
+ Command c = aNode.getCommand();
+ List<Object> key = getCommandKey(c);
+
+ AccessNode initial = this.sharedCommands.get(key);
+ if (initial != null) {
+ if (initial.info == null) {
+ initial.info = new RegisterRequestParameter.SharedAccessInfo();
+ initial.info.id = sharedId++;
+ }
+ initial.info.sharingCount++;
+ aNode.info = initial.info;
+ } else {
+ this.sharedCommands.put(key, aNode);
+ }
+ }
+ }
}
break;
@@ -491,6 +550,14 @@
return processNode;
}
+ private List<Object> getCommandKey(Command c) {
+ List<Reference> refs = ReferenceCollectorVisitor.getReferences(c);
+ List<Object> key = new ArrayList<Object>(2);
+ key.add(c.toString());
+ key.add(refs);
+ return key;
+ }
+
private void updateGroupName(PlanNode node, TableFunctionReference tt) {
String groupName = node.getGroups().iterator().next().getName();
tt.getGroupSymbol().setName(groupName);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/ProcessorDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/ProcessorDataManager.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/ProcessorDataManager.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -33,7 +33,7 @@
public interface ProcessorDataManager {
- TupleSource registerRequest(CommandContext context, Command command, String modelName, String connectorBindingId, int nodeID, int limit)
+ TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject)
throws TeiidComponentException, TeiidProcessingException;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -22,30 +22,36 @@
package org.teiid.query.processor;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBatch;
import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
import org.teiid.common.buffer.BufferManager.BufferReserveMode;
+import org.teiid.common.buffer.BufferManager.TupleSourceType;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.Assertion;
+import org.teiid.events.EventDistributor;
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.BatchCollector.BatchProducer;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.util.CommandContext;
/**
* Driver for plan processing.
*/
-public class QueryProcessor implements BatchProducer {
-
+public class QueryProcessor implements BatchProducer, ProcessorDataManager {
+
public static class ExpiredTimeSliceException extends TeiidRuntimeException {
private static final long serialVersionUID = 4585044674826578060L;
}
@@ -56,6 +62,56 @@
QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext, Object... params) throws TeiidProcessingException, TeiidComponentException;
}
+ private class SharedState {
+ TupleBuffer tb;
+ TupleSource ts;
+ int id;
+ int expectedReaders;
+
+ private void remove() {
+ ts.closeSource();
+ tb.remove();
+ tb = null;
+ ts = null;
+ }
+ }
+
+ private final class BufferedTupleSource implements TupleSource {
+ private int rowNumber = 1;
+ private SharedState state;
+
+ private BufferedTupleSource(SharedState state) {
+ this.state = state;
+ }
+
+ @Override
+ public List<?> nextTuple() throws TeiidComponentException,
+ TeiidProcessingException {
+ if (rowNumber <= state.tb.getRowCount()) {
+ return state.tb.getBatch(rowNumber).getTuple(rowNumber++);
+ }
+ if (state.tb.isFinal()) {
+ return null;
+ }
+ List<?> row = state.ts.nextTuple();
+ if (row == null) {
+ state.tb.setFinal(true);
+ } else {
+ this.state.tb.addTuple(row);
+ rowNumber++;
+ }
+ return row;
+ }
+
+ @Override
+ public void closeSource() {
+ if (--state.expectedReaders == 0) {
+ state.remove();
+ sharedStates.remove(state.id);
+ }
+ }
+ }
+
private CommandContext context;
private ProcessorDataManager dataMgr;
private BufferManager bufferMgr;
@@ -69,6 +125,8 @@
private boolean processorClosed;
private boolean continuous;
private int rowOffset = 1;
+
+ Map<Integer, SharedState> sharedStates;
/**
* Construct a processor with all necessary information to process.
@@ -78,9 +136,9 @@
* @param dataMgr The data manager that provides access to get data
* @throws TeiidComponentException
*/
- public QueryProcessor(ProcessorPlan plan, CommandContext context, BufferManager bufferMgr, ProcessorDataManager dataMgr) throws TeiidComponentException {
+ public QueryProcessor(ProcessorPlan plan, CommandContext context, BufferManager bufferMgr, final ProcessorDataManager dataMgr) {
this.context = context;
- this.dataMgr = dataMgr;
+ this.dataMgr = dataMgr;
this.processPlan = plan;
this.bufferMgr = bufferMgr;
}
@@ -187,7 +245,7 @@
// initialize if necessary
if(!initialized) {
reserved = this.bufferMgr.reserveBuffers(this.bufferMgr.getSchemaSize(this.getOutputElements()), BufferReserveMode.FORCE);
- this.processPlan.initialize(context, this.dataMgr, bufferMgr);
+ this.processPlan.initialize(context, this, bufferMgr);
initialized = true;
}
@@ -208,6 +266,12 @@
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "QueryProcessor: closing processor"); //$NON-NLS-1$
}
+ if (sharedStates != null) {
+ for (SharedState ss : sharedStates.values()) {
+ ss.remove();
+ }
+ sharedStates = null;
+ }
this.bufferMgr.releaseBuffers(reserved);
reserved = 0;
processorClosed = true;
@@ -282,4 +346,40 @@
public void setContinuous(boolean continuous) {
this.continuous = continuous;
}
+
+ @Override
+ public Object lookupCodeValue(CommandContext ctx, String codeTableName,
+ String returnElementName, String keyElementName, Object keyValue)
+ throws BlockedException, TeiidComponentException,
+ TeiidProcessingException {
+ return dataMgr.lookupCodeValue(ctx, codeTableName, returnElementName, keyElementName, keyValue);
+ }
+
+ @Override
+ public EventDistributor getEventDistributor() {
+ return dataMgr.getEventDistributor();
+ }
+
+ @Override
+ public TupleSource registerRequest(CommandContext ctx, Command command,
+ String modelName, RegisterRequestParameter parameterObject)
+ throws TeiidComponentException, TeiidProcessingException {
+ if (parameterObject.info == null) {
+ return dataMgr.registerRequest(ctx, command, modelName, parameterObject);
+ }
+ //begin handling of shared commands
+ if (sharedStates == null) {
+ sharedStates = new HashMap<Integer, SharedState>();
+ }
+ SharedState state = sharedStates.get(parameterObject.info.id);
+ if (state == null) {
+ state = new SharedState();
+ state.expectedReaders = parameterObject.info.sharingCount;
+ state.tb = QueryProcessor.this.bufferMgr.createTupleBuffer(command.getProjectedSymbols(), ctx.getConnectionId(), TupleSourceType.PROCESSOR);
+ state.ts = dataMgr.registerRequest(ctx, command, modelName, new RegisterRequestParameter(parameterObject.connectorBindingId, 0, -1));
+ state.id = parameterObject.info.id;
+ sharedStates.put(parameterObject.info.id, state);
+ }
+ return new BufferedTupleSource(state);
+ }
}
Added: trunk/engine/src/main/java/org/teiid/query/processor/RegisterRequestParameter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/RegisterRequestParameter.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/RegisterRequestParameter.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.processor;
+
+public class RegisterRequestParameter {
+
+ public static class SharedAccessInfo {
+ public int id;
+ public int sharingCount = 1;
+ }
+
+ public String connectorBindingId;
+ public int nodeID = 0;
+ public int limit = -1;
+ public SharedAccessInfo info;
+
+ public RegisterRequestParameter(String connectorBindingId, int nodeID,
+ int limit) {
+ this.connectorBindingId = connectorBindingId;
+ this.nodeID = nodeID;
+ this.limit = limit;
+ }
+
+ public RegisterRequestParameter() {
+ }
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/query/processor/RegisterRequestParameter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -51,6 +51,7 @@
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.ProcedureReservedWords;
@@ -209,7 +210,7 @@
c.setRuntimeType(DataTypeManager.getDataTypeName(es.getType()));
create.getColumns().add(c);
}
- procEnv.getDataManager().registerRequest(procEnv.getContext(), create, TempMetadataAdapter.TEMP_MODEL.getName(), null, 0, -1);
+ procEnv.getDataManager().registerRequest(procEnv.getContext(), create, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -66,6 +66,7 @@
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.processor.relational.SubqueryAwareEvaluator;
import org.teiid.query.sql.ProcedureReservedWords;
import org.teiid.query.sql.lang.Command;
@@ -161,9 +162,9 @@
@Override
public TupleSource registerRequest(CommandContext context, Command command,
- String modelName, String connectorBindingId, int nodeID, int limit)
+ String modelName, RegisterRequestParameter parameterObject)
throws TeiidComponentException, TeiidProcessingException {
- TupleSource ts = parentDataMrg.registerRequest(context, command, modelName, connectorBindingId, nodeID, limit);
+ TupleSource ts = parentDataMrg.registerRequest(context, command, modelName, parameterObject);
if (blockContext != null && ts instanceof DataTierTupleSource) {
txnTupleSources.add(new WeakReference<DataTierTupleSource>((DataTierTupleSource)ts));
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -43,6 +43,7 @@
import org.teiid.query.eval.Evaluator;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.OrderByItem;
@@ -74,6 +75,8 @@
private Object[] projection;
private List<Expression> originalSelect;
private Object modelId;
+
+ public RegisterRequestParameter.SharedAccessInfo info;
protected AccessNode() {
super();
@@ -328,7 +331,7 @@
}
@Override
- protected void addBatchRow(List row) {
+ protected void addBatchRow(List<?> row) {
if (this.getOutputElements().isEmpty()) {
//a dummy column was added to the query, just remove it now
row = Collections.emptyList();
@@ -362,7 +365,9 @@
limit = parent.getLimit() + parent.getOffset();
}
}
- tupleSources.add(getDataManager().registerRequest(getContext(), atomicCommand, modelName, connectorBindingId, getID(), limit));
+ RegisterRequestParameter param = new RegisterRequestParameter(connectorBindingId, getID(), limit);
+ param.info = info;
+ tupleSources.add(getDataManager().registerRequest(getContext(), atomicCommand, modelName, param));
if (tupleSources.size() > 1) {
reserved += getBufferManager().reserveBuffers(schemaSize, BufferReserveMode.FORCE);
}
@@ -393,6 +398,9 @@
protected void getNodeString(StringBuffer str) {
super.getNodeString(str);
str.append(command);
+ if (this.info != null) {
+ str.append(" [SHARED ").append(this.info.id).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
public Object clone(){
@@ -412,12 +420,16 @@
target.originalSelect = source.originalSelect;
}
target.command = source.command;
+ target.info = source.info;
}
public PlanNode getDescriptionProperties() {
PlanNode props = super.getDescriptionProperties();
props.addProperty(PROP_SQL, this.command.toString());
props.addProperty(PROP_MODEL_NAME, this.modelName);
+ if (this.info != null) {
+ props.addProperty(PROP_SHARING_ID, String.valueOf(this.info.id));
+ }
return props;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/BatchedUpdateNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/BatchedUpdateNode.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/BatchedUpdateNode.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -36,6 +36,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.Evaluator;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.util.VariableContext;
@@ -113,7 +114,7 @@
}
if (!commandsToExecute.isEmpty()) {
BatchedUpdateCommand command = new BatchedUpdateCommand(commandsToExecute);
- tupleSource = getDataManager().registerRequest(getContext(), command, modelName, null, getID(), -1);
+ tupleSource = getDataManager().registerRequest(getContext(), command, modelName, new RegisterRequestParameter(null, getID(), -1));
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -38,6 +38,7 @@
import org.teiid.common.buffer.BufferManager.TupleSourceType;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Insert;
@@ -209,7 +210,7 @@
}
private void registerRequest(Command command) throws TeiidComponentException, TeiidProcessingException {
- tupleSource = getDataManager().registerRequest(getContext(), command, this.modelName, null, getID(), -1);
+ tupleSource = getDataManager().registerRequest(getContext(), command, this.modelName, new RegisterRequestParameter(null, getID(), -1));
}
private void closeRequest() {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -39,6 +39,7 @@
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.processor.relational.ProjectIntoNode.Mode;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.Create;
@@ -148,13 +149,13 @@
Create create = new Create();
create.setElementSymbolsAsColumns(withCommand.getColumns());
create.setTable(withCommand.getGroupSymbol());
- this.root.getDataManager().registerRequest(getContext(), create, TempMetadataAdapter.TEMP_MODEL.getID(), null, 0, -1);
+ this.root.getDataManager().registerRequest(getContext(), create, TempMetadataAdapter.TEMP_MODEL.getID(), new RegisterRequestParameter());
}
while (true) {
TupleBatch batch = withProcessor.nextBatch();
Insert insert = new Insert(withCommand.getGroupSymbol(), withCommand.getColumns(), null);
insert.setTupleSource(new CollectionTupleSource(batch.getTuples().iterator()));
- this.root.getDataManager().registerRequest(getContext(), insert, TempMetadataAdapter.TEMP_MODEL.getID(), null, 0, -1);
+ this.root.getDataManager().registerRequest(getContext(), insert, TempMetadataAdapter.TEMP_MODEL.getID(), new RegisterRequestParameter());
if (batch.getTerminationFlag()) {
break;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -39,6 +39,7 @@
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.util.VariableContext;
@@ -129,15 +130,15 @@
Insert insert = this.resultInfo.getTempInsert();
insert.setTupleSource(new TempLoadTupleSource());
- this.dataManager.registerRequest(this.internalProcessor.getContext(), insert, TempMetadataAdapter.TEMP_MODEL.getName(), null, 0, -1);
+ this.dataManager.registerRequest(this.internalProcessor.getContext(), insert, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
if (!doneLoading) {
throw BlockedException.block("Blocking on result set load"); //$NON-NLS-1$
}
internalProcessor.closeProcessing();
AlterTempTable att = new AlterTempTable(tempTable);
//mark the temp table as non-updatable
- this.dataManager.registerRequest(this.internalProcessor.getContext(), att, TempMetadataAdapter.TEMP_MODEL.getName(), null, 0, -1);
- this.tupleSource = this.dataManager.registerRequest(this.internalProcessor.getContext(), this.resultInfo.getTempSelect(), TempMetadataAdapter.TEMP_MODEL.getName(), null, 0, -1);
+ this.dataManager.registerRequest(this.internalProcessor.getContext(), att, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
+ this.tupleSource = this.dataManager.registerRequest(this.internalProcessor.getContext(), this.resultInfo.getTempSelect(), TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
}
//force execution
currentRow();
@@ -146,7 +147,7 @@
AlterTempTable att = new AlterTempTable(tempTable);
//TODO: if the parent is small, then this is not necessary
att.setIndexColumns(this.resultInfo.getFkColumns());
- this.dataManager.registerRequest(this.internalProcessor.getContext(), att, TempMetadataAdapter.TEMP_MODEL.getName(), null, 0, -1);
+ this.dataManager.registerRequest(this.internalProcessor.getContext(), att, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
}
this.currentRowNumber = 0;
@@ -220,7 +221,7 @@
LogManager.logDetail(LogConstants.CTX_XML_PLAN, "Unloading result set temp table", rsTempTable); //$NON-NLS-1$
internalProcessor.closeProcessing();
try {
- this.tupleSource = this.dataManager.registerRequest(this.internalProcessor.getContext(), this.resultInfo.getTempDrop(), TempMetadataAdapter.TEMP_MODEL.getName(), null, 0, -1);
+ this.tupleSource = this.dataManager.registerRequest(this.internalProcessor.getContext(), this.resultInfo.getTempDrop(), TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
} catch (TeiidProcessingException e) {
LogManager.logDetail(org.teiid.logging.LogConstants.CTX_XML_PLAN, e, "Error dropping result set temp table", rsTempTable); //$NON-NLS-1$
}
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 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -20,9 +20,6 @@
* 02110-1301 USA.
*/
-/**
- *
- */
package org.teiid.query.sql.visitor;
import java.util.TreeSet;
@@ -155,6 +152,8 @@
}
public void visit(DependentSetCriteria obj) {
+ //without knowing what is feeding this, we need to treat it as non-deterministic
+ setDeterminismLevel(Determinism.NONDETERMINISTIC);
evaluationNotPossible(EvaluationLevel.PROCESSING);
}
@@ -218,4 +217,22 @@
DeepPreOrderNavigator.doVisit(obj, visitor);
return visitor.levels.contains(EvaluationLevel.PROCESSING);
}
+
+ public boolean requiresEvaluation(EvaluationLevel evaluationLevel) {
+ return levels.contains(evaluationLevel);
+ }
+
+ public Determinism getDeterminismLevel() {
+ return determinismLevel;
+ }
+
+ public boolean hasCorrelatedReferences() {
+ return hasCorrelatedReferences;
+ }
+
+ public static final EvaluatableVisitor needsEvaluation(LanguageObject obj) {
+ EvaluatableVisitor visitor = new EvaluatableVisitor();
+ DeepPreOrderNavigator.doVisit(obj, visitor);
+ return visitor;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -67,6 +67,7 @@
import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.resolver.util.ResolverUtil;
import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.navigator.PostOrderNavigator;
@@ -122,7 +123,7 @@
CommandContext context,
Command command,
String modelName,
- String connectorBindingId, int nodeID, int limit)
+ RegisterRequestParameter parameterObject)
throws TeiidComponentException, TeiidProcessingException {
TempTableStore tempTableStore = context.getTempTableStore();
@@ -132,7 +133,7 @@
return result;
}
}
- return this.processorDataManager.registerRequest(context, command, modelName, connectorBindingId, nodeID, limit);
+ return this.processorDataManager.registerRequest(context, command, modelName, parameterObject);
}
TupleSource registerRequest(CommandContext context, String modelName, Command command) throws TeiidComponentException, TeiidProcessingException {
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -706,7 +706,7 @@
}
}
- public static DecimalFormat getDecimalFormat(CommandContext context, String format) {
+ public static DecimalFormat getDecimalFormat(CommandContext context, String format) {
DecimalFormat result = null;
if (context != null) {
if (context.globalState.decimalFormatCache == null) {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -59,6 +59,7 @@
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.translator.SourceSystemFunctions;
@SuppressWarnings("nls")
public class TestDQPCore {
@@ -397,13 +398,16 @@
@Test public void testSourceConcurrency() throws Exception {
//setup default of 2
agds.setSleep(100);
+ BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
+ bsc.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
+ agds.setCaps(bsc);
StringBuffer sql = new StringBuffer();
int branches = 20;
for (int i = 0; i < branches; i++) {
if (i > 0) {
sql.append(" union all ");
}
- sql.append("select intkey || " + i + " from bqt1.smalla");
+ sql.append("select stringkey || " + i + " from bqt1.smalla");
}
sql.append(" limit 2");
helpExecute(sql.toString(), "a");
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -48,6 +48,7 @@
import org.teiid.query.processor.HardcodedDataManager;
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.processor.TestProcessor;
import org.teiid.query.resolver.TestResolver;
import org.teiid.query.rewriter.QueryRewriter;
@@ -73,8 +74,8 @@
setMustRegisterCommands(false);
}
- public TupleSource registerRequest(CommandContext context, Command command, String modelName, String connectorBindingId, int nodeID, int limit) throws org.teiid.core.TeiidComponentException {
- assertNotNull(connectorBindingId);
+ public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws org.teiid.core.TeiidComponentException {
+ assertNotNull(parameterObject.connectorBindingId);
Collection<ElementSymbol> elements = ElementCollectorVisitor.getElements(command, true, true);
@@ -83,7 +84,7 @@
fail("Query Contains a MultiSourceElement -- MultiSource expansion did not happen"); //$NON-NLS-1$
}
}
- return super.registerRequest(context, command, modelName, connectorBindingId, nodeID, limit);
+ return super.registerRequest(context, command, modelName, parameterObject);
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -103,10 +103,10 @@
procTuples.put(proc, data);
}
- public TupleSource registerRequest(CommandContext context, Command command, String modelName, String connectorBindingId, int nodeID, int limit)
+ public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject)
throws TeiidComponentException {
- LogManager.logTrace(LOG_CONTEXT, new Object[]{"Register Request:", command, ",processorID:", context.getProcessorID(), ",model name:", modelName,",TupleSourceID nodeID:",new Integer(nodeID)}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ LogManager.logTrace(LOG_CONTEXT, new Object[]{"Register Request:", command, ",processorID:", context.getProcessorID(), ",model name:", modelName,",TupleSourceID nodeID:",new Integer(parameterObject.nodeID)}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
if (this.recordingCommands) {
if (! (command instanceof BatchedUpdateCommand) ) {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -120,13 +120,13 @@
}
/**
- * @see org.teiid.query.processor.ProcessorDataManager#registerRequest(CommandContext, org.teiid.query.sql.lang.Command, java.lang.String, String, int, int)
+ * @see org.teiid.query.processor.ProcessorDataManager#registerRequest(CommandContext, org.teiid.query.sql.lang.Command, java.lang.String, RegisterRequestParameter)
* @since 4.2
*/
public TupleSource registerRequest(CommandContext context,
Command command,
String modelName,
- String connectorBindingId, int nodeID, int limit) throws TeiidComponentException {
+ RegisterRequestParameter parameterObject) throws TeiidComponentException {
if(modelName != null && validModels != null && ! validModels.contains(modelName)) {
throw new TeiidComponentException("Detected query against invalid model: " + modelName + ": " + command); //$NON-NLS-1$//$NON-NLS-2$
Added: trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.processor;
+
+import static org.junit.Assert.*;
+import static org.teiid.query.processor.TestProcessor.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.query.unittest.RealMetadataFactory;
+
+@SuppressWarnings("nls")
+public class TestCommonTableOptimizations {
+
+ @Test public void testDuplicateSourceQuery() {
+ String sql = "SELECT e1 FROM pm1.g1 union all select e1 from pm1.g1"; //$NON-NLS-1$
+
+ List<?>[] expected = new List[] {
+ Arrays.asList("a"), //$NON-NLS-1$
+ Arrays.asList("b"), //$NON-NLS-1$
+ Arrays.asList("a"), //$NON-NLS-1$
+ Arrays.asList("b"), //$NON-NLS-1$
+ };
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT pm1.g1.e1 FROM pm1.g1", new List<?>[] {Arrays.asList("a"), Arrays.asList("b")});
+
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ assertEquals(3, dataManager.getCommandHistory().size());
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -754,7 +754,7 @@
@Override
public TupleSource registerRequest(CommandContext context,
Command command, String modelName,
- String connectorBindingId, int nodeID, int limit)
+ RegisterRequestParameter parameterObject)
throws TeiidComponentException {
if (command instanceof StoredProcedure) {
StoredProcedure proc = (StoredProcedure)command;
@@ -766,7 +766,7 @@
});
}
return super.registerRequest(context, command, modelName,
- connectorBindingId, nodeID, limit);
+ parameterObject);
}
};
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -91,7 +91,7 @@
@Override
public TupleSource registerRequest(CommandContext context,
Command command, String modelName,
- String connectorBindingId, int nodeID, int limit)
+ RegisterRequestParameter parameterObject)
throws TeiidComponentException {
if (general == null && hint == null) {
assertNull(context.getSourceHint());
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestBatchedUpdateNode.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/relational/TestBatchedUpdateNode.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestBatchedUpdateNode.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -42,6 +42,7 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.TestBatchedUpdatePlanner;
import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.visitor.EvaluatableVisitor;
@@ -214,10 +215,10 @@
this.numExecutedCommands = numExecutedCommands;
}
public Object lookupCodeValue(CommandContext context,String codeTableName,String returnElementName,String keyElementName,Object keyValue) throws BlockedException,TeiidComponentException {return null;}
- public TupleSource registerRequest(CommandContext context,Command command,String modelName,String connectorBindingId, int nodeID, int limit) throws TeiidComponentException {
+ public TupleSource registerRequest(CommandContext context,Command command,String modelName,RegisterRequestParameter parameterObject) throws TeiidComponentException {
assertEquals("myProcessorID", context.getProcessorID()); //$NON-NLS-1$
assertEquals("myModelName", modelName); //$NON-NLS-1$
- assertEquals(1, nodeID);
+ assertEquals(1, parameterObject.nodeID);
commands.add(command.toString());
actualCommands.add(command);
return new FakeTupleSource(numExecutedCommands);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectIntoNode.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectIntoNode.java 2012-06-27 17:07:54 UTC (rev 4208)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectIntoNode.java 2012-06-27 19:35:38 UTC (rev 4209)
@@ -39,6 +39,7 @@
import org.teiid.query.eval.Evaluator;
import org.teiid.query.processor.FakeTupleSource;
import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.processor.relational.ProjectIntoNode.Mode;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import org.teiid.query.sql.lang.Command;
@@ -127,7 +128,7 @@
this.expectedBatchSize = expectedBatchSize;
}
public Object lookupCodeValue(CommandContext context,String codeTableName,String returnElementName,String keyElementName,Object keyValue) throws BlockedException,TeiidComponentException {return null;}
- public TupleSource registerRequest(CommandContext context,Command command,String modelName,String connectorBindingId, int nodeID, int limit) throws TeiidComponentException, TeiidProcessingException {
+ public TupleSource registerRequest(CommandContext context,Command command,String modelName,RegisterRequestParameter parameterObject) throws TeiidComponentException, TeiidProcessingException {
callCount++;
int batchSize = 1;
12 years, 6 months
teiid SVN: r4208 - trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-27 13:07:54 -0400 (Wed, 27 Jun 2012)
New Revision: 4208
Added:
trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java
Log:
TEIID-2088 adding missing class
Added: trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java
===================================================================
--- trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java (rev 0)
+++ trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java 2012-06-27 17:07:54 UTC (rev 4208)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @author tags. See the COPYRIGHT.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package net.sf.retrotranslator.runtime.java.sql;
+
+public enum RowIdLifetime_ {
+ ROWID_UNSUPPORTED,
+ ROWID_VALID_OTHER,
+ ROWID_VALID_SESSION,
+ ROWID_VALID_TRANSACTION,
+ ROWID_VALID_FOREVER
+}
Property changes on: trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/sql/RowIdLifetime_.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 6 months
teiid SVN: r4207 - trunk/engine/src/test/java/org/teiid/query/optimizer.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-27 12:54:17 -0400 (Wed, 27 Jun 2012)
New Revision: 4207
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
Log:
TEIID-2087 fix for union planning
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2012-06-27 16:34:53 UTC (rev 4206)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2012-06-27 16:54:17 UTC (rev 4207)
@@ -410,12 +410,12 @@
}
@Test public void testSortOverUnion() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from (select max(e1) as e1 from pm1.g1 having 1 = 0) as y union all select e2 from pm1.g1 order by e1", //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from (select max(e1) as e1 from pm1.g1 having 1 = 0) as y union all select e2 from pm1.g1 union all select e1 from pm1.g1 order by e1", //$NON-NLS-1$
RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(),
new String[] {
- "SELECT pm1.g1.e2 FROM pm1.g1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ "SELECT pm1.g1.e2 FROM pm1.g1", "SELECT pm1.g1.e1 FROM pm1.g1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
+ 2, // Access
0, // DependentAccess
0, // DependentSelect
0, // DependentProject
@@ -428,7 +428,7 @@
1, // Project
0, // Select
1, // Sort
- 0 // UnionAll
+ 1 // UnionAll
});
}
12 years, 6 months
teiid SVN: r4206 - in trunk/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-06-27 12:34:53 -0400 (Wed, 27 Jun 2012)
New Revision: 4206
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
Log:
TEIID-2087 fix for union planning
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 2012-06-27 16:29:03 UTC (rev 4205)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2012-06-27 16:34:53 UTC (rev 4206)
@@ -280,16 +280,11 @@
}
correctOrderBy(frame, selectSymbols, parentProject);
+
PlanNode parentSource = NodeEditor.findParent(frame, NodeConstants.Types.SOURCE);
- PlanNode parentSetOp = NodeEditor.findParent(parentProject, NodeConstants.Types.SET_OP, NodeConstants.Types.SOURCE);
- if (parentSetOp == null || NodeEditor.findNodePreOrder(parentSetOp, NodeConstants.Types.PROJECT) == parentProject) {
- if (parentSource != null) {
- FrameUtil.correctSymbolMap(((SymbolMap)frame.getProperty(NodeConstants.Info.SYMBOL_MAP)).asMap(), parentSource);
- }
- if (parentSetOp != null) {
- correctOrderBy(frame, selectSymbols, parentSetOp);
- }
+ if (parentSource != null && NodeEditor.findNodePreOrder(parentSource, NodeConstants.Types.PROJECT) == parentProject) {
+ FrameUtil.correctSymbolMap(((SymbolMap)frame.getProperty(NodeConstants.Info.SYMBOL_MAP)).asMap(), parentSource);
}
prepareFrame(frame);
@@ -304,19 +299,22 @@
return root;
}
-
+ /**
+ * special handling is needed since we are retaining the child aliases
+ */
private static void correctOrderBy(PlanNode frame,
- List<Expression> selectSymbols, PlanNode startNode) {
- PlanNode sort = NodeEditor.findParent(startNode, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE | NodeConstants.Types.SET_OP);
- if (sort != null) { //special handling is needed since we are retaining the child aliases
- List<Expression> childProject = (List<Expression>)NodeEditor.findNodePreOrder(frame, NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
- OrderBy elements = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
- for (OrderByItem item : elements.getOrderByItems()) {
- item.setSymbol(childProject.get(selectSymbols.indexOf(item.getSymbol())));
- }
- sort.getGroups().clear();
- sort.addGroups(GroupsUsedByElementsVisitor.getGroups(elements));
+ List<Expression> selectSymbols, PlanNode parentProject) {
+ PlanNode sort = NodeEditor.findParent(parentProject, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
+ if (sort == null || NodeEditor.findNodePreOrder(sort, NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE) != parentProject) {
+ return;
}
+ List<Expression> childProject = (List<Expression>)NodeEditor.findNodePreOrder(frame, NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
+ OrderBy elements = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
+ for (OrderByItem item : elements.getOrderByItems()) {
+ item.setSymbol(childProject.get(selectSymbols.indexOf(item.getSymbol())));
+ }
+ sort.getGroups().clear();
+ sort.addGroups(GroupsUsedByElementsVisitor.getGroups(elements));
}
/**
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2012-06-27 16:29:03 UTC (rev 4205)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2012-06-27 16:34:53 UTC (rev 4206)
@@ -408,5 +408,28 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
+
+ @Test public void testSortOverUnion() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from (select max(e1) as e1 from pm1.g1 having 1 = 0) as y union all select e2 from pm1.g1 order by e1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(),
+ new String[] {
+ "SELECT pm1.g1.e2 FROM pm1.g1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ });
+ }
}
12 years, 6 months