teiid SVN: r4045 - in branches/8.0.x: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-30 14:58:11 -0400 (Mon, 30 Apr 2012)
New Revision: 4045
Modified:
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
branches/8.0.x/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
branches/8.0.x/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
Log:
TEIID-2020 fix for sybase procedure issue
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -53,6 +53,7 @@
protected Connection connection;
protected ExecutionContext context;
protected JDBCExecutionFactory executionFactory;
+ protected Command command;
// Derived from properties
protected boolean trimString;
@@ -65,7 +66,7 @@
// Constructors
// ===========================================================================================================================
- protected JDBCBaseExecution(Connection connection, ExecutionContext context, JDBCExecutionFactory jef) {
+ protected JDBCBaseExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory jef) {
this.connection = connection;
this.context = context;
@@ -73,6 +74,7 @@
trimString = jef.isTrimStrings();
fetchSize = context.getBatchSize();
+ this.command = command;
}
/**
@@ -143,7 +145,7 @@
protected void setSizeContraints(Statement statement) {
try {
- statement.setFetchSize(fetchSize);
+ executionFactory.setFetchSize(command, context, statement, fetchSize);
} catch (SQLException e) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestId(), " could not set fetch size: ", fetchSize); //$NON-NLS-1$
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -30,6 +30,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.MessageFormat;
@@ -1124,8 +1125,24 @@
return nameParts;
}
+ /**
+ * Get the predicate name for LIKE_REGEX
+ * @return
+ */
public String getLikeRegexString() {
return SQLConstants.Reserved.LIKE_REGEX;
}
+
+ /**
+ * Set the fetch size on the given statement.
+ * @param context
+ * @param command
+ * @param statement
+ * @param fetchSize
+ * @throws SQLException
+ */
+ public void setFetchSize(Command command, ExecutionContext context, Statement statement, int fetchSize) throws SQLException {
+ statement.setFetchSize(fetchSize);
+ }
}
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -52,7 +52,6 @@
// ===========================================================================================================================
protected ResultSet results;
- protected Command command;
protected Class<?>[] columnDataTypes;
// ===========================================================================================================================
@@ -60,8 +59,7 @@
// ===========================================================================================================================
public JDBCQueryExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env) {
- super(connection, context, env);
- this.command = command;
+ super(command, connection, context, env);
}
@Override
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -43,7 +43,6 @@
*/
public class JDBCUpdateExecution extends JDBCBaseExecution implements UpdateExecution {
- private Command command;
private int[] result;
/**
@@ -54,8 +53,7 @@
* @param id
*/
public JDBCUpdateExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env) {
- super(connection, context, env);
- this.command = command;
+ super(command, connection, context, env);
}
// ===========================================================================================================================
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -287,4 +287,9 @@
return true;
}
+ @Override
+ protected boolean setFetchSizeOnCallableStatements() {
+ return true;
+ }
+
}
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -24,7 +24,10 @@
*/
package org.teiid.translator.jdbc.sybase;
+import java.sql.CallableStatement;
import java.sql.Date;
+import java.sql.SQLException;
+import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
@@ -34,13 +37,16 @@
import java.util.List;
import java.util.Map;
+import org.teiid.language.Command;
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.Literal;
import org.teiid.language.SQLConstants;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TranslatorProperty;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
@@ -58,6 +64,7 @@
public static final String FIFTEEN_5 = "15.5"; //$NON-NLS-1$
protected Map<String, Integer> formatMap = new HashMap<String, Integer>();
+ protected boolean jtdsDriver;
public SybaseExecutionFactory() {
setDatabaseVersion(TWELVE_5);
@@ -365,5 +372,27 @@
public boolean supportsRowLimit() {
return getDatabaseVersion().compareTo(FIFTEEN_0_2) >= 0;
}
+
+ @TranslatorProperty(display="JTDS Driver", description="True if the driver is the JTDS driver",advanced=true)
+ public boolean isJtdsDriver() {
+ return jtdsDriver;
+ }
+
+ public void setJtdsDriver(boolean jtdsDriver) {
+ this.jtdsDriver = jtdsDriver;
+ }
+
+ protected boolean setFetchSizeOnCallableStatements() {
+ return false;
+ }
+
+ @Override
+ public void setFetchSize(Command command, ExecutionContext context,
+ Statement statement, int fetchSize) throws SQLException {
+ if (!isJtdsDriver() && !setFetchSizeOnCallableStatements() && statement instanceof CallableStatement) {
+ return;
+ }
+ super.setFetchSize(command, context, statement, fetchSize);
+ }
}
Modified: branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -64,7 +64,7 @@
private AtomicRequestID id;
private ConnectorManager manager;
private AtomicRequestMessage requestMsg;
- private ExecutionFactory connector;
+ private ExecutionFactory<Object, Object> connector;
private QueryMetadataInterface queryMetadata;
/* Created on new request */
@@ -212,6 +212,9 @@
// Translate the command
Command command = this.requestMsg.getCommand();
this.expectedColumns = command.getProjectedSymbols().size();
+ if (command instanceof StoredProcedure) {
+ this.expectedColumns = ((StoredProcedure)command).getResultSetColumns().size();
+ }
LanguageBridgeFactory factory = new LanguageBridgeFactory(queryMetadata);
factory.setConvertIn(!this.connector.supportsInCriteria());
org.teiid.language.Command translatedCommand = factory.translate(command);
Modified: branches/8.0.x/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -192,7 +192,7 @@
if(resultSetParameter != null){
List<ElementSymbol> result = new LinkedList<ElementSymbol>();
for (Iterator<ElementSymbol> i = resultSetParameter.getResultSetColumns().iterator(); i.hasNext();) {
- ElementSymbol symbol = (ElementSymbol)i.next().clone();
+ ElementSymbol symbol = i.next().clone();
symbol.setGroupSymbol(getGroup());
result.add(symbol);
}
@@ -250,13 +250,11 @@
* @return Ordered list of SingleElementSymbol
*/
public List getProjectedSymbols(){
- List<ElementSymbol> result = new ArrayList<ElementSymbol>();
- //add result set columns
- List rsColumns = getResultSetColumns();
- result.addAll(rsColumns);
if (!returnParameters()) {
- return result;
+ return getResultSetColumns();
}
+ //add result set columns
+ List<ElementSymbol> result = new ArrayList<ElementSymbol>(getResultSetColumns());
//add out/inout parameter symbols
for (SPParameter parameter : mapOfParameters.values()) {
if(parameter.getParameterType() == ParameterInfo.RETURN_VALUE){
Modified: branches/8.0.x/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- branches/8.0.x/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2012-04-30 18:23:28 UTC (rev 4044)
+++ branches/8.0.x/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2012-04-30 18:58:11 UTC (rev 4045)
@@ -806,6 +806,8 @@
case MetadataConstants.PARAMETER_TYPES.RETURN_VALUE:
type = ProcedureParameter.Type.ReturnValue;
break;
+ default:
+ throw new IllegalArgumentException("Invalid parameter type, please ensure all parameter types are valid in Designer."); //$NON-NLS-1$
}
paramRd.setType(type);
12 years, 7 months
teiid SVN: r4044 - branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-04-30 14:23:28 -0400 (Mon, 30 Apr 2012)
New Revision: 4044
Modified:
branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
Log:
TEIID-2021: Adding a check to validate the translator used in the VDB for its availability.
Modified: branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-04-30 15:04:19 UTC (rev 4043)
+++ branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-04-30 18:23:28 UTC (rev 4044)
@@ -115,6 +115,19 @@
}
}
+ // make sure the translator defined exists in configuration.
+ for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
+ if (model.isSource() && !model.getSourceNames().isEmpty()) {
+ for (String source:model.getSourceNames()) {
+ String translatorName = model.getSourceTranslatorName(source);
+ Translator parent = this.translatorRepository.getTranslatorMetaData(translatorName);
+ if ( parent == null) {
+ throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50077, translatorName, deploymentName));
+ }
+ }
+ }
+ }
+
// check if this is a VDB with index files, if there are then build the TransformationMetadata
UDFMetaData udf = deploymentUnit.removeAttachment(TeiidAttachments.UDF_METADATA);
if (udf != null) {
12 years, 7 months
teiid SVN: r4043 - in branches/8.0.x: common-core/src/main/java/org/teiid/core/types and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-30 11:04:19 -0400 (Mon, 30 Apr 2012)
New Revision: 4043
Modified:
branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java
branches/8.0.x/common-core/src/main/java/org/teiid/core/types/BinaryType.java
branches/8.0.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java
Log:
TEIID-2019 removing jaxb reference
Modified: branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java 2012-04-30 13:56:47 UTC (rev 4042)
+++ branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java 2012-04-30 15:04:19 UTC (rev 4043)
@@ -206,7 +206,7 @@
writer.writeEndElement();
}
- private void writeElement(final XMLStreamWriter writer, String name, String value) throws XMLStreamException {
+ private static void writeElement(final XMLStreamWriter writer, String name, String value) throws XMLStreamException {
writer.writeStartElement(name);
writer.writeCharacters(value);
writer.writeEndElement();
@@ -258,6 +258,7 @@
Properties nodeProps = getAttributes(reader);
PlanNode childNode = new PlanNode(nodeProps.getProperty("name"));//$NON-NLS-1$
node.addProperty(props.getProperty("name"), buildNode(reader, childNode));//$NON-NLS-1$
+ break;
}
else {
throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element", reader.getName(), "value"), reader.getLocation());//$NON-NLS-1$ //$NON-NLS-2$
Modified: branches/8.0.x/common-core/src/main/java/org/teiid/core/types/BinaryType.java
===================================================================
--- branches/8.0.x/common-core/src/main/java/org/teiid/core/types/BinaryType.java 2012-04-30 13:56:47 UTC (rev 4042)
+++ branches/8.0.x/common-core/src/main/java/org/teiid/core/types/BinaryType.java 2012-04-30 15:04:19 UTC (rev 4043)
@@ -24,9 +24,8 @@
import java.util.Arrays;
-import javax.xml.bind.DatatypeConverter;
-
import org.teiid.core.util.Assertion;
+import org.teiid.core.util.PropertiesUtils;
public final class BinaryType implements Comparable<BinaryType> {
@@ -102,7 +101,7 @@
@Override
public String toString() {
- return DatatypeConverter.printHexBinary(bytes);
+ return PropertiesUtils.toHex(bytes);
}
public BlobType toBlob() {
Modified: branches/8.0.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java
===================================================================
--- branches/8.0.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java 2012-04-30 13:56:47 UTC (rev 4042)
+++ branches/8.0.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java 2012-04-30 15:04:19 UTC (rev 4043)
@@ -646,6 +646,14 @@
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
};
+ public static String toHex(byte[] bytes) {
+ StringBuilder sb = new StringBuilder(bytes.length * 2);
+ for (byte b : bytes) {
+ sb.append(toHex(b >>> 4));
+ sb.append(toHex(b));
+ }
+ return sb.toString();
+ }
public static final void copyProperty(Properties srcProperties, String srcPropName, Properties tgtProperties, String tgtPropName) {
if(srcProperties == null || srcPropName == null || tgtProperties == null || tgtPropName == null) {
12 years, 7 months
teiid SVN: r4042 - in branches/8.0.x: admin/src/test/java/org/teiid/adminapi/impl and 6 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-04-30 09:56:47 -0400 (Mon, 30 Apr 2012)
New Revision: 4042
Modified:
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
branches/8.0.x/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java
branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionParameter.java
branches/8.0.x/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java
branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties
branches/8.0.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
branches/8.0.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
Log:
TEIID-2019: removing the references to JAXB in favor of direct stream based parsing.
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -28,12 +28,9 @@
import java.util.Map;
import java.util.Properties;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
import org.teiid.adminapi.AdminObject;
-(a)XmlAccessorType(XmlAccessType.NONE)
public abstract class AdminObjectImpl implements AdminObject, Serializable {
private static final long serialVersionUID = -6381303538713462682L;
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -25,30 +25,18 @@
import java.util.ArrayList;
import java.util.List;
-import javax.xml.bind.annotation.*;
import org.teiid.adminapi.DataPolicy;
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "permissions",
- "mappedRoleNames"
-})
public class DataPolicyMetadata implements DataPolicy, Serializable {
private static final long serialVersionUID = -4119646357275977190L;
- @XmlAttribute(name = "name", required = true)
protected String name;
- @XmlElement(name = "description")
protected String description;
- @XmlAttribute(name = "any-authenticated")
protected boolean anyAuthenticated;
- @XmlAttribute(name = "allow-create-temporary-tables")
protected Boolean allowCreateTemporaryTables;
- @XmlElement(name = "permission")
protected PermissionMap permissions = new PermissionMap(new KeyBuilder<PermissionMetaData>() {
private static final long serialVersionUID = -6992984146431492449L;
@Override
@@ -57,7 +45,6 @@
}
});
- @XmlElement(name = "mapped-role-name")
protected List<String> mappedRoleNames = new ArrayList<String>();
@Override
@@ -129,37 +116,19 @@
return false;
}
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = {
- "resourceName",
- "allowCreate",
- "allowRead",
- "allowUpdate",
- "allowDelete",
- "allowExecute",
- "allowAlter"
- })
public static class PermissionMetaData implements DataPermission, Serializable {
private static final long serialVersionUID = 7034744531663164277L;
// XML based fields
private String resourceName;
- @XmlElement(name = "allow-create")
protected Boolean allowCreate;
- @XmlElement(name = "allow-read")
protected Boolean allowRead;
- @XmlElement(name = "allow-update")
protected Boolean allowUpdate;
- @XmlElement(name = "allow-delete")
protected Boolean allowDelete;
- @XmlElement(name = "allow-execute")
protected Boolean allowExecute;
- @XmlElement(name = "allow-alter")
protected Boolean allowAlter;
@Override
- @XmlElement(name = "resource-name", required = true)
public String getResourceName() {
return resourceName;
}
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -28,31 +28,16 @@
import java.util.LinkedList;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "JAXBProperties",
- "sources",
- "errors"
-})
public class ModelMetaData extends AdminObjectImpl implements Model {
private static final int DEFAULT_ERROR_HISTORY = 10;
private static final String SUPPORTS_MULTI_SOURCE_BINDINGS_KEY = "supports-multi-source-bindings"; //$NON-NLS-1$
private static final long serialVersionUID = 3714234763056162230L;
- @XmlElement(name = "source")
protected ListOverMap<SourceMappingMetadata> sources = new ListOverMap<SourceMappingMetadata>(new KeyBuilder<SourceMappingMetadata>() {
private static final long serialVersionUID = 2273673984691112369L;
@@ -62,26 +47,14 @@
}
});
- @XmlAttribute(name = "type")
protected String modelType = Type.PHYSICAL.name();
-
- @XmlElement(name = "description")
protected String description;
-
- @XmlAttribute(name = "path")
protected String path;
-
- @XmlAttribute(name = "visible")
protected Boolean visible = true;
-
- @XmlElement(name = "validation-error")
protected List<ValidationError> errors;
-
protected String schemaSourceType;
-
protected String schemaText;
-
- @XmlAttribute(name = "name", required = true)
+
public String getName() {
return super.getName();
}
@@ -134,7 +107,6 @@
}
@Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
@@ -264,22 +236,13 @@
this.errors.clear();
}
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = {
- "value"
- })
public static class ValidationError implements Serializable{
private static final long serialVersionUID = 2044197069467559527L;
public enum Severity {ERROR, WARNING};
- @XmlValue
protected String value;
-
- @XmlAttribute(name = "severity", required = true)
protected String severity;
-
- @XmlAttribute(name = "path")
protected String path;
public ValidationError() {};
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -24,11 +24,6 @@
import java.io.Serializable;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
/**
* <pre>
* <complexType name="property">
@@ -43,14 +38,10 @@
*
*
*/
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "property")
public class PropertyMetadata implements Serializable{
private static final long serialVersionUID = -5040224539939758816L;
- @XmlAttribute(name = "name", required = true)
protected String name;
- @XmlAttribute(name = "value", required = true)
protected String value;
public PropertyMetadata() {
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
--- branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -24,23 +24,11 @@
import java.io.Serializable;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "")
public class SourceMappingMetadata implements Serializable {
private static final long serialVersionUID = -4417878417697685794L;
- @XmlAttribute(name = "name", required = true)
private String name;
-
- @XmlAttribute(name = "connection-jndi-name")
private String jndiName;
-
- @XmlAttribute(name = "translator-name",required = true)
private String translatorName;
public SourceMappingMetadata() {}
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -24,8 +24,6 @@
import java.net.URL;
import java.util.*;
-import javax.xml.bind.annotation.*;
-
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
@@ -34,15 +32,6 @@
import org.teiid.core.util.StringUtil;
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "JAXBProperties",
- "models",
- "translators",
- "dataPolicies"
-})
-@XmlRootElement(name = "vdb")
public class VDBMetaData extends AdminObjectImpl implements VDB {
private static final String VERSION_DELIM = "."; //$NON-NLS-1$
@@ -53,7 +42,6 @@
* This simulating a list over a map. JAXB requires a list and performance recommends
* map and we would like to keep one variable to represent both.
*/
- @XmlElement(name = "model", required = true, type = ModelMetaData.class)
protected ListOverMap<ModelMetaData> models = new ListOverMap<ModelMetaData>(new KeyBuilder<ModelMetaData>() {
private static final long serialVersionUID = 846247100420118961L;
@@ -63,7 +51,6 @@
}
});
- @XmlElement(name = "translator", required = true, type = VDBTranslatorMetaData.class)
protected ListOverMap<VDBTranslatorMetaData> translators = new ListOverMap<VDBTranslatorMetaData>(new KeyBuilder<VDBTranslatorMetaData>() {
private static final long serialVersionUID = 3890502172003653563L;
@@ -73,7 +60,6 @@
}
});
- @XmlElement(name = "data-role", required = true, type = DataPolicyMetadata.class)
protected ListOverMap<DataPolicyMetadata> dataPolicies = new ListOverMap<DataPolicyMetadata>(new KeyBuilder<DataPolicyMetadata>() {
private static final long serialVersionUID = 4954591545242715254L;
@@ -83,10 +69,8 @@
}
});
- @XmlAttribute(name = "version", required = true)
private int version = 1;
- @XmlElement(name = "description")
protected String description;
private String fileUrl = null;
@@ -96,7 +80,6 @@
private boolean removed;
private long queryTimeout = Long.MIN_VALUE;
- @XmlAttribute(name = "name", required = true)
public String getName() {
return super.getName();
}
@@ -300,7 +283,6 @@
// This one manages the JAXB binding
@Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
--- branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -23,15 +23,9 @@
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
import org.teiid.adminapi.Translator;
-(a)XmlAccessorType(XmlAccessType.NONE)
public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
private static final long serialVersionUID = -3454161477587996138L;
private String type;
@@ -44,7 +38,6 @@
return super.getName();
}
- @XmlAttribute(name = "name", required = true)
public void setName(String name) {
super.setName(name);
}
@@ -54,13 +47,11 @@
return type;
}
- @XmlAttribute(name = "type",required = true)
public void setType(String type) {
this.type = type;
}
@Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
@@ -82,7 +73,6 @@
return this.description;
}
- @XmlAttribute(name = "description")
public void setDescription(String desc) {
this.description = desc;
}
Modified: branches/8.0.x/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/8.0.x/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -30,13 +30,6 @@
import java.util.Arrays;
import java.util.List;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
import org.jboss.dmr.ModelNode;
import org.junit.Test;
import org.teiid.adminapi.DataPolicy;
@@ -49,33 +42,7 @@
@SuppressWarnings("nls")
public class TestVDBMetaData {
-
- public void testMarshellUnmarshellUsingJaxb() throws Exception {
-
- VDBMetaData vdb = buildVDB();
-
- SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
- Marshaller marshell = jc.createMarshaller();
- marshell.setSchema(schema);
- marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
-
- StringWriter sw = new StringWriter();
- marshell.marshal(vdb, sw);
-
- //System.out.println(sw.toString());
-
- // UnMarshell
- Unmarshaller un = jc.createUnmarshaller();
- un.setSchema(schema);
- vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
-
- validateVDB(vdb);
- }
-
-
@Test
public void testMarshellUnmarshellDirectParsing() throws Exception {
Modified: branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -26,9 +26,6 @@
import java.util.Arrays;
import java.util.List;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
@@ -108,7 +105,6 @@
private Determinism determinism = Determinism.DETERMINISTIC;
- @XmlElement(name="inputParameters")
protected List<FunctionParameter> inParameters = new ArrayList<FunctionParameter>(2);
private FunctionParameter outputParameter;
private Schema parent;
@@ -154,7 +150,6 @@
* Return name of method
* @return Name
*/
- @XmlAttribute
public String getName() {
return super.getName();
}
@@ -180,7 +175,6 @@
* Get description of method
* @return Description
*/
- @XmlAttribute
public String getDescription() {
return this.description;
}
@@ -198,7 +192,6 @@
* @return Category
* @see FunctionCategoryConstants
*/
- @XmlAttribute
public String getCategory() {
return this.category;
}
@@ -228,7 +221,6 @@
this.pushdown = pushdown;
}
- @XmlAttribute
public void setPushDown(String pushdown) {
if (pushdown != null) {
if (pushdown.equals(REQUIRED)) {
@@ -247,7 +239,6 @@
* Get invocation class name
* @return Invocation class name
*/
- @XmlAttribute
public String getInvocationClass() {
return this.invocationClass;
}
@@ -264,7 +255,6 @@
* Get invocation method name
* @return Invocation method name
*/
- @XmlAttribute
public String getInvocationMethod() {
return this.invocationMethod;
}
@@ -312,7 +302,6 @@
* Get ouput parameter.
* @return Output parameter or return argument
*/
- @XmlElement(name="returnParameter")
public FunctionParameter getOutputParameter() {
return this.outputParameter;
}
@@ -448,7 +437,6 @@
return this.determinism;
}
- @XmlAttribute(name="deterministic")
public void setDeterministicBoolean(boolean deterministic) {
this.determinism = deterministic ? Determinism.DETERMINISTIC : Determinism.NONDETERMINISTIC;
}
Modified: branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionParameter.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionParameter.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionParameter.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -24,9 +24,6 @@
import java.io.Serializable;
-import javax.xml.bind.annotation.XmlAttribute;
-
-
/**
* A function parameter defines the name and description of an input or output
* parameter for a function. The name should not be null, but that is not
@@ -81,7 +78,6 @@
* Return name of parameter.
* @return Name
*/
- @XmlAttribute
public String getName() {
return this.name;
}
@@ -98,7 +94,6 @@
* Get description of parameter
* @return Description
*/
- @XmlAttribute
public String getDescription() {
return this.description;
}
@@ -116,7 +111,6 @@
* @return Type name
* @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
*/
- @XmlAttribute
public String getType() {
return this.type;
}
Modified: branches/8.0.x/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
===================================================================
--- branches/8.0.x/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2012-04-30 13:56:47 UTC (rev 4042)
@@ -15,12 +15,13 @@
<dependencies>
+ <module name="javax.api" />
+ <module name="javax.xml.bind.api" />
+ <module name="javax.resource.api"/>
<module name="org.jboss.teiid.common-core" />
<module name="org.jboss.teiid.api" />
<module name="org.jboss.teiid.client" />
<module name="org.jboss.teiid.admin" />
- <module name="javax.api" />
- <module name="javax.resource.api"/>
<module name="org.jboss.logging" />
<module name="org.jboss.as.controller"/>
<module name="org.jboss.modules"/>
Modified: branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -28,24 +28,23 @@
import java.io.ObjectOutput;
import java.io.StringReader;
import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.Properties;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.XMLType;
import org.teiid.core.util.ExternalizeUtil;
import org.teiid.jdbc.JDBCPlugin;
@@ -56,17 +55,13 @@
* parent. For procedure plans child PlanNodes will be processing instructions,
* which can in turn contain other relational or procedure plans.
*/
-@XmlType
-@XmlRootElement(name="node")
public class PlanNode implements Externalizable {
/**
* A Property is a named value of a {@link PlanNode} that may be
* another {@link PlanNode} or a non-null list of values.
*/
- @XmlType(name = "property")
public static class Property implements Externalizable {
- @XmlAttribute
private String name;
private List<String> values;
private PlanNode planNode;
@@ -83,7 +78,6 @@
return name;
}
- @XmlElement(name="value")
public List<String> getValues() {
return values;
}
@@ -92,7 +86,6 @@
this.values = values;
}
- @XmlElement(name="node")
public PlanNode getPlanNode() {
return planNode;
}
@@ -118,10 +111,8 @@
}
- @XmlElement(name="property")
private List<Property> properties = new LinkedList<Property>();
private PlanNode parent;
- @XmlAttribute
private String name;
public PlanNode() {
@@ -221,28 +212,68 @@
writer.writeEndElement();
}
- public static PlanNode fromXml(String planString) {
- try {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
- Unmarshaller marshaller = jc.createUnmarshaller();
- PlanNode planNode = (PlanNode) marshaller.unmarshal(new StringReader(planString));
- setParents(planNode);
- return planNode;
- } catch (JAXBException e) {
- //shouldn't happen
- throw new TeiidRuntimeException(e);
+ private static Properties getAttributes(XMLStreamReader reader) {
+ Properties props = new Properties();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ props.setProperty(attrName, attrValue);
+ }
}
- }
+ return props;
+ }
+
+ public static PlanNode fromXml(String planString) throws XMLStreamException {
+ XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(planString));
- private static void setParents(PlanNode planNode) {
- for (Property property : planNode.properties) {
- if (property.planNode != null) {
- property.planNode.parent = planNode;
- setParents(property.planNode);
+ while (reader.hasNext()&& (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ String element = reader.getLocalName();
+ if (element.equals("node")) { //$NON-NLS-1$
+ Properties props = getAttributes(reader);
+ PlanNode planNode = new PlanNode(props.getProperty("name"));//$NON-NLS-1$
+ planNode.setParent(null);
+ buildNode(reader, planNode);
+ return planNode;
}
+ throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element", reader.getName(), "node"),reader.getLocation());//$NON-NLS-1$ //$NON-NLS-2$
}
+ return null;
}
-
+
+ private static PlanNode buildNode(XMLStreamReader reader, PlanNode node) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ String property = reader.getLocalName();
+ if (property.equals("property")) {//$NON-NLS-1$
+ Properties props = getAttributes(reader);
+ ArrayList<String> values = new ArrayList<String>();
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ String valueNode = reader.getLocalName();
+ if (valueNode.equals("value")) {//$NON-NLS-1$
+ values.add(reader.getElementText());
+ }
+ else if (valueNode.equals("node")) {//$NON-NLS-1$
+ values = null;
+ Properties nodeProps = getAttributes(reader);
+ PlanNode childNode = new PlanNode(nodeProps.getProperty("name"));//$NON-NLS-1$
+ node.addProperty(props.getProperty("name"), buildNode(reader, childNode));//$NON-NLS-1$
+ }
+ else {
+ throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element", reader.getName(), "value"), reader.getLocation());//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ if (values != null) {
+ node.addProperty(props.getProperty("name"), values);//$NON-NLS-1$
+ }
+ }
+ else {
+ throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element", reader.getName(), "property"), reader.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ return node;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
Modified: branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties
===================================================================
--- branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties 2012-04-30 13:56:47 UTC (rev 4042)
@@ -172,4 +172,5 @@
TEIID20008=Failed to load "org.jboss.teiid" module.
TEIID20023=connection closed
TEIID20007=Duplicate Class
-TEIID20028=data length too big: {0} > max of {1}. You may need to adjust the maxObjectSize client setting.
\ No newline at end of file
+TEIID20028=data length too big: {0} > max of {1}. You may need to adjust the maxObjectSize client setting.
+unexpected_element=Unexpected Element {0} encountered, expecting one of {1}
\ No newline at end of file
Modified: branches/8.0.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -7,9 +7,6 @@
import java.util.List;
import java.util.Map;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
@@ -19,11 +16,8 @@
import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.FunctionParameter;
-@XmlType
-@XmlRootElement(namespace="http://www.omg.org/XMI", name="XMI")
public class FunctionMetadataReader {
- @XmlElement(namespace="http://www.metamatrix.com/metamodels/MetaMatrixFunction", name="ScalarFunction")
List<FunctionMethod> functionMethods = new ArrayList<FunctionMethod>();
public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws XMLStreamException {
Modified: branches/8.0.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
===================================================================
--- branches/8.0.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2012-04-27 15:38:44 UTC (rev 4041)
+++ branches/8.0.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2012-04-30 13:56:47 UTC (rev 4042)
@@ -29,8 +29,6 @@
import java.io.StringWriter;
import java.util.ArrayList;
-import javax.xml.bind.JAXBException;
-
import org.teiid.query.mapping.xml.MappingAttribute;
import org.teiid.query.mapping.xml.MappingChoiceNode;
import org.teiid.query.mapping.xml.MappingCriteriaNode;
12 years, 7 months
teiid SVN: r4041 - in branches/8.0.x: runtime/src/main/java/org/teiid/deployers and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-27 11:38:44 -0400 (Fri, 27 Apr 2012)
New Revision: 4041
Modified:
branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
branches/8.0.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
branches/8.0.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
branches/8.0.x/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
branches/8.0.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-2018 ensuring that the resource map is passed to the metadata
Modified: branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-04-27 12:02:10 UTC (rev 4040)
+++ branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-04-27 15:38:44 UTC (rev 4041)
@@ -21,6 +21,7 @@
*/
package org.teiid.jboss;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.ServiceLoader;
import java.util.StringTokenizer;
@@ -39,14 +40,14 @@
import org.jboss.msc.service.AbstractServiceListener;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
-import org.jboss.msc.service.ServiceBuilder.DependencyType;
import org.jboss.msc.service.ServiceController;
-import org.jboss.msc.service.ServiceController.Mode;
-import org.jboss.msc.service.ServiceController.State;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
+import org.jboss.msc.service.ServiceBuilder.DependencyType;
+import org.jboss.msc.service.ServiceController.Mode;
+import org.jboss.msc.service.ServiceController.State;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.impl.ModelMetaData;
@@ -65,6 +66,7 @@
import org.teiid.query.ObjectReplicator;
import org.teiid.query.metadata.DDLMetadataRepository;
import org.teiid.query.metadata.NativeMetadataRepository;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
class VDBDeployer implements DeploymentUnitProcessor {
@@ -126,8 +128,10 @@
// set up the metadata repositories for each models
IndexMetadataRepository indexRepo = null;
IndexMetadataStore indexFactory = deploymentUnit.removeAttachment(TeiidAttachments.INDEX_METADATA);
+ LinkedHashMap<String, Resource> visibilityMap = null;
if (indexFactory != null) {
indexRepo = new IndexMetadataRepository(indexFactory);
+ visibilityMap = indexFactory.getEntriesPlusVisibilities();
}
for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
@@ -139,7 +143,7 @@
}
// build a VDB service
- VDBService vdb = new VDBService(deployment);
+ VDBService vdb = new VDBService(deployment, visibilityMap);
final ServiceBuilder<VDBMetaData> vdbService = context.getServiceTarget().addService(TeiidServiceNames.vdbServiceName(deployment.getName(), deployment.getVersion()), vdb);
// add dependencies to data-sources
Modified: branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
===================================================================
--- branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2012-04-27 12:02:10 UTC (rev 4040)
+++ branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2012-04-27 15:38:44 UTC (rev 4041)
@@ -27,7 +27,11 @@
import javax.xml.stream.XMLStreamException;
-import org.jboss.as.server.deployment.*;
+import org.jboss.as.server.deployment.Attachments;
+import org.jboss.as.server.deployment.DeploymentPhaseContext;
+import org.jboss.as.server.deployment.DeploymentUnit;
+import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
+import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.msc.service.ServiceController;
import org.jboss.vfs.VirtualFile;
import org.teiid.adminapi.Model;
@@ -39,7 +43,6 @@
import org.teiid.logging.LogManager;
import org.teiid.metadata.VdbConstants;
import org.teiid.metadata.index.IndexMetadataStore;
-import org.teiid.runtime.RuntimePlugin;
/**
Modified: branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-04-27 12:02:10 UTC (rev 4040)
+++ branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-04-27 15:38:44 UTC (rev 4041)
@@ -28,6 +28,7 @@
import java.util.Date;
import java.util.HashSet;
import java.util.IdentityHashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -71,6 +72,7 @@
import org.teiid.metadata.index.IndexMetadataRepository;
import org.teiid.query.ObjectReplicator;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.translator.DelegatingExecutionFactory;
@@ -86,9 +88,11 @@
protected final InjectedValue<BufferManager> bufferManagerInjector = new InjectedValue<BufferManager>();
protected final InjectedValue<ObjectReplicator> objectReplicatorInjector = new InjectedValue<ObjectReplicator>();
private VDBLifeCycleListener vdbListener;
+ private LinkedHashMap<String, Resource> visibilityMap;
- public VDBService(VDBMetaData metadata) {
+ public VDBService(VDBMetaData metadata, LinkedHashMap<String, Resource> visibilityMap) {
this.vdb = metadata;
+ this.visibilityMap = visibilityMap;
}
@Override
@@ -158,7 +162,7 @@
try {
// add transformation metadata to the repository.
- getVDBRepository().addVDB(this.vdb, store, udf, cmr);
+ getVDBRepository().addVDB(this.vdb, store, visibilityMap, udf, cmr);
} catch (VirtualDatabaseException e) {
throw new StartException(IntegrationPlugin.Event.TEIID50032.name(), e);
}
Modified: branches/8.0.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- branches/8.0.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-04-27 12:02:10 UTC (rev 4040)
+++ branches/8.0.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-04-27 15:38:44 UTC (rev 4041)
@@ -37,7 +37,6 @@
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.metadata.*;
-import org.teiid.metadata.index.IndexMetadataStore;
import org.teiid.query.function.FunctionTree;
import org.teiid.query.function.UDFSource;
import org.teiid.query.metadata.CompositeMetadataStore;
@@ -63,12 +62,10 @@
// used as cached item to avoid rebuilding
private volatile VDBMetaData mergedVDB;
- public CompositeVDB(VDBMetaData vdb, MetadataStore metadataStore, UDFMetaData udf, FunctionTree systemFunctions, ConnectorManagerRepository cmr, MetadataStore... additionalStores) {
+ public CompositeVDB(VDBMetaData vdb, MetadataStore metadataStore, LinkedHashMap<String, Resource> visibilityMap, UDFMetaData udf, FunctionTree systemFunctions, ConnectorManagerRepository cmr, MetadataStore... additionalStores) {
this.vdb = vdb;
this.store = metadataStore;
- if (metadataStore instanceof IndexMetadataStore) {
- this.visibilityMap = ((IndexMetadataStore)metadataStore).getEntriesPlusVisibilities();
- }
+ this.visibilityMap = visibilityMap;
this.udf = udf;
this.systemFunctions = systemFunctions;
this.cmr = cmr;
Modified: branches/8.0.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- branches/8.0.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-04-27 12:02:10 UTC (rev 4040)
+++ branches/8.0.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-04-27 15:38:44 UTC (rev 4041)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
@@ -47,6 +48,7 @@
import org.teiid.metadata.MetadataStore;
import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.metadata.MetadataValidator;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
import org.teiid.query.validator.ValidatorReport;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.translator.TranslatorException;
@@ -68,7 +70,7 @@
private Map<String, Datatype> datatypeMap = new HashMap<String, Datatype>();
- public void addVDB(VDBMetaData vdb, MetadataStore metadataStore, UDFMetaData udf, ConnectorManagerRepository cmr) throws VirtualDatabaseException {
+ public void addVDB(VDBMetaData vdb, MetadataStore metadataStore, LinkedHashMap<String, Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr) throws VirtualDatabaseException {
if (getVDB(vdb.getName(), vdb.getVersion()) != null) {
throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40035, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40035, vdb.getName(), vdb.getVersion()));
}
@@ -81,14 +83,14 @@
if (this.odbcEnabled && odbcStore == null) {
this.odbcStore = getODBCMetadataStore();
}
-
- CompositeVDB cvdb = null;
+
+ MetadataStore[] stores = null;
if (this.odbcStore == null) {
- cvdb = new CompositeVDB(vdb, metadataStore, udf, this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore);
+ stores = new MetadataStore[] {this.systemStore};
+ } else {
+ stores = new MetadataStore[] {this.systemStore, odbcStore};
}
- else {
- cvdb = new CompositeVDB(vdb, metadataStore, udf, this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore, odbcStore);
- }
+ CompositeVDB cvdb = new CompositeVDB(vdb, metadataStore, visibilityMap, udf, this.systemFunctionManager.getSystemFunctions(), cmr, stores);
this.vdbRepo.put(vdbId(vdb), cvdb);
notifyAdd(vdb.getName(), vdb.getVersion(), cvdb);
}
Modified: branches/8.0.x/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
===================================================================
--- branches/8.0.x/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java 2012-04-27 12:02:10 UTC (rev 4040)
+++ branches/8.0.x/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java 2012-04-27 15:38:44 UTC (rev 4041)
@@ -65,7 +65,7 @@
cmr.addConnectorManager("source", getConnectorManager("FakeTranslator", "FakeConnection", getFuncsOne()));
cmr.addConnectorManager("source2", getConnectorManager("FakeTranslator2", "FakeConnection2", getFuncsTwo()));
- CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metadataStore, null, RealMetadataFactory.SFM.getSystemFunctions(),cmr);
+ CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metadataStore, null, null, RealMetadataFactory.SFM.getSystemFunctions(),cmr);
cvdb.metadataLoadFinished();
return cvdb;
}
Modified: branches/8.0.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- branches/8.0.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-04-27 12:02:10 UTC (rev 4040)
+++ branches/8.0.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-04-27 15:38:44 UTC (rev 4041)
@@ -47,8 +47,8 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.cache.Cache;
import org.teiid.cache.CacheConfiguration;
+import org.teiid.cache.DefaultCacheFactory;
import org.teiid.cache.CacheConfiguration.Policy;
-import org.teiid.cache.DefaultCacheFactory;
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
import org.teiid.common.buffer.TupleBufferCache;
@@ -412,7 +412,7 @@
udfMetaData.addFunctions(entry.getKey(), entry.getValue());
}
}
- this.repo.addVDB(vdbMetaData, metadata, udfMetaData, cmr);
+ this.repo.addVDB(vdbMetaData, metadata, (metadata instanceof IndexMetadataStore)?((IndexMetadataStore)metadata).getEntriesPlusVisibilities():null, udfMetaData, cmr);
this.repo.finishDeployment(vdbMetaData.getName(), vdbMetaData.getVersion());
this.repo.getVDB(vdbMetaData.getName(), vdbMetaData.getVersion()).setStatus(VDB.Status.ACTIVE);
} catch (VirtualDatabaseException e) {
12 years, 8 months
teiid SVN: r4040 - branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-04-27 08:02:10 -0400 (Fri, 27 Apr 2012)
New Revision: 4040
Modified:
branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
Log:
TEIID-1998: missed commit
Modified: branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-04-27 01:59:29 UTC (rev 4039)
+++ branches/8.0.x/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-04-27 12:02:10 UTC (rev 4040)
@@ -109,6 +109,7 @@
String type = data.getType();
VDBTranslatorMetaData parent = getTranslatorRepository().getTranslatorMetaData(type);
data.setModuleName(parent.getModuleName());
+ data.addAttchment(ClassLoader.class, parent.getAttachment(ClassLoader.class));
Set<String> keys = parent.getProperties().stringPropertyNames();
for (String key:keys) {
12 years, 8 months
teiid SVN: r4039 - in branches/8.0.x/engine/src: main/java/org/teiid/query/optimizer/relational and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-26 21:59:29 -0400 (Thu, 26 Apr 2012)
New Revision: 4039
Modified:
branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
branches/8.0.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
branches/8.0.x/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
Log:
TEIID-1960 fix for incorrect projection in multi-source
Modified: branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2012-04-26 19:58:31 UTC (rev 4038)
+++ branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2012-04-27 01:59:29 UTC (rev 4039)
@@ -281,5 +281,11 @@
return command;
}
+
+ @Override
+ protected boolean minimizeProject() {
+ //running minimize twice is not allowed as the original command is modified
+ return false;
+ }
}
Modified: branches/8.0.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2012-04-26 19:58:31 UTC (rev 4038)
+++ branches/8.0.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2012-04-27 01:59:29 UTC (rev 4039)
@@ -326,7 +326,7 @@
}
}
aNode.setCommand(command);
- if (!aNode.isShouldEvaluate()) {
+ if (minimizeProject() && !aNode.isShouldEvaluate()) {
aNode.minimizeProject(command);
}
setRoutingName(aNode, node);
@@ -576,5 +576,9 @@
throw new QueryPlannerException(QueryPlugin.Event.TEIID30251, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30251));
}
}
+
+ protected boolean minimizeProject() {
+ return true;
+ }
}
Modified: branches/8.0.x/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- branches/8.0.x/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2012-04-26 19:58:31 UTC (rev 4038)
+++ branches/8.0.x/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2012-04-27 01:59:29 UTC (rev 4039)
@@ -232,6 +232,23 @@
helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
+ @Test public void testMultiReplacementWithProjectConstantLimit() throws Exception {
+ final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
+ final String userSql = "SELECT a, b, source_name || a, '1' FROM MultiModel.Phys"; //$NON-NLS-1$
+ final String multiModel = "MultiModel"; //$NON-NLS-1$
+ final int sources = 2;
+ final List<?>[] expected = new List<?>[] {
+ Arrays.asList("x", "z", "ax", "1"),
+ };
+ final HardcodedDataManager dataMgr = new HardcodedDataManager();
+ dataMgr.addData("SELECT g_0.a, g_0.b, concat('a', g_0.a) FROM MultiModel.Phys AS g_0", //$NON-NLS-1$
+ new List<?>[] {
+ Arrays.asList("x", "z", "ax")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ dataMgr.addData("SELECT g_0.a, g_0.b, concat('b', g_0.a) FROM MultiModel.Phys AS g_0", //$NON-NLS-1$
+ new List<?>[] {});
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
+ }
+
@Test public void testMultiDependentJoin() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
12 years, 8 months
teiid SVN: r4038 - in trunk/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-26 15:58:31 -0400 (Thu, 26 Apr 2012)
New Revision: 4038
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseNull.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
Log:
TEIID-1993 optimizing dup remove in more situations
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2012-04-26 19:09:46 UTC (rev 4037)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2012-04-26 19:58:31 UTC (rev 4038)
@@ -161,8 +161,27 @@
}
}
}
+ case NodeConstants.Types.DUP_REMOVE:
+ if (root.getType() == NodeConstants.Types.DUP_REMOVE) {
+ //TODO there's an analog here for a non-partitioned union, but it would mean checking projections from each branch
+ boolean allConstants = true;
+ for (Expression ex : outputElements) {
+ if (!(SymbolMap.getExpression(ex) instanceof Constant)) {
+ allConstants = false;
+ break;
+ }
+ }
+ if (allConstants && addLimit(rules, root, metadata, capFinder)) {
+ //TODO we could more gracefully handle the !addLimit case
+ PlanNode parent = root.getParent();
+ if (parent != null) {
+ NodeEditor.removeChildNode(root.getParent(), root);
+ execute(parent, metadata, capFinder, rules, analysisRecord, context);
+ return;
+ }
+ }
+ }
case NodeConstants.Types.TUPLE_LIMIT:
- case NodeConstants.Types.DUP_REMOVE:
case NodeConstants.Types.SORT:
if (root.hasBooleanProperty(NodeConstants.Info.UNRELATED_SORT)) {
//add missing sort columns
@@ -248,13 +267,8 @@
//just lob off everything under the projection
PlanNode project = NodeEditor.findNodePreOrder(parent, NodeConstants.Types.PROJECT);
project.removeAllChildren();
- } else {
- PlanNode limit = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
- limit.setProperty(Info.MAX_TUPLE_LIMIT, new Constant(1));
- if (!rules.contains(RuleConstants.PUSH_LIMIT)) {
- rules.push(RuleConstants.PUSH_LIMIT);
- }
- parent.getFirstChild().addAsParent(limit);
+ } else if (!addLimit(rules, parent, metadata, capFinder)) {
+ throw new AssertionError("expected limit node to be added"); //$NON-NLS-1$
}
execute(parent, metadata, capFinder, rules, analysisRecord, context);
return;
@@ -277,6 +291,33 @@
}
}
+ private boolean addLimit(RuleStack rules, PlanNode parent, QueryMetadataInterface metadata, CapabilitiesFinder capabilitiesFinder) throws QueryMetadataException, TeiidComponentException {
+ PlanNode accessNode = NodeEditor.findParent(parent.getFirstChild(), NodeConstants.Types.ACCESS);
+
+ if (accessNode != null) {
+ Object mid = RuleRaiseAccess.getModelIDFromAccess(accessNode, metadata);
+ if (!CapabilitiesUtil.supports(Capability.ROW_LIMIT, mid, metadata, capabilitiesFinder)) {
+ if (NodeEditor.findParent(parent, NodeConstants.Types.SET_OP | NodeConstants.Types.JOIN, NodeConstants.Types.ACCESS) != null) {
+ return false; //access node is too high
+ }
+ parent = accessNode.getParent();
+ if (parent == null) {
+ return false; //cannot modify the root - TODO could move this logic to another rule
+ }
+ }
+ }
+
+ PlanNode limit = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
+ limit.setProperty(Info.MAX_TUPLE_LIMIT, new Constant(1));
+
+ if (!rules.contains(RuleConstants.PUSH_LIMIT)) {
+ rules.push(RuleConstants.PUSH_LIMIT);
+ }
+
+ parent.getFirstChild().addAsParent(limit);
+ return true;
+ }
+
static PlanNode removeGroupBy(PlanNode root,
QueryMetadataInterface metadata)
throws QueryPlannerException {
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-04-26 19:09:46 UTC (rev 4037)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2012-04-26 19:58:31 UTC (rev 4038)
@@ -26,6 +26,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -35,10 +36,12 @@
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.optimizer.relational.OptimizerRule;
import org.teiid.query.optimizer.relational.RuleStack;
import org.teiid.query.optimizer.relational.plantree.NodeConstants;
import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.resolver.util.AccessPattern;
@@ -70,7 +73,7 @@
boolean beforeDecomposeJoin = rules.contains(RuleConstants.DECOMPOSE_JOIN);
for (PlanNode sourceNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) {
if (sourceNode.getChildCount() > 0) {
- plan = doMerge(sourceNode, plan, beforeDecomposeJoin, metadata);
+ plan = doMerge(sourceNode, plan, beforeDecomposeJoin, metadata, capFinder);
}
}
@@ -79,7 +82,7 @@
static PlanNode doMerge(PlanNode frame,
PlanNode root, boolean beforeDecomposeJoin,
- QueryMetadataInterface metadata) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
+ QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
if (frame.hasBooleanProperty(Info.NO_UNNEST)) {
return root;
}
@@ -154,7 +157,7 @@
return root; //don't bother to merge until after
}
- return checkForSimpleProjection(frame, root, parentProject, metadata);
+ return checkForSimpleProjection(frame, root, parentProject, metadata, capFinder);
}
PlanNode parentJoin = NodeEditor.findParent(frame, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE);
@@ -201,6 +204,7 @@
/**
* Removes source layers that only do a simple projection of the elements below.
+ * @param capFinder
* @throws TeiidComponentException
* @throws QueryMetadataException
* @throws QueryPlannerException
@@ -208,7 +212,7 @@
private static PlanNode checkForSimpleProjection(PlanNode frame,
PlanNode root,
PlanNode parentProject,
- QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
+ QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
// check that the parent only performs projection
PlanNode nodeToCheck = parentProject.getFirstChild();
while (nodeToCheck != frame) {
@@ -265,6 +269,7 @@
PlanNode setOp = NodeEditor.findNodePreOrder(frame.getFirstChild(), NodeConstants.Types.SET_OP, NodeConstants.Types.SOURCE);
if (setOp != null) {
setOp.setProperty(NodeConstants.Info.USE_ALL, Boolean.FALSE);
+ distributeDupRemove(metadata, capFinder, setOp);
if (parentProject.getParent().getParent() != null) {
NodeEditor.removeChildNode(parentProject.getParent().getParent(), parentProject.getParent());
} else {
@@ -395,6 +400,52 @@
}
return true;
}
+
+ static void distributeDupRemove(QueryMetadataInterface metadata,
+ CapabilitiesFinder capabilitiesFinder, PlanNode unionNode)
+ throws QueryMetadataException, TeiidComponentException {
+ PlanNode unionParentSource = NodeEditor.findParent(unionNode, NodeConstants.Types.SOURCE | NodeConstants.Types.SET_OP);
+ if (unionNode.hasBooleanProperty(Info.USE_ALL)
+ || unionParentSource == null
+ || unionParentSource.getType() != NodeConstants.Types.SOURCE
+ || !unionParentSource.hasProperty(Info.PARTITION_INFO)) {
+ return;
+ }
+
+ PlanNode accessNode = NodeEditor.findParent(unionNode, NodeConstants.Types.ACCESS);
+ if (accessNode != null) {
+ Object mid = RuleRaiseAccess.getModelIDFromAccess(accessNode, metadata);
+ if (!CapabilitiesUtil.supports(Capability.QUERY_SELECT_DISTINCT, mid, metadata, capabilitiesFinder)) {
+ return;
+ }
+ }
+
+ //distribute dup remove
+ LinkedList<PlanNode> unionChildren = new LinkedList<PlanNode>();
+ RulePushAggregates.findUnionChildren(unionChildren, false, unionNode);
+ unionNode.setProperty(Info.USE_ALL, true);
+ for (PlanNode node : unionChildren) {
+ if (node.getType() == NodeConstants.Types.SET_OP) {
+ node.setProperty(Info.USE_ALL, false);
+ } else {
+ PlanNode projectNode = NodeEditor.findNodePreOrder(node, NodeConstants.Types.DUP_REMOVE | NodeConstants.Types.PROJECT, NodeConstants.Types.SOURCE);
+ if (projectNode != null && projectNode.getType() == NodeConstants.Types.PROJECT) {
+ accessNode = NodeEditor.findParent(projectNode, NodeConstants.Types.ACCESS);
+ PlanNode dup = NodeFactory.getNewNode(NodeConstants.Types.DUP_REMOVE);
+ if (accessNode == null) {
+ projectNode.addAsParent(dup);
+ } else {
+ Object mid = RuleRaiseAccess.getModelIDFromAccess(accessNode, metadata);
+ if (CapabilitiesUtil.supports(Capability.QUERY_SELECT_DISTINCT, mid, metadata, capabilitiesFinder)) {
+ projectNode.addAsParent(dup);
+ } else {
+ accessNode.addAsParent(dup);
+ }
+ }
+ }
+ }
+ }
+ }
public String toString() {
return "MergeVirtual"; //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2012-04-26 19:09:46 UTC (rev 4037)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2012-04-26 19:58:31 UTC (rev 4038)
@@ -386,7 +386,7 @@
}
//temporarily remove the access node
NodeEditor.removeChildNode(source, planNode);
- PlanNode parent = RuleMergeVirtual.doMerge(source, source.getParent(), false, metadata);
+ PlanNode parent = RuleMergeVirtual.doMerge(source, source.getParent(), false, metadata, capFinder);
//add it back
if (parent.getFirstChild() == source) {
source.getFirstChild().addAsParent(planNode);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java 2012-04-26 19:09:46 UTC (rev 4037)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java 2012-04-26 19:58:31 UTC (rev 4038)
@@ -43,10 +43,10 @@
import org.teiid.query.optimizer.relational.OptimizerRule;
import org.teiid.query.optimizer.relational.RuleStack;
import org.teiid.query.optimizer.relational.plantree.NodeConstants;
-import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.optimizer.relational.plantree.NodeEditor;
import org.teiid.query.optimizer.relational.plantree.NodeFactory;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.SetQuery;
@@ -108,6 +108,8 @@
while (canPushLimit(plan, limitNode, limitNodes, metadata, capabilitiesFinder, analysisRecord)) {
plan = RuleRaiseAccess.performRaise(plan, limitNode.getFirstChild(), limitNode);
+ //makes this rule safe to run after the final rule assign output elements
+ limitNode.setProperty(Info.OUTPUT_COLS, limitNode.getFirstChild().getProperty(Info.OUTPUT_COLS));
}
limitNodes.remove(limitNode);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseNull.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseNull.java 2012-04-26 19:09:46 UTC (rev 4037)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseNull.java 2012-04-26 19:58:31 UTC (rev 4038)
@@ -204,7 +204,7 @@
PlanNode sourceNode = NodeEditor.findParent(grandParent.getFirstChild(), NodeConstants.Types.SOURCE, NodeConstants.Types.SET_OP);
if (sourceNode != null) {
- return RuleMergeVirtual.doMerge(sourceNode, rootNode, false, metadata);
+ return RuleMergeVirtual.doMerge(sourceNode, rootNode, false, metadata, capFinder);
}
return null;
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2012-04-26 19:09:46 UTC (rev 4037)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2012-04-26 19:58:31 UTC (rev 4038)
@@ -6631,6 +6631,52 @@
});
}
+ @Test public void testDistinctConstant() throws Exception {
+ String sql = "select distinct 1 from pm1.g1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.example1Cached(), null, getGenericFinder(),
+ new String[] {"SELECT DISTINCT 1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ //TODO: there is an unnecessary dup removal here since it is the root and the optimization cannot modify the plan root
+ @Test public void testDistinctConstant1() throws Exception {
+ String sql = "select distinct 1 from pm1.g1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(),
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, TestLimit.NODE_TYPES);
+ }
+
+ @Test public void testDistinctConstant2() throws Exception {
+ String sql = "select distinct 1 from pm1.g1"; //$NON-NLS-1$
+ BasicSourceCapabilities bsc = getTypicalCapabilities();
+ bsc.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ CapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(bsc);
+ ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT 1 AS c_0 FROM pm1.g1 AS g_0 LIMIT 1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
public static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2012-04-26 19:09:46 UTC (rev 4037)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2012-04-26 19:58:31 UTC (rev 4038)
@@ -333,5 +333,27 @@
2 // UnionAll
});
}
+
+ @Test public void testUnionPartitionedDistinct() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select distinct * from (SELECT 1 as IntKey, intnum FROM BQT1.SmallA UNION ALL SELECT 2 as intkey, intnum FROM BQT2.SmallA) A", RealMetadataFactory.exampleBQTCached(), null, TestInlineView.getInliveViewCapabilitiesFinder(),//$NON-NLS-1$
+ new String[] { "SELECT DISTINCT g_0.intnum FROM BQT2.SmallA AS g_0", "SELECT DISTINCT g_0.intnum FROM BQT1.SmallA AS g_0" }, ComparisonMode.EXACT_COMMAND_STRING);
+ 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
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
}
12 years, 8 months