Author: shawkins
Date: 2012-06-14 22:39:19 -0400 (Thu, 14 Jun 2012)
New Revision: 4179
Modified:
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java
trunk/engine/src/main/java/org/teiid/query/processor/ProcessorPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/RecurseProgramCondition.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/processor/FakeProcessorPlan.java
trunk/engine/src/test/java/org/teiid/query/processor/TestBaseProcessorPlan.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/FakeXMLProcessorEnvironment.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLProcessor.java
Log:
TEIID-2073 TEIID-2068 stopping short of implementing the full recursion record feature,
but moving the plan warning logic onto the CommandContext for ease of use.
Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-06-14 17:20:06 UTC
(rev 4178)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-06-15 02:39:19 UTC
(rev 4179)
@@ -524,5 +524,7 @@
TEIID31101,
TEIID31102,
TEIID31103,
+ TEIID31104, //recursion limit hit
+ TEIID31105, //warning
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java 2012-06-14
17:20:06 UTC (rev 4178)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -132,7 +132,7 @@
Program programPlan = XMLPlanToProcessVisitor.planProgram(planEnv.mappingDoc,
planEnv);
// create plan from program and initialized environment
- XMLProcessorEnvironment env = planEnv.createProcessorEnvironment(programPlan);
+ XMLProcessorEnvironment env = new XMLProcessorEnvironment(programPlan,
planEnv.documentGroup);
XMLPlan plan = new XMLPlan(env);
plan.setXMLSchemas(metadata.getXMLSchemas(group.getMetadataID()));
if(debug) {
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java 2012-06-14
17:20:06 UTC (rev 4178)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -35,8 +35,6 @@
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
-import org.teiid.query.processor.xml.Program;
-import org.teiid.query.processor.xml.XMLProcessorEnvironment;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.Symbol;
@@ -110,14 +108,6 @@
this.metadata = qmi;
}
- XMLProcessorEnvironment createProcessorEnvironment(Program mainProgram) {
- XMLProcessorEnvironment processorEnv = new XMLProcessorEnvironment(mainProgram);
-
- processorEnv.setDocumentGroup(documentGroup);
- return processorEnv;
- }
-
-
TempMetadataAdapter getGlobalMetadata() {
return new TempMetadataAdapter(metadata, this.globalTempMetadata,
this.stagingTableMap, this.queryNodeMap);
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/ProcessorPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/ProcessorPlan.java 2012-06-14
17:20:06 UTC (rev 4178)
+++ trunk/engine/src/main/java/org/teiid/query/processor/ProcessorPlan.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -24,7 +24,6 @@
import static org.teiid.query.analysis.AnalysisRecord.*;
-import java.util.ArrayList;
import java.util.List;
import org.teiid.client.plan.PlanNode;
@@ -55,8 +54,6 @@
*/
public abstract class ProcessorPlan implements Cloneable, BatchProducer {
- private List<Exception> warnings = null;
-
private CommandContext context;
/**
@@ -69,36 +66,20 @@
* @param dataMgr Data manager reference
* @param bufferMgr Buffer manager reference
*/
- public abstract void initialize(CommandContext context, ProcessorDataManager dataMgr,
BufferManager bufferMgr);
+ public void initialize(CommandContext context, ProcessorDataManager dataMgr,
BufferManager bufferMgr) {
+ this.context = context;
+ }
+ public void addWarning(TeiidException warning) {
+ if (context != null) {
+ context.addWarning(warning);
+ }
+ }
+
/**
- * Get all warnings found while processing this plan. These warnings may
- * be detected throughout the plan lifetime, which means new ones may arrive
- * at any time. This method returns all current warnings and clears
- * the current warnings list. The warnings are in order they were detected.
- * @return Current list of warnings, never null
- */
- public List<Exception> getAndClearWarnings() {
- if (warnings == null) {
- return null;
- }
- List<Exception> copied = warnings;
- warnings = null;
- return copied;
- }
-
- protected void addWarning(TeiidException warning) {
- if (warnings == null) {
- warnings = new ArrayList<Exception>(1);
- }
- warnings.add(warning);
- }
-
- /**
* Reset a plan so that it can be processed again.
*/
public void reset() {
- this.warnings = null;
}
/**
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-14
17:20:06 UTC (rev 4178)
+++ trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -226,7 +226,7 @@
}
public List<Exception> getAndClearWarnings() {
- return this.processPlan.getAndClearWarnings();
+ return this.context.getAndClearWarnings();
}
/**
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/xml/RecurseProgramCondition.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/xml/RecurseProgramCondition.java 2012-06-14
17:20:06 UTC (rev 4178)
+++
trunk/engine/src/main/java/org/teiid/query/processor/xml/RecurseProgramCondition.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -27,6 +27,8 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.lang.Criteria;
@@ -91,8 +93,13 @@
terminate = env.getProgramRecursionCount(this.getThenProgram()) >=
this.recursionLimit;
//handle the case of exception on recursion limit reached
- if (terminate && this.exceptionOnRecursionLimit){
- throw new TeiidComponentException(QueryPlugin.Event.TEIID30212,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30212));
+ if (terminate){
+ if (this.exceptionOnRecursionLimit) {
+ throw new TeiidComponentException(QueryPlugin.Event.TEIID30212,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30212));
+ }
+ //TODO: if record, then add a log/warning
+ //env.getProcessorContext().addWarning(new
TeiidException(QueryPlugin.Event.TEIID31104,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31104, recursionLimit)));
+ LogManager.logDetail(LogConstants.CTX_XML_PLAN,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31104, recursionLimit));
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2012-06-14
17:20:06 UTC (rev 4178)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -123,9 +123,9 @@
super.reset();
nextBatchCount = 1;
+ this.context = new XMLContext();
+ this.env = this.env.clone();
- this.env = (XMLProcessorEnvironment)this.env.clone();
-
LogManager.logTrace(LogConstants.CTX_XML_PLAN, "XMLPlan reset");
//$NON-NLS-1$
}
@@ -213,9 +213,7 @@
}
/**
- * Validate the document against the Apache Xerces parser
- * The constants in the code are specific to the Apache Xerces parser and must be
used
- * Known limitiation is when it is attempted to validate against multiple schemas
+ * Validate the document against
* @param xmlDoc
* @throws TeiidComponentException if the document cannot be validated against the
schema
*
@@ -282,9 +280,9 @@
// determine if we have any warnings, errors, or fatal errors and report as necessary
if (errorHandler.hasExceptions()) {
- List exceptionList = errorHandler.getExceptionList();
- for (Iterator i = exceptionList.iterator(); i.hasNext();) {
- addWarning((TeiidException)i.next());
+ List<TeiidException> exceptionList = errorHandler.getExceptionList();
+ for (Iterator<TeiidException> i = exceptionList.iterator(); i.hasNext();) {
+ addWarning(i.next());
}
}
}
@@ -455,7 +453,7 @@
* meaning the plan has finished processing.
*/
public XMLPlan clone(){
- XMLPlan xmlPlan = new XMLPlan((XMLProcessorEnvironment)this.env.clone());
+ XMLPlan xmlPlan = new XMLPlan(this.env.clone());
xmlPlan.xmlSchemas = this.xmlSchemas;
return xmlPlan;
}
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java 2012-06-14
17:20:06 UTC (rev 4178)
+++
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -65,8 +65,9 @@
protected XMLProcessorEnvironment(){
}
- public XMLProcessorEnvironment(Program mainProgram){
+ public XMLProcessorEnvironment(Program mainProgram, GroupSymbol docGroup){
pushProgram(mainProgram);
+ this.documentGroup = docGroup;
}
/**
@@ -262,7 +263,7 @@
return this.commandContext;
}
- public Object clone() {
+ public XMLProcessorEnvironment clone() {
XMLProcessorEnvironment clone = new XMLProcessorEnvironment();
copyIntoClone(clone);
return clone;
@@ -288,11 +289,6 @@
return this.documentGroup;
}
- public void setDocumentGroup(GroupSymbol documentGroup) {
- this.documentGroup = documentGroup;
- }
-
-
boolean isStagingTableLoaded(String tableName) {
return this.loadedStagingTables.contains(tableName);
}
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-14
17:20:06 UTC (rev 4178)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -25,15 +25,7 @@
import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.TimeZone;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;
@@ -47,6 +39,7 @@
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
import org.teiid.core.util.ArgCheck;
import org.teiid.core.util.ExecutorUtils;
import org.teiid.core.util.LRUCache;
@@ -151,6 +144,8 @@
private LRUCache<String, SimpleDateFormat> dateFormatCache;
private AtomicLong reuseCount = new AtomicLong();
private ClassLoader classLoader;
+
+ private List<Exception> warnings = null;
}
private GlobalState globalState = new GlobalState();
@@ -766,4 +761,29 @@
public void setVDBClassLoader(ClassLoader classLoader) {
this.globalState.classLoader = classLoader;
}
+
+ /**
+ * Get all warnings found while processing this plan. These warnings may
+ * be detected throughout the plan lifetime, which means new ones may arrive
+ * at any time. This method returns all current warnings and clears
+ * the current warnings list. The warnings are in order they were detected.
+ * @return Current list of warnings, never null
+ */
+ public List<Exception> getAndClearWarnings() {
+ if (globalState.warnings == null) {
+ return null;
+ }
+ List<Exception> copied = globalState.warnings;
+ globalState.warnings = null;
+ return copied;
+ }
+
+ public void addWarning(TeiidException warning) {
+ if (globalState.warnings == null) {
+ globalState.warnings = new ArrayList<Exception>(1);
+ }
+ LogManager.logInfo(LogConstants.CTX_DQP,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31105, warning.getMessage()));
+ globalState.warnings.add(warning);
+ }
+
}
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-06-14 17:20:06
UTC (rev 4178)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-06-15 02:39:19
UTC (rev 4179)
@@ -1023,3 +1023,6 @@
TEIID31101=Source names are not unique for model {0} in {1}.{2}
TEIID31102=Multiple sources on non multi-source model {0} in {1}.{2}
TEIID31103=There are different sources with the name {0} in {1}.{2}
+
+TEIID31104=Recursion limit of {0} reached.
+TEIID31105=Returing warning to client: {0}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/query/processor/FakeProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/FakeProcessorPlan.java 2012-06-14
17:20:06 UTC (rev 4178)
+++ trunk/engine/src/test/java/org/teiid/query/processor/FakeProcessorPlan.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -29,11 +29,9 @@
import java.util.List;
import org.teiid.common.buffer.BlockedException;
-import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBatch;
import org.teiid.core.TeiidComponentException;
import org.teiid.query.sql.lang.Command;
-import org.teiid.query.util.CommandContext;
/**
@@ -80,17 +78,6 @@
}
/**
- * @see
org.teiid.query.processor.ProcessorPlan#initialize(org.teiid.query.processor.ProcessorDataManager,
java.lang.Object, org.teiid.common.buffer.BufferManager, java.lang.String, int)
- */
- public void initialize(
- CommandContext context,
- ProcessorDataManager dataMgr,
- BufferManager bufferMgr) {
-
- // nothing
- }
-
- /**
* @see org.teiid.query.processor.ProcessorPlan#getOutputElements()
*/
public List getOutputElements() {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestBaseProcessorPlan.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestBaseProcessorPlan.java 2012-06-14
17:20:06 UTC (rev 4178)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestBaseProcessorPlan.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -22,28 +22,28 @@
package org.teiid.query.processor;
+import static org.junit.Assert.*;
+
import java.util.Collections;
import java.util.List;
+import org.junit.Test;
import org.teiid.core.TeiidException;
+import org.teiid.query.util.CommandContext;
-import junit.framework.TestCase;
+public class TestBaseProcessorPlan {
-public class TestBaseProcessorPlan extends TestCase {
-
- public TestBaseProcessorPlan(String name) {
- super(name);
- }
-
- public void testGetAndClearWarnings() {
+ @Test public void testGetAndClearWarnings() {
FakeProcessorPlan plan = new FakeProcessorPlan(Collections.emptyList(),
Collections.emptyList());
+ CommandContext cc = new CommandContext();
+ plan.initialize(cc, null, null);
TeiidException warning = new TeiidException("test"); //$NON-NLS-1$
plan.addWarning(warning);
- List warnings = plan.getAndClearWarnings();
+ List<Exception> warnings = cc.getAndClearWarnings();
assertEquals("Did not get expected number of warnings", 1,
warnings.size()); //$NON-NLS-1$
assertEquals("Did not get expected warning", warning, warnings.get(0));
//$NON-NLS-1$
- assertNull("Did not clear warnings from plan",
plan.getAndClearWarnings()); //$NON-NLS-1$
+ assertNull("Did not clear warnings from plan",
cc.getAndClearWarnings()); //$NON-NLS-1$
}
}
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/xml/FakeXMLProcessorEnvironment.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/xml/FakeXMLProcessorEnvironment.java 2012-06-14
17:20:06 UTC (rev 4178)
+++
trunk/engine/src/test/java/org/teiid/query/processor/xml/FakeXMLProcessorEnvironment.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -53,7 +53,8 @@
/**
* @see ProcessorEnvironment#clone()
*/
- public Object clone() {
+ @Override
+ public FakeXMLProcessorEnvironment clone() {
FakeXMLProcessorEnvironment clone = new FakeXMLProcessorEnvironment();
super.copyIntoClone(clone);
clone.dataMap = this.dataMap;
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLProcessor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLProcessor.java 2012-06-14
17:20:06 UTC (rev 4178)
+++
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLProcessor.java 2012-06-15
02:39:19 UTC (rev 4179)
@@ -5719,10 +5719,9 @@
* termination criteria - should the chunk of document that meets the
* criteria be included or not? In this test below, it is expected to
* be included, but is not included in actual results due to recent
- * changes for Booz Allen POC. I could see it going either way.
+ * changes. I could see it going either way.
*
- * sbale 4/27/05 I have changed expected results as a result of changes for
- * Booz Allen POC. Previously, the recursive fragment of the document that
+ * sbale 4/27/05 Previously, the recursive fragment of the document that
* satisfied the recursion termination criteria was included, now it is not.
* See commented out section below for previous expected results.
* @throws Exception
@@ -5905,8 +5904,7 @@
}
/**
- * sbale 4/27/05 I have changed expected results as a result of changes for
- * Booz Allen POC. Previously, the recursive fragment of the document that
+ * sbale 4/27/05. Previously, the recursive fragment of the document that
* satisfied the recursion termination criteria was included, now it is not.
* See commented out section below for previous expected results.
* @throws Exception