teiid SVN: r2387 - in trunk: build/kits/jboss-container/deploy/teiid and 11 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-28 14:27:57 -0400 (Wed, 28 Jul 2010)
New Revision: 2387
Added:
trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java
Removed:
trunk/runtime/src/test/java/com/metamatrix/
Modified:
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/client/src/test/java/org/teiid/jdbc/TestResultSet.java
trunk/common-core/src/main/java/org/teiid/core/types/Streamable.java
trunk/common-core/src/test/java/org/teiid/core/types/TestBlobValue.java
trunk/common-core/src/test/java/org/teiid/core/types/TestClobValue.java
trunk/common-core/src/test/java/org/teiid/core/types/TestXMLValue.java
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml
trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java
trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
Log:
TEIID-1167 fixed lob handling in temp tables, added primary key info to the docs, updated the release notes, and made minor edits to the odbc info.
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-07-28 18:27:57 UTC (rev 2387)
@@ -164,7 +164,7 @@
<property name="inputBufferSize">0</property>
<!-- SO_SNDBUF size, 0 indicates that system default should be used (default 0) -->
<property name="outputBufferSize">0</property>
- <property name="SSLConfiguration"><inject bean="JdbcSslConfiguration"/></property>
+ <property name="SSLConfiguration"><inject bean="OdbcSslConfiguration"/></property>
</bean>
<bean name="OdbcSslConfiguration" class="org.teiid.transport.SSLConfiguration">
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-28 18:27:57 UTC (rev 2387)
@@ -10,7 +10,7 @@
<P><A HREF="http://www.teiid.org/"><IMG SRC="https://www.jboss.org/dms/teiid/images/teiid_banner.png" NAME="graphics1" ALT="Teiid" ALIGN=BOTTOM WIDTH=800></A>
<H1>Teiid ${project.version} Release Notes</H1>
-<P>Teiid ${project.version} adds ODBC and caching features.
+<P>Teiid ${project.version} adds ODBC, SQL, and caching features.
<H2>Overview</H2>
<UL>
@@ -26,6 +26,8 @@
</UL>
<H2><A NAME="Highlights"></A>Highlights</H2>
<UL>
+ <LI><B>ODBC Support</B> - Support for ODBC access is now available through PostgreSQL ODBC driver clients. See the Client Developer's Guide for more on how
+ to use Teiid's ODBC access.
<LI><B>SQL Support</B>
<ul>
<li>Added NULLS FIST/LAST handling - including pushdown support.
@@ -33,6 +35,7 @@
<li>Added support for the boolean aggregate functions ANY, SOME, EVERY.
<li>Added support for using boolean value expression as both criteria and expressions, e.g. "... where boolean_value" or "select x = 1 as boolean_value ...".
<li>Changed named procedure syntax to accept param=>value, rather than param=value.
+ <li>Added PRIMARY KEY and the associated index support to temp tables.
</ul>
<LI><B>Parallel Source Queries</B> - reestablished parallel execution of source queries within a query plan along with a prioritized work system to help prevent resource contention.
<LI><B>SHOW Statement</B> - added client handling for the SHOW statement to retrieve query plan information and see parameter values.
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestResultSet.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestResultSet.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestResultSet.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -712,9 +712,9 @@
StatementImpl statement = createMockStatement(ResultSet.TYPE_FORWARD_ONLY);
ResultsFuture<LobChunk> future = new ResultsFuture<LobChunk>();
future.getResultsReceiver().receiveResults(new LobChunk("<a/>".getBytes(Charset.forName("UTF-8")), true));
- Mockito.stub(statement.getDQP().requestNextLobChunk(0, 0, null)).toReturn(future);
+ XMLType result = new XMLType();
+ Mockito.stub(statement.getDQP().requestNextLobChunk(0, 0, result.getReferenceStreamId())).toReturn(future);
ResultsMessage resultsMsg = new ResultsMessage();
- XMLType result = new XMLType();
result.setEncoding("UTF-8");
resultsMsg.setResults(new List<?>[] {Arrays.asList(result)});
resultsMsg.setLastRow(1);
Modified: trunk/common-core/src/main/java/org/teiid/core/types/Streamable.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/Streamable.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/common-core/src/main/java/org/teiid/core/types/Streamable.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -27,6 +27,7 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.charset.Charset;
+import java.util.concurrent.atomic.AtomicInteger;
import org.teiid.core.CorePlugin;
@@ -43,12 +44,14 @@
private static final long serialVersionUID = -8252488562134729374L;
+ private static AtomicInteger counter = new AtomicInteger();
+
public static final String ENCODING = "UTF-8"; //$NON-NLS-1$
public static final Charset CHARSET = Charset.forName(ENCODING);
public static final String FORCE_STREAMING = "FORCE_STREAMING"; //$NON-NLS-1$
public static final int STREAMING_BATCH_SIZE_IN_BYTES = 102400; // 100K
- private String referenceStreamId;
+ private String referenceStreamId = String.valueOf(counter.getAndIncrement());
protected transient T reference;
protected long length = -1;
@@ -80,9 +83,9 @@
return this.referenceStreamId;
}
- public void setReferenceStreamId(String id) {
+ /*public void setReferenceStreamId(String id) {
this.referenceStreamId = id;
- }
+ }*/
@Override
public String toString() {
Modified: trunk/common-core/src/test/java/org/teiid/core/types/TestBlobValue.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/types/TestBlobValue.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/common-core/src/test/java/org/teiid/core/types/TestBlobValue.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -51,9 +51,8 @@
String testString = "this is test clob"; //$NON-NLS-1$
SerialBlob blob = new SerialBlob(testString.getBytes());
- String key = "keytodata"; //$NON-NLS-1$
BlobType bv = new BlobType(blob);
- bv.setReferenceStreamId(key);
+ String key = bv.getReferenceStreamId();
// now force to serialize
File saved = new File(UnitTestUtil.getTestScratchPath()+"/blobassaved.bin"); //$NON-NLS-1$
Modified: trunk/common-core/src/test/java/org/teiid/core/types/TestClobValue.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/types/TestClobValue.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/common-core/src/test/java/org/teiid/core/types/TestClobValue.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -52,9 +52,8 @@
String testString = "this is test clob"; //$NON-NLS-1$
SerialClob clob = new SerialClob(testString.toCharArray());
- String key = "keytodata"; //$NON-NLS-1$
ClobType cv = new ClobType(clob);
- cv.setReferenceStreamId(key);
+ String key = cv.getReferenceStreamId();
// now force to serialize
File saved = new File(UnitTestUtil.getTestScratchPath()+"/clobassaved.bin"); //$NON-NLS-1$
Modified: trunk/common-core/src/test/java/org/teiid/core/types/TestXMLValue.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/types/TestXMLValue.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/common-core/src/test/java/org/teiid/core/types/TestXMLValue.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -51,10 +51,8 @@
String testString = "<foo>this is an xml value test</foo>"; //$NON-NLS-1$
SQLXMLImpl xml = new SQLXMLImpl(testString);
- String key = "keytodata"; //$NON-NLS-1$
- String pkey = "peresistkeytodata"; //$NON-NLS-1$
XMLType xv = new XMLType(xml);
- xv.setReferenceStreamId(key);
+ String key = xv.getReferenceStreamId();
// now force to serialize
File saved = new File(UnitTestUtil.getTestScratchPath()+"/xmlsaved.bin"); //$NON-NLS-1$
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml 2010-07-28 18:27:57 UTC (rev 2387)
@@ -6,37 +6,36 @@
<chapter id="ODBC">
<title>ODBC Support</title>
- <para>Short for Open DataBase Connectivity, a standard database access method developed by the SQL Access group in 1992.
- The goal of ODBC is to make it possible to access any data from any application, regardless of which database management
- system (DBMS) is handling the data. ODBC manages this by inserting a middle layer, called a database driver ,
- between an application and the DBMS. The purpose of this layer is to translate the application's data queries
+ <para>Open DataBase Connectivity (ODBC) is a standard database access method developed by the SQL Access group in 1992.
+ ODBC, just like JDBC in Java, allows consistent client access regardless of which database management
+ system (DBMS) is handling the data. ODBC uses a driver to translate the application's data queries
into commands that the DBMS understands. For this to work, both the application and the DBMS must be ODBC-compliant
-- that is, the application must be capable of issuing ODBC commands and the
- DBMS must be capable of responding to them</para>
+ DBMS must be capable of responding to them.</para>
- <para>Teiid provides the ODBC access to deployed VDBs in the Teiid runtime through
- <ulink url="http://www.postgresql.org/">PostgreSQL</ulink>'s ODBC driver. This is possible by redirecting the ODBC commands
- from a client application to a different port than default PostgreSQL port.</para>
+ <para>Teiid can provide ODBC access to deployed VDBs in the Teiid runtime through
+ <ulink url="http://www.postgresql.org/">PostgreSQL</ulink>'s ODBC driver.
+ This is possible because Teiid has specialized handling that allows it emulate a PostgreSQL server and respond appropriate to expected
+ metadata queries.</para>
<note><para>By default, ODBC on the Teiid is enabled and running on on port <emphasis>35432</emphasis>.</para></note>
- <para>Before your application can use the ODBC, you must first install ODBC driver on same machine that
- your application is running and then create Data Source Name (DSN) for that represents a connection profile for your Teiid VDB.
+ <para>Before an application can use ODBC, you must first install the ODBC driver on same machine that
+ the application is running on and then create Data Source Name (DSN) that represents a connection profile for your Teiid VDB.
</para>
<sect1 id="install">
<title>Installing the ODBC Driver Client</title>
- <para>The PostgreSQL ODBC driver that is needed to make the ODBC connection to Teiid is <emphasis>not</emphasis>
- bundled with Teiid distribution. The driver needs be <ulink url="http://www.postgresql.org/ftp/odbc/versions/">downloaded</ulink>
- directly from PostgreSQL web site. We have tested with <emphasis>8.04.200</emphasis> version of the ODBC driver for
- this release.</para>
+ <para>A PostgreSQL ODBC driver needed to make the ODBC connection to Teiid is <emphasis>not</emphasis>
+ bundled with the Teiid distribution. The appropriate driver needs be <ulink url="http://www.postgresql.org/ftp/odbc/versions/">downloaded</ulink>
+ directly from the PostgreSQL web site. We have tested with <emphasis>8.04.200</emphasis> version of the ODBC driver.</para>
<sect2>
<title>Microsoft Windows</title>
<orderedlist>
<listitem><para>Download the ODBC driver from <ulink url="http://wwwmaster.postgresql.org/download/mirrors-ftp/odbc/versions/msi/ps...">
PostgreSQL download site</ulink>. If you are looking for 64-bit Windows driver download the driver from <ulink url="http://code.google.com/p/visionmap/wiki/psqlODBC">here</ulink>. </para></listitem>
- <listitem><para>Extract the contents of the ZIP file into a temporary location on you system. For example: "c:\temp\pgodbc"</para></listitem>
+ <listitem><para>Extract the contents of the ZIP file into a temporary location on your system. For example: "c:\temp\pgodbc"</para></listitem>
<listitem><para>Double click on "psqlodbc.msi" file or (.exe file in the case of 64 bit) to start installation of the driver.</para></listitem>
<listitem>
<para>The Wizard appears as</para>
@@ -62,7 +61,7 @@
<graphic align="center" scale="100" fileref="../images/winsetup3.png" />
</figure>
<para>If you want to install in a different directory than the default that is already selected,
- click the "Browse" button and select a directory if you want install.
+ click the "Browse" button and select a directory.
Click "Next" to start installing in the selected directory.</para>
</listitem>
<listitem>
@@ -88,10 +87,10 @@
</sect2>
<sect2>
<title>Other *nix Platform Installations</title>
- <para>For all other platforms other than Microsoft Windows, the ODBC driver needs compiled and built from the
+ <para>For all other platforms other than Microsoft Windows, the ODBC driver needs built from the
source files provided. Download the ODBC driver source files from
<ulink url="http://wwwmaster.postgresql.org/download/mirrors-ftp/odbc/versions/src/ps...">
- PostgreSQL download site</ulink>. Untar the files to a temporary location. For example: "~/tmp/pgodbc".
+ the PostgreSQL download site</ulink>. Untar the files to a temporary location. For example: "~/tmp/pgodbc".
Build and install the driver by running the commands below.</para>
<note><para>You should use super user account or use "sudo" command for running the "make install" command. </para></note>
<programlisting><![CDATA[
@@ -101,8 +100,8 @@
% make
% make install
]]></programlisting>
-
- <para>The the next step in the process is to create a DSN for accessing the Teiid VDB.</para>
+ <para>Some *nix distributions may already provide binary forms of the appropriate driver, which can be used as an alternative to
+ building from source.</para>
</sect2>
</sect1>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml 2010-07-28 18:27:57 UTC (rev 2387)
@@ -415,179 +415,179 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod13" xreflabel="createTempTable"/>createTempTable</para></entry>
<entry align="left" valign="top"><para>::=
-<CREATE> <LOCAL> <TEMPORARY> <TABLE> <link linkend="prod2">id</link> <LPAREN> <link linkend="prod14">createElementsWithTypes</link> <RPAREN></para></entry></row>
+<CREATE> <LOCAL> <TEMPORARY> <TABLE> <link linkend="prod2">id</link> <LPAREN> <link linkend="prod14">createElementsWithTypes</link> ( <COMMA> <PRIMARY> <link linkend="prod15">nonReserved</link> <LPAREN> <link linkend="prod2">id</link> ( <COMMA> <link linkend="prod2">id</link> )* <RPAREN> )? <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod15" xreflabel="errorStatement"/>errorStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod16" xreflabel="errorStatement"/>errorStatement</para></entry>
<entry align="left" valign="top"><para>::=
-<ERROR> <link linkend="prod16">expression</link></para></entry></row>
+<ERROR> <link linkend="prod17">expression</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod17" xreflabel="statement"/>statement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod18" xreflabel="statement"/>statement</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod18">ifStatement</link> | <link linkend="prod19">loopStatement</link> | <link linkend="prod20">whileStatement</link> | <link linkend="prod21">delimitedStatement</link> )</para></entry></row>
+( <link linkend="prod19">ifStatement</link> | <link linkend="prod20">loopStatement</link> | <link linkend="prod21">whileStatement</link> | <link linkend="prod22">delimitedStatement</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod21" xreflabel="delimitedStatement"/>delimitedStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod22" xreflabel="delimitedStatement"/>delimitedStatement</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod22">sqlStatement</link> | <link linkend="prod15">errorStatement</link> | <link linkend="prod23">assignStatement</link> | <link linkend="prod24">declareStatement</link> | <link linkend="prod25">continueStatement</link> | <link linkend="prod26">breakStatement</link> ) <SEMICOLON></para></entry></row>
+( <link linkend="prod23">sqlStatement</link> | <link linkend="prod16">errorStatement</link> | <link linkend="prod24">assignStatement</link> | <link linkend="prod25">declareStatement</link> | <link linkend="prod26">continueStatement</link> | <link linkend="prod27">breakStatement</link> ) <SEMICOLON></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod27" xreflabel="block"/>block</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod28" xreflabel="block"/>block</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod17">statement</link> | ( <BEGIN> ( <link linkend="prod17">statement</link> )* <END> ) )</para></entry></row>
+( <link linkend="prod18">statement</link> | ( <BEGIN> ( <link linkend="prod18">statement</link> )* <END> ) )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod26" xreflabel="breakStatement"/>breakStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod27" xreflabel="breakStatement"/>breakStatement</para></entry>
<entry align="left" valign="top"><para>::=
<BREAK></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod25" xreflabel="continueStatement"/>continueStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod26" xreflabel="continueStatement"/>continueStatement</para></entry>
<entry align="left" valign="top"><para>::=
<CONTINUE></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod20" xreflabel="whileStatement"/>whileStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod21" xreflabel="whileStatement"/>whileStatement</para></entry>
<entry align="left" valign="top"><para>::=
-<WHILE> <LPAREN> <link linkend="prod28">criteria</link> <RPAREN> <link linkend="prod27">block</link></para></entry></row>
+<WHILE> <LPAREN> <link linkend="prod29">criteria</link> <RPAREN> <link linkend="prod28">block</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod19" xreflabel="loopStatement"/>loopStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod20" xreflabel="loopStatement"/>loopStatement</para></entry>
<entry align="left" valign="top"><para>::=
-<LOOP> <ON> <LPAREN> <link linkend="prod7">queryExpression</link> <RPAREN> <AS> <link linkend="prod2">id</link> <link linkend="prod27">block</link></para></entry></row>
+<LOOP> <ON> <LPAREN> <link linkend="prod7">queryExpression</link> <RPAREN> <AS> <link linkend="prod2">id</link> <link linkend="prod28">block</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod18" xreflabel="ifStatement"/>ifStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod19" xreflabel="ifStatement"/>ifStatement</para></entry>
<entry align="left" valign="top"><para>::=
-<IF> <LPAREN> <link linkend="prod28">criteria</link> <RPAREN> <link linkend="prod27">block</link> ( <ELSE> <link linkend="prod27">block</link> )?</para></entry></row>
+<IF> <LPAREN> <link linkend="prod29">criteria</link> <RPAREN> <link linkend="prod28">block</link> ( <ELSE> <link linkend="prod28">block</link> )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod29" xreflabel="criteriaSelector"/>criteriaSelector</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod30" xreflabel="criteriaSelector"/>criteriaSelector</para></entry>
<entry align="left" valign="top"><para>::=
( ( <EQ> | <NE> | <NE2> | <LE> | <GE> | <LT> | <GT> | <IN> | <LIKE> | ( <IS> <NULL> ) | <BETWEEN> ) )? <CRITERIA> ( <ON> <LPAREN> <link linkend="prod2">id</link> ( <COMMA> <link linkend="prod2">id</link> )* <RPAREN> )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod30" xreflabel="hasCriteria"/>hasCriteria</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod31" xreflabel="hasCriteria"/>hasCriteria</para></entry>
<entry align="left" valign="top"><para>::=
-<HAS> <link linkend="prod29">criteriaSelector</link></para></entry></row>
+<HAS> <link linkend="prod30">criteriaSelector</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod24" xreflabel="declareStatement"/>declareStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod25" xreflabel="declareStatement"/>declareStatement</para></entry>
<entry align="left" valign="top"><para>::=
-<DECLARE> <link linkend="prod31">dataType</link> <link linkend="prod2">id</link> ( <EQ> <link linkend="prod32">assignStatementOperand</link> )?</para></entry></row>
+<DECLARE> <link linkend="prod32">dataType</link> <link linkend="prod2">id</link> ( <EQ> <link linkend="prod33">assignStatementOperand</link> )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod23" xreflabel="assignStatement"/>assignStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod24" xreflabel="assignStatement"/>assignStatement</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod2">id</link> <EQ> <link linkend="prod32">assignStatementOperand</link></para></entry></row>
+<link linkend="prod2">id</link> <EQ> <link linkend="prod33">assignStatementOperand</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod32" xreflabel="assignStatementOperand"/>assignStatementOperand</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod33" xreflabel="assignStatementOperand"/>assignStatementOperand</para></entry>
<entry align="left" valign="top"><para>::=
-( ( <link linkend="prod9">insert</link> ) | <link linkend="prod10">update</link> | <link linkend="prod11">delete</link> | <link linkend="prod8">storedProcedure</link> | ( <link linkend="prod16">expression</link> ) | <link linkend="prod7">queryExpression</link> )</para></entry></row>
+( ( <link linkend="prod9">insert</link> ) | <link linkend="prod10">update</link> | <link linkend="prod11">delete</link> | <link linkend="prod8">storedProcedure</link> | ( <link linkend="prod17">expression</link> ) | <link linkend="prod7">queryExpression</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod22" xreflabel="sqlStatement"/>sqlStatement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod23" xreflabel="sqlStatement"/>sqlStatement</para></entry>
<entry align="left" valign="top"><para>::=
-( ( <link linkend="prod33">dynamicCommand</link> ) | <link linkend="prod5">userCommand</link> )</para></entry></row>
+( ( <link linkend="prod34">dynamicCommand</link> ) | <link linkend="prod5">userCommand</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod34" xreflabel="translateCriteria"/>translateCriteria</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod35" xreflabel="translateCriteria"/>translateCriteria</para></entry>
<entry align="left" valign="top"><para>::=
-<TRANSLATE> <link linkend="prod29">criteriaSelector</link> ( <WITH> <LPAREN> <link linkend="prod2">id</link> <EQ> <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod2">id</link> <EQ> <link linkend="prod16">expression</link> )* <RPAREN> )?</para></entry></row>
+<TRANSLATE> <link linkend="prod30">criteriaSelector</link> ( <WITH> <LPAREN> <link linkend="prod2">id</link> <EQ> <link linkend="prod17">expression</link> ( <COMMA> <link linkend="prod2">id</link> <EQ> <link linkend="prod17">expression</link> )* <RPAREN> )?</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod4" xreflabel="createUpdateProcedure"/>createUpdateProcedure</para></entry>
<entry align="left" valign="top"><para>::=
-<CREATE> ( <VIRTUAL> )? ( <UPDATE> )? <PROCEDURE> <link linkend="prod27">block</link></para></entry></row>
+<CREATE> ( <VIRTUAL> )? ( <UPDATE> )? <PROCEDURE> <link linkend="prod28">block</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod33" xreflabel="dynamicCommand"/>dynamicCommand</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod34" xreflabel="dynamicCommand"/>dynamicCommand</para></entry>
<entry align="left" valign="top"><para>::=
-( <EXECUTE> | <EXEC> ) <STRING> <link linkend="prod16">expression</link> ( <AS> <link linkend="prod14">createElementsWithTypes</link> ( <INTO> <link linkend="prod2">id</link> )? )? ( <USING> <link linkend="prod35">setClauseList</link> )? ( <UPDATE> ( ( <INTEGERVAL> ) | ( <STAR> ) ) )?</para></entry></row>
+( <EXECUTE> | <EXEC> ) <STRING> <link linkend="prod17">expression</link> ( <AS> <link linkend="prod14">createElementsWithTypes</link> ( <INTO> <link linkend="prod2">id</link> )? )? ( <USING> <link linkend="prod36">setClauseList</link> )? ( <UPDATE> ( ( <INTEGERVAL> ) | ( <STAR> ) ) )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod35" xreflabel="setClauseList"/>setClauseList</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod36" xreflabel="setClauseList"/>setClauseList</para></entry>
<entry align="left" valign="top"><para>::=
<link linkend="prod2">id</link> <EQ> ( <COMMA> <link linkend="prod2">id</link> <EQ> )*</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod14" xreflabel="createElementsWithTypes"/>createElementsWithTypes</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod2">id</link> <link linkend="prod31">dataType</link> ( <COMMA> <link linkend="prod2">id</link> <link linkend="prod31">dataType</link> )*</para></entry></row>
+<link linkend="prod2">id</link> <link linkend="prod32">dataType</link> ( <COMMA> <link linkend="prod2">id</link> <link linkend="prod32">dataType</link> )*</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod6" xreflabel="callableStatement"/>callableStatement</para></entry>
<entry align="left" valign="top"><para>::=
-<LBRACE> ( <QMARK> <EQ> )? <CALL> <link linkend="prod2">id</link> ( <LPAREN> ( <link linkend="prod36">executeUnnamedParams</link> ) <RPAREN> )? <RBRACE> ( <link linkend="prod37">option</link> )?</para></entry></row>
+<LBRACE> ( <QMARK> <EQ> )? <CALL> <link linkend="prod2">id</link> ( <LPAREN> ( <link linkend="prod37">executeUnnamedParams</link> ) <RPAREN> )? <RBRACE> ( <link linkend="prod38">option</link> )?</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod8" xreflabel="storedProcedure"/>storedProcedure</para></entry>
<entry align="left" valign="top"><para>::=
-( ( ( <EXEC> ) | ( <EXECUTE> ) | ( <CALL> ) ) <link linkend="prod2">id</link> <LPAREN> ( <link linkend="prod38">executeNamedParams</link> | <link linkend="prod36">executeUnnamedParams</link> ) <RPAREN> ) ( <link linkend="prod37">option</link> )?</para></entry></row>
+( ( ( <EXEC> ) | ( <EXECUTE> ) | ( <CALL> ) ) <link linkend="prod2">id</link> <LPAREN> ( <link linkend="prod39">executeNamedParams</link> | <link linkend="prod37">executeUnnamedParams</link> ) <RPAREN> ) ( <link linkend="prod38">option</link> )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod36" xreflabel="executeUnnamedParams"/>executeUnnamedParams</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod37" xreflabel="executeUnnamedParams"/>executeUnnamedParams</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )* )?</para></entry></row>
+( <link linkend="prod17">expression</link> ( <COMMA> <link linkend="prod17">expression</link> )* )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod38" xreflabel="executeNamedParams"/>executeNamedParams</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod39" xreflabel="executeNamedParams"/>executeNamedParams</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod2">id</link> <EQ> ( <GT> )? <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod2">id</link> <EQ> ( <GT> )? <link linkend="prod16">expression</link> )* )</para></entry></row>
+( <link linkend="prod2">id</link> <EQ> ( <GT> )? <link linkend="prod17">expression</link> ( <COMMA> <link linkend="prod2">id</link> <EQ> ( <GT> )? <link linkend="prod17">expression</link> )* )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod9" xreflabel="insert"/>insert</para></entry>
<entry align="left" valign="top"><para>::=
-<INSERT> <INTO> <link linkend="prod2">id</link> ( <LPAREN> <link linkend="prod2">id</link> ( <COMMA> <link linkend="prod2">id</link> )* <RPAREN> )? ( ( <VALUES> <link linkend="prod39">rowValues</link> ) | ( <link linkend="prod7">queryExpression</link> ) ) ( <link linkend="prod37">option</link> )?</para></entry></row>
+<INSERT> <INTO> <link linkend="prod2">id</link> ( <LPAREN> <link linkend="prod2">id</link> ( <COMMA> <link linkend="prod2">id</link> )* <RPAREN> )? ( ( <VALUES> <link linkend="prod40">rowValues</link> ) | ( <link linkend="prod7">queryExpression</link> ) ) ( <link linkend="prod38">option</link> )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod39" xreflabel="rowValues"/>rowValues</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod40" xreflabel="rowValues"/>rowValues</para></entry>
<entry align="left" valign="top"><para>::=
-<LPAREN> <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )* <RPAREN></para></entry></row>
+<LPAREN> <link linkend="prod17">expression</link> ( <COMMA> <link linkend="prod17">expression</link> )* <RPAREN></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod10" xreflabel="update"/>update</para></entry>
<entry align="left" valign="top"><para>::=
-<UPDATE> <link linkend="prod2">id</link> <SET> <link linkend="prod35">setClauseList</link> ( <link linkend="prod40">where</link> )? ( <link linkend="prod37">option</link> )?</para></entry></row>
+<UPDATE> <link linkend="prod2">id</link> <SET> <link linkend="prod36">setClauseList</link> ( <link linkend="prod41">where</link> )? ( <link linkend="prod38">option</link> )?</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod11" xreflabel="delete"/>delete</para></entry>
<entry align="left" valign="top"><para>::=
-<DELETE> <FROM> <link linkend="prod2">id</link> ( <link linkend="prod40">where</link> )? ( <link linkend="prod37">option</link> )?</para></entry></row>
+<DELETE> <FROM> <link linkend="prod2">id</link> ( <link linkend="prod41">where</link> )? ( <link linkend="prod38">option</link> )?</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod7" xreflabel="queryExpression"/>queryExpression</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod41">queryExpressionBody</link></para></entry></row>
+<link linkend="prod42">queryExpressionBody</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod41" xreflabel="queryExpressionBody"/>queryExpressionBody</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod42" xreflabel="queryExpressionBody"/>queryExpressionBody</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod42">queryTerm</link> ( ( <UNION> | <EXCEPT> ) ( <ALL> | <DISTINCT> )? <link linkend="prod42">queryTerm</link> )* ( <link linkend="prod43">orderby</link> )? ( <link linkend="prod44">limit</link> )? ( <link linkend="prod37">option</link> )?</para></entry></row>
+<link linkend="prod43">queryTerm</link> ( ( <UNION> | <EXCEPT> ) ( <ALL> | <DISTINCT> )? <link linkend="prod43">queryTerm</link> )* ( <link linkend="prod44">orderby</link> )? ( <link linkend="prod45">limit</link> )? ( <link linkend="prod38">option</link> )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod42" xreflabel="queryTerm"/>queryTerm</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod43" xreflabel="queryTerm"/>queryTerm</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod45">queryPrimary</link> ( <INTERSECT> ( <ALL> | <DISTINCT> )? <link linkend="prod45">queryPrimary</link> )*</para></entry></row>
+<link linkend="prod46">queryPrimary</link> ( <INTERSECT> ( <ALL> | <DISTINCT> )? <link linkend="prod46">queryPrimary</link> )*</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod45" xreflabel="queryPrimary"/>queryPrimary</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod46" xreflabel="queryPrimary"/>queryPrimary</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod46">query</link> | ( <LPAREN> <link linkend="prod41">queryExpressionBody</link> <RPAREN> ) )</para></entry></row>
+( <link linkend="prod47">query</link> | ( <LPAREN> <link linkend="prod42">queryExpressionBody</link> <RPAREN> ) )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod46" xreflabel="query"/>query</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod47" xreflabel="query"/>query</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod47">select</link> ( <link linkend="prod48">into</link> )? ( <link linkend="prod49">from</link> ( <link linkend="prod40">where</link> )? ( <link linkend="prod50">groupBy</link> )? ( <link linkend="prod51">having</link> )? )?</para></entry></row>
+<link linkend="prod48">select</link> ( <link linkend="prod49">into</link> )? ( <link linkend="prod50">from</link> ( <link linkend="prod41">where</link> )? ( <link linkend="prod51">groupBy</link> )? ( <link linkend="prod52">having</link> )? )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod48" xreflabel="into"/>into</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod49" xreflabel="into"/>into</para></entry>
<entry align="left" valign="top"><para>::=
<INTO> ( <link linkend="prod2">id</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod47" xreflabel="select"/>select</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod48" xreflabel="select"/>select</para></entry>
<entry align="left" valign="top"><para>::=
-<SELECT> ( <ALL> | ( <DISTINCT> ) )? ( <STAR> | ( <link linkend="prod52">selectSymbol</link> ( <COMMA> <link linkend="prod52">selectSymbol</link> )* ) )</para></entry></row>
+<SELECT> ( <ALL> | ( <DISTINCT> ) )? ( <STAR> | ( <link linkend="prod53">selectSymbol</link> ( <COMMA> <link linkend="prod53">selectSymbol</link> )* ) )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod52" xreflabel="selectSymbol"/>selectSymbol</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod53" xreflabel="selectSymbol"/>selectSymbol</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod53">selectExpression</link> | <link linkend="prod54">allInGroupSymbol</link> )</para></entry></row>
+( <link linkend="prod54">selectExpression</link> | <link linkend="prod55">allInGroupSymbol</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod53" xreflabel="selectExpression"/>selectExpression</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod54" xreflabel="selectExpression"/>selectExpression</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod16">expression</link> ( ( <AS> )? <link linkend="prod2">id</link> )? )</para></entry></row>
+( <link linkend="prod17">expression</link> ( ( <AS> )? <link linkend="prod2">id</link> )? )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod55" xreflabel="derivedColumn"/>derivedColumn</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod56" xreflabel="derivedColumn"/>derivedColumn</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod16">expression</link> ( <AS> <link linkend="prod2">id</link> )? )</para></entry></row>
+( <link linkend="prod17">expression</link> ( <AS> <link linkend="prod2">id</link> )? )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod54" xreflabel="allInGroupSymbol"/>allInGroupSymbol</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod55" xreflabel="allInGroupSymbol"/>allInGroupSymbol</para></entry>
<entry align="left" valign="top"><para>::=
<ALL_IN_GROUP></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod56" xreflabel="xmlAgg"/>xmlAgg</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod57" xreflabel="xmlAgg"/>xmlAgg</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLAGG> <LPAREN> <link linkend="prod16">expression</link> ( <link linkend="prod43">orderby</link> )? <RPAREN></para></entry></row>
+<XMLAGG> <LPAREN> <link linkend="prod17">expression</link> ( <link linkend="prod44">orderby</link> )? <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod57" xreflabel="aggregateSymbol"/>aggregateSymbol</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod58" xreflabel="aggregateSymbol"/>aggregateSymbol</para></entry>
<entry align="left" valign="top"><para>::=
-( ( <link linkend="prod58">nonReserved</link> <LPAREN> <STAR> <RPAREN> ) | ( ( <link linkend="prod58">nonReserved</link> | <ANY> | <SOME> ) <LPAREN> ( <DISTINCT> | <ALL> )? <link linkend="prod16">expression</link> <RPAREN> ) )</para></entry></row>
+( ( <link linkend="prod15">nonReserved</link> <LPAREN> <STAR> <RPAREN> ) | ( ( <link linkend="prod15">nonReserved</link> | <ANY> | <SOME> ) <LPAREN> ( <DISTINCT> | <ALL> )? <link linkend="prod17">expression</link> <RPAREN> ) )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod49" xreflabel="from"/>from</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod50" xreflabel="from"/>from</para></entry>
<entry align="left" valign="top"><para>::=
<FROM> ( <link linkend="prod59">tableReference</link> ( <COMMA> <link linkend="prod59">tableReference</link> )* )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod59" xreflabel="tableReference"/>tableReference</para></entry>
<entry align="left" valign="top"><para>::=
-( ( <LBRACE> <link linkend="prod58">nonReserved</link> <link linkend="prod60">joinedTable</link> <RBRACE> ) | <link linkend="prod60">joinedTable</link> )</para></entry></row>
+( ( <LBRACE> <link linkend="prod15">nonReserved</link> <link linkend="prod60">joinedTable</link> <RBRACE> ) | <link linkend="prod60">joinedTable</link> )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod60" xreflabel="joinedTable"/>joinedTable</para></entry>
<entry align="left" valign="top"><para>::=
@@ -599,7 +599,7 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod63" xreflabel="qualifiedJoin"/>qualifiedJoin</para></entry>
<entry align="left" valign="top"><para>::=
-( ( ( <RIGHT> ( <OUTER> )? ) | ( <LEFT> ( <OUTER> )? ) | ( <FULL> ( <OUTER> )? ) | <INNER> )? <JOIN> <link linkend="prod59">tableReference</link> <ON> <link linkend="prod28">criteria</link> )</para></entry></row>
+( ( ( <RIGHT> ( <OUTER> )? ) | ( <LEFT> ( <OUTER> )? ) | ( <FULL> ( <OUTER> )? ) | <INNER> )? <JOIN> <link linkend="prod59">tableReference</link> <ON> <link linkend="prod29">criteria</link> )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod61" xreflabel="tablePrimary"/>tablePrimary</para></entry>
<entry align="left" valign="top"><para>::=
@@ -607,31 +607,31 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod68" xreflabel="xmlSerialize"/>xmlSerialize</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLSERIALIZE> <LPAREN> ( <link linkend="prod58">nonReserved</link> )? <link linkend="prod16">expression</link> ( <AS> ( <STRING> | <VARCHAR> | <CLOB> ) )? <RPAREN></para></entry></row>
+<XMLSERIALIZE> <LPAREN> ( <link linkend="prod15">nonReserved</link> )? <link linkend="prod17">expression</link> ( <AS> ( <STRING> | <VARCHAR> | <CLOB> ) )? <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod58" xreflabel="nonReserved"/>nonReserved</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod15" xreflabel="nonReserved"/>nonReserved</para></entry>
<entry align="left" valign="top"><para>::=
<ID></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod64" xreflabel="textTable"/>textTable</para></entry>
<entry align="left" valign="top"><para>::=
-<ID> <LPAREN> <link linkend="prod16">expression</link> <link linkend="prod58">nonReserved</link> <link linkend="prod69">textColumn</link> ( <COMMA> <link linkend="prod69">textColumn</link> )* ( <ID> <link linkend="prod70">charVal</link> )? ( ( <ESCAPE> <link linkend="prod70">charVal</link> ) | ( <ID> <link linkend="prod70">charVal</link> ) )? ( <ID> ( <link linkend="prod71">intVal</link> )? )? ( <ID> <link linkend="prod71">intVal</link> )? <RPAREN> ( <AS> )? <link linkend="prod2">id</link></para></entry></row>
+<ID> <LPAREN> <link linkend="prod17">expression</link> <link linkend="prod15">nonReserved</link> <link linkend="prod69">textColumn</link> ( <COMMA> <link linkend="prod69">textColumn</link> )* ( <ID> <link linkend="prod70">charVal</link> )? ( ( <ESCAPE> <link linkend="prod70">charVal</link> ) | ( <ID> <link linkend="prod70">charVal</link> ) )? ( <ID> ( <link linkend="prod71">intVal</link> )? )? ( <ID> <link linkend="prod71">intVal</link> )? <RPAREN> ( <AS> )? <link linkend="prod2">id</link></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod69" xreflabel="textColumn"/>textColumn</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod2">id</link> <link linkend="prod31">dataType</link> ( <ID> <link linkend="prod71">intVal</link> )?</para></entry></row>
+<link linkend="prod2">id</link> <link linkend="prod32">dataType</link> ( <ID> <link linkend="prod71">intVal</link> )?</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod72" xreflabel="xmlQuery"/>xmlQuery</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLQUERY> <LPAREN> ( <link linkend="prod73">xmlNamespaces</link> <COMMA> )? <link linkend="prod1">stringVal</link> ( <ID> <link linkend="prod55">derivedColumn</link> ( <COMMA> <link linkend="prod55">derivedColumn</link> )* )? ( ( <NULL> | <link linkend="prod58">nonReserved</link> ) <ON> <link linkend="prod58">nonReserved</link> )? <RPAREN></para></entry></row>
+<XMLQUERY> <LPAREN> ( <link linkend="prod73">xmlNamespaces</link> <COMMA> )? <link linkend="prod1">stringVal</link> ( <ID> <link linkend="prod56">derivedColumn</link> ( <COMMA> <link linkend="prod56">derivedColumn</link> )* )? ( ( <NULL> | <link linkend="prod15">nonReserved</link> ) <ON> <link linkend="prod15">nonReserved</link> )? <RPAREN></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod65" xreflabel="xmlTable"/>xmlTable</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLTABLE> <LPAREN> ( <link linkend="prod73">xmlNamespaces</link> <COMMA> )? <link linkend="prod1">stringVal</link> ( <ID> <link linkend="prod55">derivedColumn</link> ( <COMMA> <link linkend="prod55">derivedColumn</link> )* )? ( <ID> <link linkend="prod74">xmlColumn</link> ( <COMMA> <link linkend="prod74">xmlColumn</link> )* )? <RPAREN> ( <AS> )? <link linkend="prod2">id</link></para></entry></row>
+<XMLTABLE> <LPAREN> ( <link linkend="prod73">xmlNamespaces</link> <COMMA> )? <link linkend="prod1">stringVal</link> ( <ID> <link linkend="prod56">derivedColumn</link> ( <COMMA> <link linkend="prod56">derivedColumn</link> )* )? ( <ID> <link linkend="prod74">xmlColumn</link> ( <COMMA> <link linkend="prod74">xmlColumn</link> )* )? <RPAREN> ( <AS> )? <link linkend="prod2">id</link></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod74" xreflabel="xmlColumn"/>xmlColumn</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod2">id</link> ( ( <FOR> <link linkend="prod58">nonReserved</link> ) | ( <link linkend="prod31">dataType</link> ( <DEFAULT_KEYWORD> <link linkend="prod16">expression</link> )? ( <link linkend="prod58">nonReserved</link> <link linkend="prod1">stringVal</link> )? ) )</para></entry></row>
+<link linkend="prod2">id</link> ( ( <FOR> <link linkend="prod15">nonReserved</link> ) | ( <link linkend="prod32">dataType</link> ( <DEFAULT_KEYWORD> <link linkend="prod17">expression</link> )? ( <link linkend="prod15">nonReserved</link> <link linkend="prod1">stringVal</link> )? ) )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod71" xreflabel="intVal"/>intVal</para></entry>
<entry align="left" valign="top"><para>::=
@@ -645,11 +645,11 @@
<entry align="left" valign="top"><para>::=
( <ID> ( ( <AS> )? <link linkend="prod2">id</link> )? )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod40" xreflabel="where"/>where</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod41" xreflabel="where"/>where</para></entry>
<entry align="left" valign="top"><para>::=
-<WHERE> <link linkend="prod28">criteria</link></para></entry></row>
+<WHERE> <link linkend="prod29">criteria</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod28" xreflabel="criteria"/>criteria</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod29" xreflabel="criteria"/>criteria</para></entry>
<entry align="left" valign="top"><para>::=
<link linkend="prod75">compoundCritOr</link></para></entry></row>
<row>
@@ -667,7 +667,7 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod78" xreflabel="booleanPrimary"/>booleanPrimary</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod34">translateCriteria</link> | ( <link linkend="prod79">commonValueExpression</link> ( ( <link linkend="prod80">betweenCrit</link> | <link linkend="prod81">matchCrit</link> | <link linkend="prod82">setCrit</link> | <link linkend="prod83">isNullCrit</link> | <link linkend="prod84">subqueryCompareCriteria</link> | <link linkend="prod85">compareCrit</link> ) )? ) | <link linkend="prod86">existsCriteria</link> | <link linkend="prod30">hasCriteria</link> )</para></entry></row>
+( <link linkend="prod35">translateCriteria</link> | ( <link linkend="prod79">commonValueExpression</link> ( ( <link linkend="prod80">betweenCrit</link> | <link linkend="prod81">matchCrit</link> | <link linkend="prod82">setCrit</link> | <link linkend="prod83">isNullCrit</link> | <link linkend="prod84">subqueryCompareCriteria</link> | <link linkend="prod85">compareCrit</link> ) )? ) | <link linkend="prod86">existsCriteria</link> | <link linkend="prod31">hasCriteria</link> )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod87" xreflabel="operator"/>operator</para></entry>
<entry align="left" valign="top"><para>::=
@@ -709,41 +709,41 @@
<entry align="left" valign="top"><para>::=
<EXISTS> <link linkend="prod88">subquery</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod50" xreflabel="groupBy"/>groupBy</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod51" xreflabel="groupBy"/>groupBy</para></entry>
<entry align="left" valign="top"><para>::=
<GROUP> <BY> ( <link linkend="prod89">groupByItem</link> ( <COMMA> <link linkend="prod89">groupByItem</link> )* )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod89" xreflabel="groupByItem"/>groupByItem</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod16">expression</link></para></entry></row>
+<link linkend="prod17">expression</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod51" xreflabel="having"/>having</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod52" xreflabel="having"/>having</para></entry>
<entry align="left" valign="top"><para>::=
-<HAVING> <link linkend="prod28">criteria</link></para></entry></row>
+<HAVING> <link linkend="prod29">criteria</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod43" xreflabel="orderby"/>orderby</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod44" xreflabel="orderby"/>orderby</para></entry>
<entry align="left" valign="top"><para>::=
<ORDER> <BY> <link linkend="prod90">sortSpecification</link> ( <COMMA> <link linkend="prod90">sortSpecification</link> )*</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod90" xreflabel="sortSpecification"/>sortSpecification</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod91">sortKey</link> ( <ASC> | <DESC> )? ( <link linkend="prod58">nonReserved</link> <link linkend="prod58">nonReserved</link> )?</para></entry></row>
+<link linkend="prod91">sortKey</link> ( <ASC> | <DESC> )? ( <link linkend="prod15">nonReserved</link> <link linkend="prod15">nonReserved</link> )?</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod91" xreflabel="sortKey"/>sortKey</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod16">expression</link></para></entry></row>
+<link linkend="prod17">expression</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod44" xreflabel="limit"/>limit</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod45" xreflabel="limit"/>limit</para></entry>
<entry align="left" valign="top"><para>::=
<LIMIT> ( <INTEGERVAL> | <QMARK> ) ( <COMMA> ( <INTEGERVAL> | <QMARK> ) )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod37" xreflabel="option"/>option</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod38" xreflabel="option"/>option</para></entry>
<entry align="left" valign="top"><para>::=
<OPTION> ( <MAKEDEP> <link linkend="prod2">id</link> ( <COMMA> <link linkend="prod2">id</link> )* | <MAKENOTDEP> <link linkend="prod2">id</link> ( <COMMA> <link linkend="prod2">id</link> )* | <NOCACHE> ( <link linkend="prod2">id</link> ( <COMMA> <link linkend="prod2">id</link> )* )? )*</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod16" xreflabel="expression"/>expression</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod17" xreflabel="expression"/>expression</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod28">criteria</link></para></entry></row>
+<link linkend="prod29">criteria</link></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod79" xreflabel="commonValueExpression"/>commonValueExpression</para></entry>
<entry align="left" valign="top"><para>::=
@@ -767,19 +767,19 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod95" xreflabel="valueExpressionPrimary"/>valueExpressionPrimary</para></entry>
<entry align="left" valign="top"><para>::=
-( <QMARK> | <link linkend="prod97">literal</link> | ( <LBRACE> <link linkend="prod58">nonReserved</link> <link linkend="prod98">function</link> <RBRACE> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod56">xmlAgg</link> ) | ( <link linkend="prod98">function</link> ) | ( <ID> ) | <link linkend="prod88">subquery</link> | ( <LPAREN> <link linkend="prod16">expression</link> <RPAREN> ) | <link linkend="prod99">searchedCaseExpression</link> | <link linkend="prod100">caseExpression</link> )</para></entry></row>
+( <QMARK> | <link linkend="prod97">literal</link> | ( <LBRACE> <link linkend="prod15">nonReserved</link> <link linkend="prod98">function</link> <RBRACE> ) | ( <link linkend="prod58">aggregateSymbol</link> ) | ( <link linkend="prod58">aggregateSymbol</link> ) | ( <link linkend="prod58">aggregateSymbol</link> ) | ( <link linkend="prod57">xmlAgg</link> ) | ( <link linkend="prod98">function</link> ) | ( <ID> ) | <link linkend="prod88">subquery</link> | ( <LPAREN> <link linkend="prod17">expression</link> <RPAREN> ) | <link linkend="prod99">searchedCaseExpression</link> | <link linkend="prod100">caseExpression</link> )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod100" xreflabel="caseExpression"/>caseExpression</para></entry>
<entry align="left" valign="top"><para>::=
-<CASE> <link linkend="prod16">expression</link> ( <WHEN> <link linkend="prod16">expression</link> <THEN> <link linkend="prod16">expression</link> )+ ( <ELSE> <link linkend="prod16">expression</link> )? <END></para></entry></row>
+<CASE> <link linkend="prod17">expression</link> ( <WHEN> <link linkend="prod17">expression</link> <THEN> <link linkend="prod17">expression</link> )+ ( <ELSE> <link linkend="prod17">expression</link> )? <END></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod99" xreflabel="searchedCaseExpression"/>searchedCaseExpression</para></entry>
<entry align="left" valign="top"><para>::=
-<CASE> ( <WHEN> <link linkend="prod28">criteria</link> <THEN> <link linkend="prod16">expression</link> )+ ( <ELSE> <link linkend="prod16">expression</link> )? <END></para></entry></row>
+<CASE> ( <WHEN> <link linkend="prod29">criteria</link> <THEN> <link linkend="prod17">expression</link> )+ ( <ELSE> <link linkend="prod17">expression</link> )? <END></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod98" xreflabel="function"/>function</para></entry>
<entry align="left" valign="top"><para>::=
-( ( <CONVERT> <LPAREN> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod31">dataType</link> <RPAREN> ) | ( <CAST> <LPAREN> <link linkend="prod16">expression</link> <AS> <link linkend="prod31">dataType</link> <RPAREN> ) | ( <link linkend="prod58">nonReserved</link> <LPAREN> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod101">stringConstant</link> <RPAREN> ) | ( <link linkend="prod58">nonReserved</link> <LPAREN> <link linkend="prod102">intervalType</link> <COMMA> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod16">expression</link> <RPAREN> ) | <link linkend="prod103">queryString</link> | ( ( <LEFT> | <RIGHT> | <CHAR> | <USER> | <YEAR> | <MONTH> | <HOUR> | <MINUTE> | <SECOND> | <XMLCONCAT> | <XMLCOMMENT> ) <LPAREN> ( <link linkend="prod16">expression</link> !
( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | ( ( <INSERT> ) <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | ( ( <TRANSLATE> ) <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | <link linkend="prod104">xmlParse</link> | <link linkend="prod105">xmlElement</link> | ( <XMLPI> <LPAREN> ( <ID> <link linkend="prod106">idExpression</link> | <link linkend="prod106">idExpression</link> ) ( <COMMA> <link linkend="prod16">expression</link> )? <RPAREN> ) | <link linkend="prod107">xmlForest</link> | <link linkend="prod68">xmlSerialize</link> | <link linkend="prod72">xmlQuery</link> | ( <link linkend="prod2">id</link> <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )*!
)? <RPAREN> ) )</para></entry></row>
+( ( <CONVERT> <LPAREN> <link linkend="prod17">expression</link> <COMMA> <link linkend="prod32">dataType</link> <RPAREN> ) | ( <CAST> <LPAREN> <link linkend="prod17">expression</link> <AS> <link linkend="prod32">dataType</link> <RPAREN> ) | ( <link linkend="prod15">nonReserved</link> <LPAREN> <link linkend="prod17">expression</link> <COMMA> <link linkend="prod101">stringConstant</link> <RPAREN> ) | ( <link linkend="prod15">nonReserved</link> <LPAREN> <link linkend="prod102">intervalType</link> <COMMA> <link linkend="prod17">expression</link> <COMMA> <link linkend="prod17">expression</link> <RPAREN> ) | <link linkend="prod103">queryString</link> | ( ( <LEFT> | <RIGHT> | <CHAR> | <USER> | <YEAR> | <MONTH> | <HOUR> | <MINUTE> | <SECOND> | <XMLCONCAT> | <XMLCOMMENT> ) <LPAREN> ( <link linkend="prod17">expression</link> !
( <COMMA> <link linkend="prod17">expression</link> )* )? <RPAREN> ) | ( ( <INSERT> ) <LPAREN> ( <link linkend="prod17">expression</link> ( <COMMA> <link linkend="prod17">expression</link> )* )? <RPAREN> ) | ( ( <TRANSLATE> ) <LPAREN> ( <link linkend="prod17">expression</link> ( <COMMA> <link linkend="prod17">expression</link> )* )? <RPAREN> ) | <link linkend="prod104">xmlParse</link> | <link linkend="prod105">xmlElement</link> | ( <XMLPI> <LPAREN> ( <ID> <link linkend="prod106">idExpression</link> | <link linkend="prod106">idExpression</link> ) ( <COMMA> <link linkend="prod17">expression</link> )? <RPAREN> ) | <link linkend="prod107">xmlForest</link> | <link linkend="prod68">xmlSerialize</link> | <link linkend="prod72">xmlQuery</link> | ( <link linkend="prod2">id</link> <LPAREN> ( <link linkend="prod17">expression</link> ( <COMMA> <link linkend="prod17">expression</link> )*!
)? <RPAREN> ) )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod101" xreflabel="stringConstant"/>stringConstant</para></entry>
<entry align="left" valign="top"><para>::=
@@ -787,23 +787,23 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod104" xreflabel="xmlParse"/>xmlParse</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLPARSE> <LPAREN> <link linkend="prod58">nonReserved</link> <link linkend="prod16">expression</link> ( <link linkend="prod58">nonReserved</link> )? <RPAREN></para></entry></row>
+<XMLPARSE> <LPAREN> <link linkend="prod15">nonReserved</link> <link linkend="prod17">expression</link> ( <link linkend="prod15">nonReserved</link> )? <RPAREN></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod103" xreflabel="queryString"/>queryString</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod58">nonReserved</link> <LPAREN> <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod55">derivedColumn</link> )* <RPAREN></para></entry></row>
+<link linkend="prod15">nonReserved</link> <LPAREN> <link linkend="prod17">expression</link> ( <COMMA> <link linkend="prod56">derivedColumn</link> )* <RPAREN></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod105" xreflabel="xmlElement"/>xmlElement</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLELEMENT> <LPAREN> ( <ID> <link linkend="prod2">id</link> | <link linkend="prod2">id</link> ) ( <COMMA> <link linkend="prod73">xmlNamespaces</link> )? ( <COMMA> <link linkend="prod108">xmlAttributes</link> )? ( <COMMA> <link linkend="prod16">expression</link> )* <RPAREN></para></entry></row>
+<XMLELEMENT> <LPAREN> ( <ID> <link linkend="prod2">id</link> | <link linkend="prod2">id</link> ) ( <COMMA> <link linkend="prod73">xmlNamespaces</link> )? ( <COMMA> <link linkend="prod108">xmlAttributes</link> )? ( <COMMA> <link linkend="prod17">expression</link> )* <RPAREN></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod108" xreflabel="xmlAttributes"/>xmlAttributes</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLATTRIBUTES> <LPAREN> <link linkend="prod55">derivedColumn</link> ( <COMMA> <link linkend="prod55">derivedColumn</link> )* <RPAREN></para></entry></row>
+<XMLATTRIBUTES> <LPAREN> <link linkend="prod56">derivedColumn</link> ( <COMMA> <link linkend="prod56">derivedColumn</link> )* <RPAREN></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod107" xreflabel="xmlForest"/>xmlForest</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLFOREST> <LPAREN> ( <link linkend="prod73">xmlNamespaces</link> <COMMA> )? <link linkend="prod55">derivedColumn</link> ( <COMMA> <link linkend="prod55">derivedColumn</link> )* <RPAREN></para></entry></row>
+<XMLFOREST> <LPAREN> ( <link linkend="prod73">xmlNamespaces</link> <COMMA> )? <link linkend="prod56">derivedColumn</link> ( <COMMA> <link linkend="prod56">derivedColumn</link> )* <RPAREN></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod73" xreflabel="xmlNamespaces"/>xmlNamespaces</para></entry>
<entry align="left" valign="top"><para>::=
@@ -825,13 +825,13 @@
<entry align="left" valign="top"><para>::=
<link linkend="prod2">id</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod31" xreflabel="dataType"/>dataType</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod32" xreflabel="dataType"/>dataType</para></entry>
<entry align="left" valign="top"><para>::=
( <STRING> | <VARCHAR> | <BOOLEAN> | <BYTE> | <TINYINT> | <SHORT> | <SMALLINT> | <CHAR> | <INTEGER> | <LONG> | <BIGINT> | <BIGINTEGER> | <FLOAT> | <REAL> | <DOUBLE> | <BIGDECIMAL> | <DECIMAL> | <DATE> | <TIME> | <TIMESTAMP> | <OBJECT> | <BLOB> | <CLOB> | <XML> )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod102" xreflabel="intervalType"/>intervalType</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod58">nonReserved</link> )</para></entry></row>
+( <link linkend="prod15">nonReserved</link> )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod97" xreflabel="literal"/>literal</para></entry>
<entry align="left" valign="top"><para>::=
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-07-28 18:27:57 UTC (rev 2387)
@@ -639,7 +639,7 @@
</para>
<para>
Temp tables can be defined implicitly by referencing them in a
- SELECT INTO or in an INSERT statement or explicitly with a CREATE TABLE
+ INSERT statement or explicitly with a CREATE TABLE
statement. Implicitly created temp tables must have a name that
starts with '#'.
</para>
@@ -647,31 +647,39 @@
<para>Creation syntax:
</para>
<listitem>
- <para>CREATE LOCAL TEMPORARY TABLE<temporary table name> (<column name> <data type>,...)
+ <para>CREATE LOCAL TEMPORARY TABLE x (column type, ... [PRIMARY KEY (column, ...)])
</para>
</listitem>
<listitem>
- <para>SELECT <column name>,...INTO <temporary table name> FROM <table name>
+ <para>INSERT INTO #x (column, ...) VALUES (value, ...)
</para>
</listitem>
- <listitem>
- <para>INSERT INTO <temporary table name> ((<column name>,...)VALUES (<value>,...)
- </para>
- </listitem>
</itemizedlist>
<itemizedlist>
<para>Drop syntax:
</para>
<listitem>
- <para>DROP TABLE <temporary table name>
+ <para>DROP TABLE x
</para>
</listitem>
</itemizedlist>
<itemizedlist>
+ <para>Primary Key Support</para>
+ <listitem>
+ <para>All key columns must be comparable.</para>
+ </listitem>
+ <listitem>
+ <para>Use of a primary key creates a clustered index that supports search improvements for comparison, in, like, and order by.</para>
+ </listitem>
+ <listitem>
+ <para>Null is an allowable primary key value, but there must be only 1 row that has an all null key.</para>
+ </listitem>
+ </itemizedlist>
+ <itemizedlist>
<para>Limitations:
</para>
<listitem>
- <para>With the CREATE TABLE syntax only basic table definition (column name and type information) is supported.
+ <para>With the CREATE TABLE syntax only basic table definition (column name and type information) and an optional primary key are supported.
</para>
</listitem>
<listitem>
@@ -691,8 +699,13 @@
</para>
</listitem>
<listitem>
- <para>temp tables are non-transactional.
+ <para>Temp tables are non-transactional.
</para>
+ </listitem>
+ <listitem>
+ <para>Lob values (xml, clob, blob) are tracked by reference rather than by value in a temporary table.
+ Lob values from external sources that are inserted in a temporary table may become unreadable when the associated statement or connection is closed.
+ </para>
</listitem>
</itemizedlist>
<para>The following example is a series of statements that loads a temporary table with data from 2 sources, and with a manually inserted record, and then uses that temp table in a subsequent query.</para>
Added: trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.common.buffer;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.Streamable;
+import org.teiid.dqp.DQPPlugin;
+import org.teiid.query.sql.symbol.Expression;
+
+/**
+ * Tracks lob references so they are not lost during serialization.
+ * TODO: for temp tables we may need to have a copy by value management strategy
+ */
+public class LobManager {
+
+ private Map<String, Streamable<?>> lobReferences = new ConcurrentHashMap<String, Streamable<?>>();
+
+ public void updateReferences(int[] lobIndexes, List<?> tuple)
+ throws TeiidComponentException {
+ for (int i = 0; i < lobIndexes.length; i++) {
+ Object anObj = tuple.get(lobIndexes[i]);
+ if (!(anObj instanceof Streamable<?>)) {
+ continue;
+ }
+ Streamable lob = (Streamable) anObj;
+ if (lob.getReference() == null) {
+ lob.setReference(getLobReference(lob.getReferenceStreamId()).getReference());
+ } else {
+ String id = lob.getReferenceStreamId();
+ this.lobReferences.put(id, lob);
+ }
+ }
+ }
+
+ public Streamable<?> getLobReference(String id) throws TeiidComponentException {
+ Streamable<?> lob = null;
+ if (this.lobReferences != null) {
+ lob = this.lobReferences.get(id);
+ }
+ if (lob == null) {
+ throw new TeiidComponentException(DQPPlugin.Util.getString("ProcessWorker.wrongdata")); //$NON-NLS-1$
+ }
+ return lob;
+ }
+
+ public void clear() {
+ this.lobReferences.clear();
+ }
+
+ public static int[] getLobIndexes(List expressions) {
+ if (expressions == null) {
+ return null;
+ }
+ int[] result = new int[expressions.size()];
+ int resultIndex = 0;
+ for (int i = 0; i < expressions.size(); i++) {
+ Expression expr = (Expression) expressions.get(i);
+ if (DataTypeManager.isLOB(expr.getType()) || expr.getType() == DataTypeManager.DefaultDataClasses.OBJECT) {
+ result[resultIndex++] = i;
+ }
+ }
+ if (resultIndex == 0) {
+ return null;
+ }
+ return Arrays.copyOf(result, resultIndex);
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -126,7 +126,11 @@
} else {
values.setDataTypes(stree.types);
}
- managedBatch = stree.manager.createManagedBatch(values);
+ if (children != null) {
+ managedBatch = stree.keyManager.createManagedBatch(values);
+ } else {
+ managedBatch = stree.leafManager.createManagedBatch(values);
+ }
}
protected void remove() {
@@ -145,6 +149,9 @@
if (managedBatch == null) {
throw new AssertionError("Batch removed"); //$NON-NLS-1$
}
+ if (children != null) {
+ return managedBatch.getBatch(true, stree.keytypes);
+ }
return managedBatch.getBatch(true, stree.types);
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -50,7 +50,8 @@
private int shift = 1;
protected SPage[] header = new SPage[] {new SPage(this, true)};
- protected BatchManager manager;
+ protected BatchManager keyManager;
+ protected BatchManager leafManager;
protected Comparator comparator;
protected int pageSize;
protected int keyLength;
@@ -59,13 +60,16 @@
private AtomicInteger rowCount = new AtomicInteger();
- public STree(BatchManager recman,
+ public STree(BatchManager manager,
+ BatchManager leafManager,
final Comparator comparator,
int pageSize,
int keyLength,
String[] types) {
randomSeed = seedGenerator.nextInt() | 0x00000100; // ensure nonzero
- this.manager = recman;
+ randomSeed = 1;
+ this.keyManager = manager;
+ this.leafManager = leafManager;
this.comparator = comparator;
this.pageSize = Math.max(pageSize, SPage.MIN_PERSISTENT_SIZE);
pageSize >>>= 4;
@@ -144,10 +148,6 @@
return null;
}
- public List find(List k) throws TeiidComponentException {
- return find(k, new LinkedList<SearchResult>());
- }
-
public List insert(List tuple, boolean replace) throws TeiidComponentException {
LinkedList<SearchResult> places = new LinkedList<SearchResult>();
List match = find(tuple, places);
@@ -306,7 +306,8 @@
public void remove() {
truncate();
- this.manager.remove();
+ this.keyManager.remove();
+ this.leafManager.remove();
}
public int getRowCount() {
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -63,13 +63,6 @@
public TupleBatch() {
}
- public static TupleBatch directBatch(int rowOffset, List<List> tuples) {
- TupleBatch result = new TupleBatch();
- result.rowOffset = rowOffset;
- result.tuples = tuples;
- return result;
- }
-
/**
* Constructor
* @param beginRow indicates the row of the tuple source which is the
@@ -156,10 +149,6 @@
this.terminationFlag = terminationFlag;
}
- public String[] getDataTypes() {
- return types;
- }
-
public void setDataTypes(String[] types) {
this.types = types;
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -27,8 +27,6 @@
import java.util.ListIterator;
import java.util.Map;
import java.util.TreeMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
@@ -61,8 +59,6 @@
return types;
}
- private static final AtomicLong LOB_ID = new AtomicLong();
-
//construction state
private BatchManager manager;
private String tupleSourceID;
@@ -77,36 +73,28 @@
private boolean removed;
private boolean forwardOnly;
- //lob management
- private Map<String, Streamable<?>> lobReferences; //references to contained lobs
- private boolean lobs = true;
+ private LobManager lobManager;
+ private int[] lobIndexes;
- public TupleBuffer(BatchManager manager, String id, List<?> schema, int batchSize) {
+ public TupleBuffer(BatchManager manager, String id, List<?> schema, int[] lobIndexes, int batchSize) {
this.manager = manager;
this.tupleSourceID = id;
this.schema = schema;
this.types = getTypeNames(schema);
+ this.lobIndexes = lobIndexes;
+ if (this.lobIndexes != null) {
+ this.lobManager = new LobManager();
+ }
this.batchSize = batchSize;
- if (types != null) {
- int i = 0;
- for (i = 0; i < types.length; i++) {
- if (DataTypeManager.isLOB(types[i]) || types[i] == DataTypeManager.DefaultDataTypes.OBJECT) {
- break;
- }
- }
- if (i == types.length) {
- lobs = false;
- }
- }
}
public boolean isLobs() {
- return lobs;
+ return lobIndexes != null;
}
public void addTuple(List<?> tuple) throws TeiidComponentException {
- if (lobs) {
- correctLobReferences(schema.size(), tuple);
+ if (isLobs()) {
+ lobManager.updateReferences(lobIndexes, tuple);
}
this.rowCount++;
if (batchBuffer == null) {
@@ -131,7 +119,11 @@
}
} else {
//add the lob references only, since they may still be referenced later
- correctLobReferences(batch.getTuples());
+ if (isLobs()) {
+ for (List<?> tuple : batch.getTuples()) {
+ lobManager.updateReferences(lobIndexes, tuple);
+ }
+ }
}
}
@@ -209,9 +201,6 @@
Assertion.isNotNull(entry);
BatchManager.ManagedBatch batch = entry.getValue();
result = batch.getBatch(!forwardOnly, types);
- if (lobs && result.getDataTypes() == null) {
- correctLobReferences(result.getTuples());
- }
result.setDataTypes(types);
if (forwardOnly) {
batches.remove(entry.getKey());
@@ -260,55 +249,12 @@
}
public Streamable<?> getLobReference(String id) throws TeiidComponentException {
- Streamable<?> lob = null;
- if (this.lobReferences != null) {
- lob = this.lobReferences.get(id);
- }
- if (lob == null) {
+ if (lobManager == null) {
throw new TeiidComponentException(DQPPlugin.Util.getString("ProcessWorker.wrongdata")); //$NON-NLS-1$
}
- return lob;
+ return lobManager.getLobReference(id);
}
- /**
- * If a tuple batch is being added with Lobs, then references to
- * the lobs will be held on the {@link TupleSourceInfo}
- * @param batch
- * @throws TeiidComponentException
- */
- @SuppressWarnings("unchecked")
- private void correctLobReferences(List<List> rows) throws TeiidComponentException {
- int columns = schema.size();
- // walk through the results and find all the lobs
- for (List list : rows) {
- correctLobReferences(columns, list);
- }
- }
-
- private void correctLobReferences(int columns, List list)
- throws TeiidComponentException {
- for (int col = 0; col < columns; col++) {
- Object anObj = list.get(col);
-
- if (!(anObj instanceof Streamable<?>)) {
- continue;
- }
- Streamable lob = (Streamable)anObj;
- String id = lob.getReferenceStreamId();
- if (id == null) {
- id = String.valueOf(LOB_ID.getAndIncrement());
- lob.setReferenceStreamId(id);
- }
- if (this.lobReferences == null) {
- this.lobReferences = new ConcurrentHashMap<String, Streamable<?>>();
- }
- this.lobReferences.put(id, lob);
- if (lob.getReference() == null) {
- lob.setReference(getLobReference(lob.getReferenceStreamId()).getReference());
- }
- }
- }
-
public void setForwardOnly(boolean forwardOnly) {
this.forwardOnly = forwardOnly;
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -39,7 +39,6 @@
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Condition;
@@ -52,6 +51,7 @@
import org.teiid.common.buffer.BatchManager;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.FileStore;
+import org.teiid.common.buffer.LobManager;
import org.teiid.common.buffer.STree;
import org.teiid.common.buffer.StorageManager;
import org.teiid.common.buffer.TupleBatch;
@@ -100,15 +100,16 @@
private final int columnCount;
private volatile FileStore store;
private Map<Long, long[]> physicalMapping = new ConcurrentHashMap<Long, long[]>();
- private Map<Long, String[]> types = new ConcurrentSkipListMap<Long, String[]>();
private ReadWriteLock compactionLock = new ReentrantReadWriteLock();
private AtomicLong unusedSpace = new AtomicLong();
+ private int[] lobIndexes;
- private BatchManagerImpl(String newID, int columnCount) {
+ private BatchManagerImpl(String newID, int columnCount, int[] lobIndexes) {
this.id = newID;
this.columnCount = columnCount;
this.store = createFileStore(id);
this.store.setCleanupReference(this);
+ this.lobIndexes = lobIndexes;
}
@Override
@@ -197,6 +198,7 @@
private int beginRow;
private BatchManagerImpl batchManager;
private long id;
+ private LobManager lobManager;
public ManagedBatchImpl(TupleBatch batch, BatchManagerImpl manager) {
id = batchAdded.incrementAndGet();
@@ -204,6 +206,9 @@
this.activeBatch = batch;
this.beginRow = batch.getBeginRow();
this.batchManager = manager;
+ if (this.batchManager.lobIndexes != null) {
+ this.lobManager = new LobManager();
+ }
}
private void addToCache(boolean update) {
@@ -280,6 +285,11 @@
batch.readExternal(ois);
batch.setRowOffset(this.beginRow);
batch.setDataTypes(null);
+ if (lobManager != null) {
+ for (List<?> tuple : batch.getTuples()) {
+ lobManager.updateReferences(batchManager.lobIndexes, tuple);
+ }
+ }
if (cache) {
this.activeBatch = batch;
addToCache(true);
@@ -297,13 +307,18 @@
public synchronized void persist() throws TeiidComponentException {
boolean lockheld = false;
- try {
+ try {
TupleBatch batch = activeBatch;
if (batch != null) {
if (!persistent) {
long count = writeCount.incrementAndGet();
LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
long offset = 0;
+ if (lobManager != null) {
+ for (List<?> tuple : batch.getTuples()) {
+ lobManager.updateReferences(batchManager.lobIndexes, tuple);
+ }
+ }
synchronized (batchManager.store) {
offset = batchManager.getOffset();
OutputStream fsos = new BufferedOutputStream(batchManager.store.createOutputStream(), IO_BUFFER_SIZE);
@@ -313,14 +328,17 @@
long size = batchManager.store.getLength() - offset;
long[] info = new long[] {offset, size};
batchManager.physicalMapping.put(this.id, info);
- batchManager.types.put(this.id, batch.getDataTypes());
}
LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
}
this.batchReference = new WeakReference<TupleBatch>(batch);
+ } else {
+ assert persistent;
}
} catch (IOException e) {
throw new TeiidComponentException(e);
+ } catch (Throwable e) {
+ throw new TeiidComponentException(e);
} finally {
persistent = true;
activeBatch = null;
@@ -343,6 +361,9 @@
if (info != null) {
batchManager.unusedSpace.addAndGet(info[1]);
}
+ if (lobManager != null) {
+ lobManager.clear();
+ }
activeBatch = null;
batchReference = null;
}
@@ -444,23 +465,24 @@
public TupleBuffer createTupleBuffer(final List elements, String groupName,
TupleSourceType tupleSourceType) {
final String newID = String.valueOf(this.tsId.getAndIncrement());
-
- BatchManager batchManager = new BatchManagerImpl(newID, elements.size());
- TupleBuffer tupleBuffer = new TupleBuffer(batchManager, newID, elements, getProcessorBatchSize());
+ int[] lobIndexes = LobManager.getLobIndexes(elements);
+ BatchManager batchManager = new BatchManagerImpl(newID, elements.size(), lobIndexes);
+ TupleBuffer tupleBuffer = new TupleBuffer(batchManager, newID, elements, lobIndexes, getProcessorBatchSize());
LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating TupleBuffer:", newID, "of type ", tupleSourceType); //$NON-NLS-1$ //$NON-NLS-2$
return tupleBuffer;
}
public STree createSTree(final List elements, String groupName, TupleSourceType tupleSourceType, int keyLength) {
- final String newID = String.valueOf(this.tsId.getAndIncrement());
-
- BatchManager bm = new BatchManagerImpl(newID, elements.size());
+ String newID = String.valueOf(this.tsId.getAndIncrement());
+ int[] lobIndexes = LobManager.getLobIndexes(elements);
+ BatchManager bm = new BatchManagerImpl(newID, elements.size(), lobIndexes);
+ BatchManager keyManager = new BatchManagerImpl(String.valueOf(this.tsId.getAndIncrement()), keyLength, null);
int[] compareIndexes = new int[keyLength];
for (int i = 1; i < compareIndexes.length; i++) {
compareIndexes[i] = i;
}
LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID, "of type ", tupleSourceType); //$NON-NLS-1$ //$NON-NLS-2$
- return new STree(bm, new ListNestedSortComparator(compareIndexes), getProcessorBatchSize(), keyLength, TupleBuffer.getTypeNames(elements));
+ return new STree(keyManager, bm, new ListNestedSortComparator(compareIndexes), getProcessorBatchSize(), keyLength, TupleBuffer.getTypeNames(elements));
}
@Override
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -193,7 +193,7 @@
LogManager.logDetail(LogConstants.CTX_DQP, e, "Request Thread", requestID, "- error occurred"); //$NON-NLS-1$ //$NON-NLS-2$
if (!isCanceled()) {
- dqpCore.logMMCommand(this, Event.CANCEL, null);
+ dqpCore.logMMCommand(this, Event.ERROR, null);
//Case 5558: Differentiate between system level errors and
//processing errors. Only log system level errors as errors,
//log the processing errors as warnings only
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -288,7 +288,7 @@
SortUtility sort = new SortUtility(ts, orderBy.getOrderByItems(), Mode.SORT, bm, sessionID);
tb = sort.sort();
} else {
- tb = bm.createTupleBuffer(getColumns(), sessionID, TupleSourceType.PROCESSOR);
+ tb = bm.createTupleBuffer(projectedCols, sessionID, TupleSourceType.PROCESSOR);
List next = null;
while ((next = ts.nextTuple()) != null) {
tb.addTuple(next);
@@ -359,7 +359,7 @@
protected void tuplePassed(List tuple)
throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (rowId != null) {
- tuple.add(0, rowId.getAndAdd(1));
+ tuple.add(0, rowId.getAndIncrement());
}
insertTuple(tuple);
}
Modified: trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2010-07-28 18:04:14 UTC (rev 2386)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2010-07-28 18:27:57 UTC (rev 2387)
@@ -67,7 +67,7 @@
ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
x.setType(DataTypeManager.DefaultDataClasses.INTEGER);
List<ElementSymbol> schema = Arrays.asList(x);
- TupleBuffer tb = new TupleBuffer(new FakeBatchManager(), "x", schema, 32); //$NON-NLS-1$
+ TupleBuffer tb = new TupleBuffer(new FakeBatchManager(), "x", schema, null, 32); //$NON-NLS-1$
tb.setForwardOnly(true);
tb.addTuple(Arrays.asList(1));
TupleBatch batch = tb.getBatch(1);
@@ -90,11 +90,11 @@
ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
x.setType(DataTypeManager.DefaultDataClasses.CLOB);
List<ElementSymbol> schema = Arrays.asList(x);
- TupleBuffer tb = new TupleBuffer(new FakeBatchManager(), "x", schema, 32); //$NON-NLS-1$
+ TupleBuffer tb = new TupleBuffer(new FakeBatchManager(), "x", schema, LobManager.getLobIndexes(schema), 32); //$NON-NLS-1$
ClobType c = new ClobType(new SerialClob(new char[0]));
TupleBatch batch = new TupleBatch(1, new List[] {Arrays.asList(c)});
tb.addTupleBatch(batch, false);
- assertNotNull(c.getReferenceStreamId());
+ assertNotNull(tb.getLobReference(c.getReferenceStreamId()));
}
}
14 years, 5 months
teiid SVN: r2386 - in trunk: cache-jbosscache and 12 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-07-28 14:04:14 -0400 (Wed, 28 Jul 2010)
New Revision: 2386
Added:
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java
Modified:
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/cache-jbosscache/pom.xml
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
trunk/engine/src/main/java/org/teiid/cache/Cache.java
trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
trunk/jboss-integration/pom.xml
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java
trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
Log:
TEIID-1104: Added "ports-*" flag work in the clustered mode, which automatically offsets the ports in Teiid. Also added capability to hook into JBoss Cache in clustered mode for Teiid caching purposes. However, the Teiid does not make use of the distributed cache yet for its ResultSet Cache or metadata cache. Which is coming in next installment.
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-07-28 18:04:14 UTC (rev 2386)
@@ -44,6 +44,10 @@
<property name="maxOpenFiles">64</property>
</bean>
+ <bean name="CacheFactory" class="org.teiid.cache.jboss.ClusterableCacheFactory">
+ <property name="clusteredCacheName">mvcc-shared</property>
+ </bean>
+
<bean name="RuntimeEngineDeployer" class="org.teiid.jboss.deployers.RuntimeEngineDeployer">
<property name="jndiName">teiid/engine-deployer</property>
<property name="profileService"><inject bean="ProfileService"/></property>
@@ -58,7 +62,9 @@
<property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
<property name="securityHelper"><inject bean="SecurityHelper"/></property>
<property name="VDBRepository"><inject bean="VDBRepository"/></property>
+ <property name="cacheFactory"><inject bean="CacheFactory"/></property>
+
<!-- Process pool maximum thread count. (default 64) -->
<property name="maxThreads">64</property>
<!-- Max active plans (default 20). Increase this value on highly concurrent systems - but ensure that the underlying pools can handle the increased load without timeouts. -->
Modified: trunk/cache-jbosscache/pom.xml
===================================================================
--- trunk/cache-jbosscache/pom.xml 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/cache-jbosscache/pom.xml 2010-07-28 18:04:14 UTC (rev 2386)
@@ -24,6 +24,7 @@
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
Added: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java (rev 0)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache.jboss;
+
+import java.io.Serializable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.teiid.cache.Cache;
+import org.teiid.cache.CacheConfiguration;
+import org.teiid.cache.CacheFactory;
+import org.teiid.cache.DefaultCacheFactory;
+import org.teiid.cache.Cache.Type;
+import org.teiid.core.TeiidRuntimeException;
+
+public class ClusterableCacheFactory implements CacheFactory, Serializable {
+ private static final long serialVersionUID = -1992994494154581234L;
+ private CacheFactory delegate;
+ private String cacheName;
+
+ @Override
+ public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+ if (this.delegate == null) {
+ Object cacheManager = getClusteredCache();
+ if (cacheManager == null) {
+ this.delegate = new DefaultCacheFactory();
+ }
+ else {
+ try {
+ this.delegate = new JBossCacheFactory(this.cacheName, cacheManager);
+ } catch (Exception e) {
+ throw new TeiidRuntimeException("Failed to obtain the clusted cache"); //$NON-NLS-1$
+ }
+ }
+ }
+ return delegate.get(type, config);
+ }
+
+ public void setClusteredCacheName(String name) {
+ this.cacheName = name;
+ }
+
+ @Override
+ public void destroy() {
+ this.delegate.destroy();
+ }
+
+ private Object getClusteredCache() {
+ try {
+ Context ctx = new InitialContext();
+ return ctx.lookup("java:CacheManager"); //$NON-NLS-1$
+ } catch (NamingException e) {
+ return null;
+ }
+ }
+}
Property changes on: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -24,12 +24,7 @@
import java.io.Serializable;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
+import org.jboss.cache.CacheManager;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.Region;
@@ -38,7 +33,6 @@
import org.jboss.cache.eviction.FIFOAlgorithmConfig;
import org.jboss.cache.eviction.LFUAlgorithmConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
-import org.jboss.cache.jmx.CacheJmxWrapperMBean;
import org.teiid.cache.Cache;
import org.teiid.cache.CacheConfiguration;
import org.teiid.cache.CacheFactory;
@@ -48,19 +42,14 @@
public class JBossCacheFactory implements CacheFactory, Serializable{
+ private static final long serialVersionUID = -2767452034178675653L;
private transient org.jboss.cache.Cache cacheStore;
private volatile boolean destroyed = false;
- public void setCacheName(String jmxName) {
- try {
- MBeanServer server = MBeanServerFactory.findMBeanServer(null).get(0);
- ObjectName on = new ObjectName(jmxName);
- CacheJmxWrapperMBean cacheWrapper = MBeanServerInvocationHandler.newProxyInstance(server, on, CacheJmxWrapperMBean.class, false);
- this.cacheStore = cacheWrapper.getCache();
- } catch (MalformedObjectNameException e) {
- throw new TeiidRuntimeException(e);
- }
+ public JBossCacheFactory(String name, Object cm) throws Exception {
+ CacheManager cachemanager = (CacheManager)cm;
+ this.cacheStore = cachemanager.getCache(name, true);
}
/**
@@ -68,6 +57,11 @@
*/
public Cache get(Type type, CacheConfiguration config) {
if (!destroyed) {
+
+ if (!this.cacheStore.getCacheStatus().allowInvocations()) {
+ this.cacheStore.start();
+ }
+
Node cacheRoot = this.cacheStore.getRoot().addChild(Fqn.fromString("Teiid")); //$NON-NLS-1$
Node node = cacheRoot.addChild(Fqn.fromString(type.location()));
Modified: trunk/engine/src/main/java/org/teiid/cache/Cache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/Cache.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/cache/Cache.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -32,15 +32,9 @@
*/
public interface Cache<K, V> {
- public enum Type { REGISTRY("Registry"), //$NON-NLS-1$
- SESSION("Session"), //$NON-NLS-1$
- SESSION_MONITOR("Session-Monitor"), //$NON-NLS-1$
- AUTHORIZATION_POLICY("Authorization-Policy"), //$NON-NLS-1$
- AUTHORIZATION_PRINCIPAL("Auhtorization-Principal"), //$NON-NLS-1$
+ public enum Type {SESSION("Session"), //$NON-NLS-1$
RESULTSET("ResultSet"), //$NON-NLS-1$
- VDBMETADATA("VdbMetadata"), //$NON-NLS-1$
- VDBMODELS("VdbModels"), //$NON-NLS-1$
- SCOPED_CACHE("Scoped-Cache"); //$NON-NLS-1$
+ PREPAREDPLAN("PreparaedPlan"); //$NON-NLS-1$
private String location;
Added: trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.teiid.core.util.LRUCache;
+
+public class DefaultCache<K, V> implements Cache<K, V>, Serializable {
+ private static final long serialVersionUID = -511120208522577206L;
+ public static final int DEFAULT_MAX_SIZE_TOTAL = 250;
+
+ Map<K, V> map;
+ Map<String, Cache> children = new HashMap();
+ String name;
+
+ public DefaultCache(String name) {
+ this(name, DEFAULT_MAX_SIZE_TOTAL);
+ }
+
+ public DefaultCache(String name, int maxSize) {
+ if(maxSize < 0){
+ maxSize = DEFAULT_MAX_SIZE_TOTAL;
+ }
+ this.map = Collections.synchronizedMap(new LRUCache<K, V>(maxSize));
+ this.name = name;
+ }
+
+ public void addListener(CacheListener listener) {
+ }
+
+ public void clear() {
+ map.clear();
+ }
+
+ public V get(K key) {
+ return map.get(key);
+ }
+
+ public Set<K> keySet() {
+ return map.keySet();
+ }
+
+ public V put(K key, V value) {
+ return map.put(key, value);
+ }
+
+ public V remove(K key) {
+ return map.remove(key);
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public Collection<V> values() {
+ return map.values();
+ }
+
+ @Override
+ public void removeListener() {
+ }
+
+ @Override
+ public Cache addChild(String name) {
+ if (children.get(name) != null) {
+ return children.get(name);
+ }
+
+ Cache c = new DefaultCache(name);
+ children.put(name, c);
+ return c;
+ }
+
+ @Override
+ public Cache getChild(String name) {
+ return children.get(name);
+ }
+
+ @Override
+ public List<Cache> getChildren() {
+ return new ArrayList<Cache>(children.values());
+ }
+
+ @Override
+ public boolean removeChild(String name) {
+ Object obj = children.remove(name);
+ return obj != null;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -22,12 +22,6 @@
package org.teiid.cache;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import org.teiid.cache.Cache.Type;
import org.teiid.core.TeiidRuntimeException;
@@ -36,9 +30,13 @@
public class DefaultCacheFactory implements CacheFactory, Serializable {
private static final long serialVersionUID = -5541424157695857527L;
- DefaultCache cacheRoot = new DefaultCache("Teiid");
+ DefaultCache cacheRoot;
private volatile boolean destroyed = false;
+ public DefaultCacheFactory() {
+ this.cacheRoot = new DefaultCache("Teiid"); //$NON-NLS-1$
+ }
+
@Override
public void destroy() {
this.destroyed = true;
@@ -52,81 +50,4 @@
}
throw new TeiidRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
}
-
- class DefaultCache<K, V> implements Cache<K, V>, Serializable {
- Map<K, V> map = new HashMap();
- Map<String, Cache> children = new HashMap();
- String name;
-
- public DefaultCache(String name) {
- this.name = name;
- }
- public void addListener(CacheListener listener) {
- }
-
- public void clear() {
- map.clear();
- }
-
- public V get(K key) {
- return map.get(key);
- }
-
- public Set<K> keySet() {
- return map.keySet();
- }
-
- public V put(K key, V value) {
- return map.put(key, value);
- }
-
- public V remove(K key) {
- return map.remove(key);
- }
-
- public int size() {
- return map.size();
- }
-
- public Collection<V> values() {
- return map.values();
- }
-
- @Override
- public void removeListener() {
- }
-
- @Override
- public Cache addChild(String name) {
- if (children.get(name) != null) {
- return children.get(name);
- }
-
- Cache c = new DefaultCache(name);
- children.put(name, c);
- return c;
- }
-
- @Override
- public Cache getChild(String name) {
- return children.get(name);
- }
-
- @Override
- public List<Cache> getChildren() {
- return new ArrayList<Cache>(children.values());
- }
-
- @Override
- public boolean removeChild(String name) {
- Object obj = children.remove(name);
- return obj != null;
- }
-
- @Override
- public String getName() {
- return name;
- }
- }
-
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -22,12 +22,15 @@
package org.teiid.dqp.internal.process;
+import java.io.Serializable;
+
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.sql.lang.Command;
-public class CachedResults {
+public class CachedResults implements Serializable {
+ private static final long serialVersionUID = -5603182134635082207L;
private Command command;
private AnalysisRecord analysisRecord;
private TupleBuffer results;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -44,6 +44,8 @@
import org.teiid.adminapi.Request.ThreadState;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.cache.Cache;
+import org.teiid.cache.CacheFactory;
import org.teiid.client.DQP;
import org.teiid.client.RequestMessage;
import org.teiid.client.ResultsMessage;
@@ -207,6 +209,7 @@
private int maxActivePlans = DQPConfiguration.DEFAULT_MAX_ACTIVE_PLANS;
private int currentlyActivePlans;
private LinkedList<RequestWorkItem> waitingPlans = new LinkedList<RequestWorkItem>();
+ private CacheFactory cacheFactory;
/**
* perform a full shutdown and wait for 10 seconds for all threads to finish
@@ -653,11 +656,11 @@
//result set cache
if (config.isResultSetCacheEnabled()) {
- this.rsCache = new SessionAwareCache<CachedResults>(config.getResultSetCacheMaxEntries());
+ this.rsCache = new SessionAwareCache<CachedResults>(config.getResultSetCacheMaxEntries(), this.cacheFactory, Cache.Type.RESULTSET);
}
//prepared plan cache
- prepPlanCache = new SessionAwareCache<PreparedPlan>(config.getPreparedPlanCacheMaxCount());
+ prepPlanCache = new SessionAwareCache<PreparedPlan>(config.getPreparedPlanCacheMaxCount(), this.cacheFactory, Cache.Type.PREPAREDPLAN);
// Processor debug flag
LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", this.processorDebugAllowed)); //$NON-NLS-1$
@@ -831,4 +834,8 @@
return maxSourceRows;
}
+ public void setCacheFactory(CacheFactory factory) {
+ this.cacheFactory = factory;
+ }
+
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -146,7 +146,7 @@
// Defect 13751: Clone the plan in its current state (i.e. before processing) so that it can be used for later queries
prepPlan.setPlan(processPlan.clone());
prepPlan.setAnalysisRecord(analysisRecord);
- this.prepPlanCache.put(id, this.context.isSessionFunctionEvaluated(), prepPlan);
+ this.prepPlanCache.put(id, this.context.isSessionFunctionEvaluated(), this.context.isUserFunctionEvaluated(), prepPlan);
}
} else {
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -363,11 +363,12 @@
}
if (doneProducingBatches && cid != null) {
boolean sessionScope = processor.getContext().isSessionFunctionEvaluated();
+ boolean userScope = processor.getContext().isUserFunctionEvaluated();
CachedResults cr = new CachedResults();
cr.setCommand(originalCommand);
cr.setAnalysisRecord(analysisRecord);
cr.setResults(resultsBuffer);
- dqpCore.getRsCache().put(cid, sessionScope, cr);
+ dqpCore.getRsCache().put(cid, sessionScope, userScope, cr);
}
add = sendResultsIfNeeded(batch);
if (!added) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -22,14 +22,18 @@
package org.teiid.dqp.internal.process;
-import java.util.Collections;
+import java.io.Serializable;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
+import org.teiid.cache.Cache;
+import org.teiid.cache.CacheConfiguration;
+import org.teiid.cache.CacheFactory;
+import org.teiid.cache.DefaultCache;
+import org.teiid.cache.DefaultCacheFactory;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
-import org.teiid.core.util.LRUCache;
import org.teiid.query.parser.ParseInfo;
import org.teiid.vdb.runtime.VDBKey;
@@ -40,29 +44,48 @@
public class SessionAwareCache<T> {
public static final int DEFAULT_MAX_SIZE_TOTAL = 250;
- private Map<CacheID, T> cache;
+ private Cache<CacheID, T> localCache;
+ private Cache<CacheID, T> distributedCache;
+
private int maxSize;
private AtomicInteger cacheHit = new AtomicInteger();
SessionAwareCache(){
- this(DEFAULT_MAX_SIZE_TOTAL);
+ this(DEFAULT_MAX_SIZE_TOTAL, new DefaultCacheFactory(), Cache.Type.RESULTSET);
}
- SessionAwareCache (int maxSize ){
+ SessionAwareCache(int maxSize){
+ this(maxSize, new DefaultCacheFactory(), Cache.Type.RESULTSET);
+ }
+
+ SessionAwareCache (int maxSize, final CacheFactory cacheFactory, final Cache.Type type){
if(maxSize < 0){
- maxSize = DEFAULT_MAX_SIZE_TOTAL;
+ this.maxSize = DEFAULT_MAX_SIZE_TOTAL;
}
this.maxSize = maxSize;
- cache = Collections.synchronizedMap(new LRUCache<CacheID, T>(maxSize));
+ this.localCache = new DefaultCache<CacheID, T>("local", maxSize); //$NON-NLS-1$
+
+ this.distributedCache = localCache;
+
+// if (type == Cache.Type.PREPAREDPLAN) {
+// this.distributedCache = localCache;
+// }
+// else {
+// this.distributedCache = cacheFactory.get(type, new CacheConfiguration(CacheConfiguration.Policy.LRU, -1, SessionAwareCache.this.maxSize));
+// }
}
public T get(CacheID id){
id.setSessionId(id.originalSessionId);
- T result = cache.get(id);
+ T result = localCache.get(id);
if (result == null) {
id.setSessionId(null);
- result = cache.get(id);
+ result = distributedCache.get(id);
+ if (result == null) {
+ id.setUserName(null);
+ result = distributedCache.get(id);
+ }
}
if (result != null) {
cacheHit.getAndIncrement();
@@ -77,13 +100,20 @@
/**
* Create PreparedPlan for the given clientConn and SQl query
*/
- public void put(CacheID id, boolean sessionSpecific, T t){
+ public void put(CacheID id, boolean sessionSpecific, boolean userSpecific, T t){
+ if (!id.cachable) {
+ return;
+ }
if (sessionSpecific) {
id.setSessionId(id.originalSessionId);
+ this.localCache.put(id, t);
} else {
id.setSessionId(null);
+ if (!userSpecific) {
+ id.setUserName(null);
+ }
+ this.distributedCache.put(id, t);
}
- this.cache.put(id, t);
}
/**
@@ -91,22 +121,27 @@
* @param clientConn ClientConnection
*/
public void clearAll(){
- cache.clear();
+ this.localCache.clear();
+ this.distributedCache.clear();
}
- static class CacheID{
+ static class CacheID implements Serializable {
+ private static final long serialVersionUID = 8261905111156764744L;
private String sql;
private VDBKey vdbInfo;
private ParseInfo pi;
private String sessionId;
private String originalSessionId;
- private List<?> parameters;
+ private List<Serializable> parameters;
+ private String userName;
+ boolean cachable = true;
CacheID(DQPWorkContext context, ParseInfo pi, String sql){
this.sql = sql;
this.vdbInfo = new VDBKey(context.getVdbName(), context.getVdbVersion());
this.pi = pi;
this.originalSessionId = context.getSessionId();
+ this.userName = context.getUserName();
}
private void setSessionId(String sessionId) {
@@ -114,8 +149,22 @@
}
public void setParameters(List<?> parameters) {
- this.parameters = parameters;
+ if (parameters != null && !parameters.isEmpty()) {
+ this.parameters = new ArrayList<Serializable>();
+ for (Object obj:parameters) {
+ if (obj instanceof Serializable) {
+ this.parameters.add((Serializable)obj);
+ }
+ else{
+ this.cachable = false;
+ }
+ }
+ }
}
+
+ public void setUserName(String name) {
+ this.userName = name;
+ }
public boolean equals(Object obj){
if(obj == this) {
@@ -126,6 +175,7 @@
}
CacheID that = (CacheID)obj;
return this.pi.equals(that.pi) && this.vdbInfo.equals(that.vdbInfo) && this.sql.equals(that.sql)
+ && EquivalenceUtil.areEqual(this.userName, that.userName)
&& EquivalenceUtil.areEqual(this.sessionId, that.sessionId)
&& EquivalenceUtil.areEqual(this.parameters, that.parameters);
}
@@ -143,7 +193,7 @@
//for testing purpose
int getSpaceUsed() {
- return cache.size();
+ return localCache.size();
}
int getSpaceAllowed() {
return maxSize;
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -46,7 +46,8 @@
* descriptor.
*/
public class FunctionDescriptor implements Serializable, Cloneable {
-
+ private static final long serialVersionUID = 5374103983118037242L;
+
private static final boolean ALLOW_NAN_INFINITY = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.allowNanInfinity", false); //$NON-NLS-1$
private String name;
@@ -238,6 +239,11 @@
throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0002, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0002, getName()));
}
+ if (getDeterministic() == FunctionMethod.USER_DETERMINISTIC && values.length > 0 && values[0] instanceof CommandContext) {
+ CommandContext cc = (CommandContext)values[0];
+ cc.setUserFunctionEvaluated(true);
+ }
+
if (getDeterministic() >= FunctionMethod.SESSION_DETERMINISTIC && values.length > 0 && values[0] instanceof CommandContext) {
CommandContext cc = (CommandContext)values[0];
cc.setSessionFunctionEvaluated(true);
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -56,7 +56,8 @@
* @see FunctionCategoryConstants
*/
public class FunctionMethod implements Serializable {
-
+ private static final long serialVersionUID = -8039086494296455152L;
+
private static final String NOT_ALLOWED = "NOT_ALLOWED"; //$NON-NLS-1$
private static final String ALLOWED = "ALLOWED"; //$NON-NLS-1$
private static final String REQUIRED = "REQUIRED"; //$NON-NLS-1$
@@ -83,9 +84,10 @@
*/
public static final int DETERMINISTIC = 0;
public static final int SERVER_DETERMINISTIC = 1;
- public static final int SESSION_DETERMINISTIC = 2;
- public static final int COMMAND_DETERMINISTIC = 3;
- public static final int NONDETERMINISTIC = 4;
+ public static final int USER_DETERMINISTIC = 2;
+ public static final int SESSION_DETERMINISTIC = 3;
+ public static final int COMMAND_DETERMINISTIC = 4;
+ public static final int NONDETERMINISTIC = 5;
private String name;
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -192,12 +192,12 @@
new FunctionParameter[] {
new FunctionParameter("roleType", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, FunctionMethod.SESSION_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, FunctionMethod.USER_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(new FunctionMethod("hasRole", QueryPlugin.Util.getString("SystemSource.hasRole_description"), SECURITY, FunctionMethod.CANNOT_PUSHDOWN, SECURITY_FUNCTION_CLASS, "hasRole", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, FunctionMethod.SESSION_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, FunctionMethod.USER_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addFormatNumberFunctions() {
@@ -769,13 +769,15 @@
private void addUserFunction() {
functions.add(
new FunctionMethod("user", QueryPlugin.Util.getString("SystemSource.User_desc"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "user", null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.User_result")), false, FunctionMethod.SESSION_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.User_result")), false, FunctionMethod.USER_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addCurrentDatabaseFunction() {
+ // this function is actually session_deterministic, however for caching purposes it has been set deterministic
+ // as caching is already scoped to the VDB.
functions.add(
new FunctionMethod("current_database", QueryPlugin.Util.getString("SystemSource.current_database_desc"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "current_database", null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("current_database_result")), false, FunctionMethod.SESSION_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("current_database_result")), false, FunctionMethod.DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addEnvFunction() {
Modified: trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -22,12 +22,15 @@
package org.teiid.query.parser;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
-public class ParseInfo {
+public class ParseInfo implements Serializable{
+ private static final long serialVersionUID = -7323683731955992888L;
+
public Map<String, Integer> nameCounts = new HashMap<String, Integer>();
public int referenceCount = 0;
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -90,6 +90,8 @@
private boolean sessionFunctionEvaluated;
+ private boolean userFunctionEvaluated;
+
private Set<String> groups;
private long timeSliceEnd = Long.MAX_VALUE;
@@ -147,6 +149,14 @@
globalState.sessionFunctionEvaluated = sessionFunctionEvaluated;
}
+ public boolean isUserFunctionEvaluated() {
+ return globalState.userFunctionEvaluated;
+ }
+
+ public void setUserFunctionEvaluated(boolean userFunctionEvaluated) {
+ globalState.userFunctionEvaluated = userFunctionEvaluated;
+ }
+
/**
* @return
*/
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -61,7 +61,7 @@
//No PreparedPlan at the begining
assertNull(cache.get(id));
//create one
- cache.put(id, true, new PreparedPlan());
+ cache.put(id, true, false, new PreparedPlan());
//should have one now
assertNotNull("Unable to get prepared plan from cache", cache.get(id)); //$NON-NLS-1$
}
@@ -148,7 +148,7 @@
CacheID id = new CacheID(session, pi, dummy.toString());
PreparedPlan pPlan = new PreparedPlan();
- cache.put(id, true, pPlan);
+ cache.put(id, true, false, pPlan);
pPlan.setCommand(dummy);
pPlan.setPlan(new RelationalPlan(new ProjectNode(i)));
AnalysisRecord analysisRecord = new AnalysisRecord(true, false);
Modified: trunk/jboss-integration/pom.xml
===================================================================
--- trunk/jboss-integration/pom.xml 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/jboss-integration/pom.xml 2010-07-28 18:04:14 UTC (rev 2386)
@@ -22,9 +22,14 @@
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-api</artifactId>
</dependency>
-
+
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-cache-jbosscache</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
<scope>provided</scope>
</dependency>
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -54,6 +54,7 @@
import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.adminapi.jboss.AdminProvider;
+import org.teiid.cache.CacheFactory;
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
import org.teiid.client.util.ExceptionUtil;
@@ -128,28 +129,43 @@
// create the necessary services
createClientServices();
+ int offset = 0;
+ String portBinding = System.getProperty("jboss.service.binding.set"); //$NON-NLS-1$
+ if (portBinding != null && portBinding.startsWith("ports-")) { //$NON-NLS-1$
+ if (portBinding.equals("ports-default")) { //$NON-NLS-1$
+ offset = 0;
+ }
+ else {
+ try {
+ offset = Integer.parseInt(portBinding.substring(portBinding.length()-2))*100;
+ } catch (NumberFormatException e) {
+ offset = 0;
+ }
+ }
+ }
+
this.csr.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
this.csr.registerClientService(DQP.class, proxyService(DQP.class, this.dqpCore, LogConstants.CTX_DQP), LogConstants.CTX_DQP);
this.csr.registerClientService(Admin.class, proxyService(Admin.class, admin, LogConstants.CTX_ADMIN_API), LogConstants.CTX_ADMIN_API);
if (this.jdbcSocketConfiguration.isEnabled()) {
- this.jdbcSocket = new SocketListener(this.jdbcSocketConfiguration, csr, this.dqpCore.getBufferManager());
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid JDBC = ",(this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ this.jdbcSocket = new SocketListener(this.jdbcSocketConfiguration, csr, this.dqpCore.getBufferManager(), offset);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid JDBC = ",(this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber()+offset)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_not_enabled", "jdbc connections")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (this.adminSocketConfiguration.isEnabled()) {
- this.adminSocket = new SocketListener(this.adminSocketConfiguration, csr, this.dqpCore.getBufferManager());
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid Admin", (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ this.adminSocket = new SocketListener(this.adminSocketConfiguration, csr, this.dqpCore.getBufferManager(), offset);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid Admin", (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber()+offset)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_not_enabled", "admin connections")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (this.odbcSocketConfiguration.isEnabled()) {
this.vdbRepository.odbcEnabled();
- this.odbcSocket = new ODBCSocketListener(this.odbcSocketConfiguration, csr, this.dqpCore.getBufferManager());
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("odbc_enabled","Teiid ODBC - SSL=", (this.odbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"ON":"OFF")+" Host = "+this.odbcSocketConfiguration.getHostAddress().getHostName()+" Port = "+this.odbcSocketConfiguration.getPortNumber())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ this.odbcSocket = new ODBCSocketListener(this.odbcSocketConfiguration, csr, this.dqpCore.getBufferManager(), offset);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("odbc_enabled","Teiid ODBC - SSL=", (this.odbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"ON":"OFF")+" Host = "+this.odbcSocketConfiguration.getHostAddress().getHostName()+" Port = "+this.odbcSocketConfiguration.getPortNumber()+offset)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("odbc_not_enabled")); //$NON-NLS-1$
}
@@ -408,4 +424,8 @@
String targetVDBName, int targetVDBVersion) throws AdminException {
this.vdbRepository.mergeVDBs(sourceVDBName, sourceVDBVersion, targetVDBName, targetVDBVersion);
}
+
+ public void setCacheFactory(CacheFactory factory) {
+ this.dqpCore.setCacheFactory(factory);
+ }
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -33,8 +33,8 @@
public class ODBCSocketListener extends SocketListener {
private ODBCServerRemote.AuthenticationType authType = ODBCServerRemote.AuthenticationType.CLEARTEXT;
- public ODBCSocketListener(SocketConfiguration config, ClientServiceRegistryImpl csr, StorageManager storageManager) {
- super(config, csr, storageManager);
+ public ODBCSocketListener(SocketConfiguration config, ClientServiceRegistryImpl csr, StorageManager storageManager, int portOffset) {
+ super(config, csr, storageManager, portOffset);
}
@Override
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-07-28 17:06:09 UTC (rev 2385)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-07-28 18:04:14 UTC (rev 2386)
@@ -51,8 +51,8 @@
private ExecutorService nettyPool;
private ClientServiceRegistryImpl csr;
- public SocketListener(SocketConfiguration config, ClientServiceRegistryImpl csr, StorageManager storageManager) {
- this(config.getPortNumber(), config.getHostAddress().getHostAddress(), config.getInputBufferSize(), config.getOutputBufferSize(), config.getMaxSocketThreads(), config.getSSLConfiguration(), csr, storageManager);
+ public SocketListener(SocketConfiguration config, ClientServiceRegistryImpl csr, StorageManager storageManager, int portOffset) {
+ this(config.getPortNumber()+portOffset, config.getHostAddress().getHostAddress(), config.getInputBufferSize(), config.getOutputBufferSize(), config.getMaxSocketThreads(), config.getSSLConfiguration(), csr, storageManager);
LogManager.logDetail(LogConstants.CTX_TRANSPORT, RuntimePlugin.Util.getString("SocketTransport.1", new Object[] {config.getHostAddress().getHostAddress(), String.valueOf(config.getPortNumber())})); //$NON-NLS-1$
}
14 years, 5 months
teiid SVN: r2385 - trunk/runtime/src/main/java/org/teiid/deployers.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-07-28 13:06:09 -0400 (Wed, 28 Jul 2010)
New Revision: 2385
Modified:
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
Log:
TEIID-1173: Allowing the empty VDBs to pass through for preview functionality. If the metadata strore is not available then a empty store is created.
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-07-28 16:39:18 UTC (rev 2384)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-07-28 17:06:09 UTC (rev 2385)
@@ -120,6 +120,11 @@
store = dynamicStore;
}
+ // allow empty vdbs for enabling the preview functionality
+ if (preview && store == null) {
+ store = new MetadataStoreGroup();
+ }
+
if (store == null) {
LogManager.logError(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("failed_matadata_load", deployment.getName(), deployment.getVersion())); //$NON-NLS-1$
}
14 years, 5 months
teiid SVN: r2384 - trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-07-28 12:39:18 -0400 (Wed, 28 Jul 2010)
New Revision: 2384
Modified:
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
Log:
TEIID-1172: The setter method were taking the object form of the input variables, where as getter methods were designed with primitive types. Since the injection logic looks for the setter methods based on the getter return types, it was not finding the correct methods thus the error during the deployment.
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-07-28 15:20:07 UTC (rev 2383)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-07-28 16:39:18 UTC (rev 2384)
@@ -63,8 +63,8 @@
return waitTime;
}
- public void setWaitTime(Integer waitTime) {
- this.waitTime = waitTime.intValue();
+ public void setWaitTime(int waitTime) {
+ this.waitTime = waitTime;
}
@TranslatorProperty(display="Rows Per Query", advanced=true)
@@ -72,7 +72,7 @@
return rowCount;
}
- public void setRowCount(Integer rowCount) {
+ public void setRowCount(int rowCount) {
this.rowCount = rowCount;
}
@@ -81,8 +81,8 @@
return this.throwError;
}
- public void setThrowError(Boolean error) {
- this.throwError = error.booleanValue();
+ public void setThrowError(boolean error) {
+ this.throwError = error;
}
@TranslatorProperty(display="Poll interval if using a Asynchronous Connector")
@@ -90,8 +90,8 @@
return this.pollIntervalInMilli;
}
- public void setPollIntervalInMilli(Long intervel) {
- this.pollIntervalInMilli = intervel.longValue();
+ public void setPollIntervalInMilli(long intervel) {
+ this.pollIntervalInMilli = intervel;
}
@Override
14 years, 5 months
teiid SVN: r2383 - in trunk: engine/src/main/java/org/teiid/common/buffer and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-28 11:20:07 -0400 (Wed, 28 Jul 2010)
New Revision: 2383
Modified:
trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-1167 cleaning up index condition logic
Modified: trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java 2010-07-28 04:40:32 UTC (rev 2382)
+++ trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java 2010-07-28 15:20:07 UTC (rev 2383)
@@ -127,6 +127,11 @@
} catch (OptionalDataException e) {
this.encoding = Streamable.ENCODING;
}
+ try {
+ this.type = (Type)in.readObject();
+ } catch (OptionalDataException e) {
+ this.type = Type.UNKNOWN;
+ }
}
@Override
@@ -136,6 +141,7 @@
this.encoding = getEncoding(this);
}
out.writeObject(this.encoding);
+ out.writeObject(this.type);
}
/**
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java 2010-07-28 04:40:32 UTC (rev 2382)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java 2010-07-28 15:20:07 UTC (rev 2383)
@@ -31,15 +31,12 @@
/**
* Implements intelligent browsing over a {@link STree}
- *
- * TODO: when using other values we can be more efficient
- * with paging.
*/
public class TupleBrowser {
private final STree tree;
- private List<List<?>> otherValues;
+ private List<List<Object>> valueSet;
private SPage page;
private int index;
@@ -50,13 +47,30 @@
private TupleBatch values;
private boolean updated;
private boolean direction;
- private boolean range;
+
+ /**
+ * Construct a value based browser
+ * @param sTree
+ * @param valueSet
+ * @param direction
+ */
+ public TupleBrowser(STree sTree, List<List<Object>> valueSet, boolean direction) {
+ this.tree = sTree;
+ this.direction = direction;
+ this.valueSet = valueSet;
+ }
- public TupleBrowser(STree sTree, List<?> lowerBound, List<?> upperBound, List<List<?>> otherValues, boolean range, boolean direction) throws TeiidComponentException {
+ /**
+ * Construct a range based browser
+ * @param sTree
+ * @param lowerBound
+ * @param upperBound
+ * @param direction
+ * @throws TeiidComponentException
+ */
+ public TupleBrowser(STree sTree, List<Object> lowerBound, List<Object> upperBound, boolean direction) throws TeiidComponentException {
this.tree = sTree;
this.direction = direction;
- this.otherValues = otherValues;
- this.range = range;
if (lowerBound != null) {
setPage(lowerBound);
@@ -81,16 +95,11 @@
if (!direction) {
values = upper.values;
}
- } else if (range) {
- //this is a range query
- //TODO: this could also be signaled with an all null key
+ } else {
bound = tree.header[0];
while (bound.next != null) {
bound = bound.next;
}
- } else {
- bound = page;
- boundIndex = index;
}
if (!direction) {
@@ -107,32 +116,65 @@
}
}
- private void setPage(List<?> lowerBound) throws TeiidComponentException {
- if (values != null) {
- int possibleIndex = Collections.binarySearch(values.getTuples(), lowerBound, tree.comparator);
- if (possibleIndex != -1 && possibleIndex != -values.getTuples().size() -1) {
- index = possibleIndex;
- if (possibleIndex < 0) {
- index = -index -1;
- }
- return;
- }
- }
- resetState();
+ private boolean setPage(List<?> lowerBound) throws TeiidComponentException {
LinkedList<SearchResult> places = new LinkedList<SearchResult>();
this.tree.find(lowerBound, places);
SearchResult sr = places.getLast();
page = sr.page;
index = sr.index;
+ boolean result = true;
if (index < 0) {
+ result = false;
index = -index - 1;
}
values = sr.values;
+ return result;
}
+ /**
+ * Returns the next tuple or null if there are no more results.
+ * @return
+ * @throws TeiidComponentException
+ */
public List<?> next() throws TeiidComponentException {
for (;;) {
+ //first check for value iteration
+ if (valueSet != null) {
+ if (valueSet.isEmpty()) {
+ resetState();
+ return null;
+ }
+ List<?> newValue = direction?valueSet.remove(0):valueSet.remove(valueSet.size() -1);
+ if (values != null) {
+ int possibleIndex = Collections.binarySearch(values.getTuples(), newValue, tree.comparator);
+ if (possibleIndex >= 0) {
+ //value exists in the current page
+ index = possibleIndex;
+ return values.getTuples().get(possibleIndex);
+ }
+ //check for end/terminal conditions
+ if (direction && possibleIndex == -values.getTuples().size() -1) {
+ if (page.next == null) {
+ resetState();
+ return null;
+ }
+ } else if (!direction && possibleIndex == -1) {
+ if (page.prev == null) {
+ resetState();
+ return null;
+ }
+ } else {
+ //the value simply doesn't exist
+ continue;
+ }
+ }
+ resetState();
+ if (!setPage(newValue)) {
+ continue;
+ }
+ return values.getTuples().get(index);
+ }
if (page == null) {
return null;
}
@@ -149,19 +191,6 @@
if (page == bound && index == boundIndex) {
resetState();
page = null; //terminate
- } else if (otherValues != null && !range) {
- if (!otherValues.isEmpty()) {
- List newBound = direction?otherValues.remove(0):otherValues.remove(otherValues.size() -1);
- setPage(newBound);
- } else {
- otherValues = null;
- if (page != bound) {
- resetState();
- }
- page = bound;
- index = boundIndex;
- values = bound.values;
- }
} else {
index+=getOffset();
}
@@ -185,6 +214,9 @@
}
private int getOffset() {
+ if (valueSet != null) {
+ return 0;
+ }
return direction?1:-1;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2010-07-28 04:40:32 UTC (rev 2382)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2010-07-28 15:20:07 UTC (rev 2383)
@@ -191,13 +191,9 @@
pinode.setIntoElements(allIntoElements);
pinode.setModelName(modelName);
processNode = pinode;
- if (!metadata.isTemporaryTable(groupID)) {
- SourceCapabilities caps = capFinder.findCapabilities(modelName);
- pinode.setDoBatching(caps.supportsCapability(Capability.BATCHED_UPDATES));
- pinode.setDoBulkInsert(caps.supportsCapability(Capability.BULK_UPDATE));
- } else {
- pinode.setDoBulkInsert(true);
- }
+ SourceCapabilities caps = capFinder.findCapabilities(modelName);
+ pinode.setDoBatching(caps.supportsCapability(Capability.BATCHED_UPDATES));
+ pinode.setDoBulkInsert(caps.supportsCapability(Capability.BULK_UPDATE));
}
} catch(QueryMetadataException e) {
throw new TeiidComponentException(e);
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java 2010-07-28 04:40:32 UTC (rev 2382)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java 2010-07-28 15:20:07 UTC (rev 2383)
@@ -35,13 +35,16 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
+/**
+ * Accumulates information from criteria about a specific index column.
+ */
class IndexCondition {
static IndexCondition[] getIndexConditions(Criteria condition, List<ElementSymbol> keyColumns) {
List<Criteria> crits = Criteria.separateCriteriaByAnd(condition);
IndexCondition[] conditions = new IndexCondition[keyColumns.size()];
for (int i = 0; i < conditions.length; i++) {
- if (i > 0 && (conditions[i - 1].range || conditions[i -1].upper != null)) {
+ if (i > 0 && conditions[i - 1].valueSet.size() != 1) {
break; //don't yet support any other types of composite key lookups
}
conditions[i] = new IndexCondition();
@@ -122,27 +125,25 @@
Constant lower = null;
Constant upper = null;
- boolean range = true;
- TreeSet<Constant> otherValues = new TreeSet<Constant>();
+ TreeSet<Constant> valueSet = new TreeSet<Constant>();
void addCondition(Constant value, int comparisionMode) {
switch (comparisionMode) {
case CompareCriteria.EQ:
- otherValues.clear();
- lower = value;
+ valueSet.clear();
+ valueSet.add(value);
+ lower = null;
upper = null;
- range = false;
break;
case CompareCriteria.GE:
case CompareCriteria.GT:
- if (lower == null) {
- range = true;
+ if (valueSet.isEmpty()) {
lower = value;
}
break;
case CompareCriteria.LE:
case CompareCriteria.LT:
- if (upper == null && range) {
+ if (valueSet.isEmpty()) {
upper = value;
}
break;
@@ -150,21 +151,12 @@
}
void addSet(TreeSet<Constant> values) {
- if (!range && lower != null) {
+ if (!valueSet.isEmpty()) {
return;
}
- Iterator<Constant> iter = values.iterator();
- Constant lowest = iter.next();
- iter.remove();
- lower = lowest;
- range = false;
- iter = values.descendingIterator();
- if (iter.hasNext()) {
- Constant highest = iter.next();
- upper = highest;
- iter.remove();
- }
- otherValues.addAll(values);
+ lower = null;
+ upper = null;
+ valueSet.addAll(values);
}
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-07-28 04:40:32 UTC (rev 2382)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-07-28 15:20:07 UTC (rev 2383)
@@ -300,18 +300,18 @@
}
private TupleBrowser createTupleBrower(Criteria condition, boolean direction) throws TeiidComponentException {
- List lower = null;
- List upper = null;
- List<List<?>> otherValues = null;
- boolean range = true;
+ List<Object> lower = null;
+ List<Object> upper = null;
+ List<List<Object>> values = null;
if (condition != null && rowId == null) {
IndexCondition[] indexConditions = IndexCondition.getIndexConditions(condition, columns.subList(0, tree.getKeyLength()));
if (indexConditions.length > 1 && indexConditions[indexConditions.length - 1] != null) {
- lower = new ArrayList(indexConditions.length);
+ List<Object> value = new ArrayList<Object>(indexConditions.length);
for (IndexCondition indexCondition : indexConditions) {
- lower.add(indexCondition.lower.getValue());
+ value.add(indexCondition.valueSet.iterator().next().getValue());
}
- range = false;
+ values = new ArrayList<List<Object>>(1);
+ values.add(value);
//TODO: support other composite key lookups
} else {
if (indexConditions[0].lower != null) {
@@ -320,14 +320,18 @@
if (indexConditions[0].upper != null) {
upper = Arrays.asList(indexConditions[0].upper.getValue());
}
- otherValues = new ArrayList<List<?>>();
- for (Constant constant : indexConditions[0].otherValues) {
- otherValues.add(Arrays.asList(constant.getValue()));
+ if (!indexConditions[0].valueSet.isEmpty()) {
+ values = new ArrayList<List<Object>>();
+ for (Constant constant : indexConditions[0].valueSet) {
+ values.add(Arrays.asList(constant.getValue()));
+ }
}
- range = indexConditions[0].range;
}
}
- return new TupleBrowser(this.tree, lower, upper, otherValues, range, direction);
+ if (values != null) {
+ return new TupleBrowser(this.tree, values, direction);
+ }
+ return new TupleBrowser(this.tree, lower, upper, direction);
}
public int getRowCount() {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-07-28 04:40:32 UTC (rev 2382)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-07-28 15:20:07 UTC (rev 2383)
@@ -185,7 +185,25 @@
execute("insert into x (e2, e1) values (1, 'c')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
execute("insert into x (e2, e1) values (0, 'd')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
execute("insert into x (e2, e1) values (-1, 'e')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
- execute("select * from x where e1 in ('a', 'c', 'e')", new List[] {Arrays.asList("a", 3), Arrays.asList("c", 1), Arrays.asList("e", -1)}); //$NON-NLS-1$
+ execute("select * from x where e1 in ('a', 'c', 'e', 'f', 'g')", new List[] {Arrays.asList("a", 3), Arrays.asList("c", 1), Arrays.asList("e", -1)}); //$NON-NLS-1$
}
+ @Test public void testInWithIndexUpdate() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (3, 'a')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (1, 'c')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (0, 'd')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (-1, 'e')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("update x set e2 = 5 where e1 in ('a', 'c')", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ }
+
+ @Test public void testCompositeKeyCompareEquals() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e1, e2))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (3, 'a')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (1, 'c')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x where e1 = 'b' and e2 = 2", new List[] {Arrays.asList("b", 2)}); //$NON-NLS-1$
+ }
+
}
14 years, 5 months
teiid SVN: r2382 - in trunk/engine/src: main/java/org/teiid/query/metadata and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-28 00:40:32 -0400 (Wed, 28 Jul 2010)
New Revision: 2382
Added:
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
Modified:
trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLPlanningEnhancements.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1167 adding support for predicate use of the index and validating that the primary key must be comparable
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -49,7 +49,7 @@
private int mask = 1;
private int shift = 1;
- private SPage[] header = new SPage[] {new SPage(this, true)};
+ protected SPage[] header = new SPage[] {new SPage(this, true)};
protected BatchManager manager;
protected Comparator comparator;
protected int pageSize;
@@ -112,7 +112,7 @@
* @throws IOException
* @throws TeiidComponentException
*/
- private List find(List n, LinkedList<SearchResult> places) throws TeiidComponentException {
+ List find(List n, LinkedList<SearchResult> places) throws TeiidComponentException {
SPage x = null;
for (int i = header.length - 1; i >= 0; i--) {
if (x == null) {
@@ -313,10 +313,6 @@
return this.rowCount.get();
}
- public TupleBrowser browse(List lowerBound, List upperBound, boolean direction) {
- return new TupleBrowser(direction);
- }
-
public int truncate() {
int oldSize = rowCount.getAndSet(0);
for (int i = 0; i < header.length; i++) {
@@ -330,86 +326,6 @@
return oldSize;
}
- //TODO: support update/delete from the browser
- public class TupleBrowser {
-
- SPage page = header[0];
- int index;
- TupleBatch values;
- boolean updated;
- boolean direction;
-
- public TupleBrowser(boolean direction) {
- this.direction = direction;
- if (!direction) {
- while (page.prev != null) {
- page = page.prev;
- }
- }
- }
-
- public boolean matchedLower() {
- return false;
- }
-
- public boolean matchedUpper() {
- return false;
- }
-
- public List next() throws TeiidComponentException {
- for (;;) {
- if (values == null) {
- values = page.getValues();
- if (direction) {
- index = 0;
- } else {
- index = values.getTuples().size() - 1;
- }
- }
- if (index >= 0 && index < values.getTuples().size()) {
- List result = values.getTuples().get(index);
- index+=getOffset();
- return result;
- }
- if (updated) {
- page.setValues(values);
- }
- updated = false;
- values = null;
- if (direction) {
- page = page.next;
- } else {
- page = page.prev;
- }
- if (page == null) {
- return null;
- }
- }
- }
-
- private int getOffset() {
- return direction?1:-1;
- }
-
- /**
- * Perform an in-place update of the tuple just returned by the next method
- * WARNING - this must not change the key value
- * @param tuple
- * @throws TeiidComponentException
- */
- public void update(List tuple) throws TeiidComponentException {
- values.getTuples().set(index - getOffset(), tuple);
- updated = true;
- }
-
- /**
- * Notify the browser that the last value was deleted.
- */
- public void removed() {
- index-=getOffset();
- }
- }
-
@Override
public String toString() {
StringBuffer result = new StringBuffer();
Added: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.common.buffer;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.teiid.common.buffer.SPage.SearchResult;
+import org.teiid.core.TeiidComponentException;
+
+/**
+ * Implements intelligent browsing over a {@link STree}
+ *
+ * TODO: when using other values we can be more efficient
+ * with paging.
+ */
+public class TupleBrowser {
+
+ private final STree tree;
+
+ private List<List<?>> otherValues;
+
+ private SPage page;
+ private int index;
+
+ private SPage bound;
+ private int boundIndex = -1;
+
+ private TupleBatch values;
+ private boolean updated;
+ private boolean direction;
+ private boolean range;
+
+ public TupleBrowser(STree sTree, List<?> lowerBound, List<?> upperBound, List<List<?>> otherValues, boolean range, boolean direction) throws TeiidComponentException {
+ this.tree = sTree;
+ this.direction = direction;
+ this.otherValues = otherValues;
+ this.range = range;
+
+ if (lowerBound != null) {
+ setPage(lowerBound);
+ } else {
+ page = sTree.header[0];
+ }
+
+ boolean valid = true;
+
+ if (upperBound != null) {
+ if (this.tree.comparator.compare(upperBound, lowerBound) < 0) {
+ valid = false;
+ }
+ LinkedList<SearchResult> places = new LinkedList<SearchResult>();
+ this.tree.find(upperBound, places);
+ SearchResult upper = places.getLast();
+ bound = upper.page;
+ boundIndex = upper.index;
+ if (boundIndex < 0) {
+ boundIndex = Math.min(upper.values.getTuples().size() - 1, -boundIndex -1);
+ }
+ if (!direction) {
+ values = upper.values;
+ }
+ } else if (range) {
+ //this is a range query
+ //TODO: this could also be signaled with an all null key
+ bound = tree.header[0];
+ while (bound.next != null) {
+ bound = bound.next;
+ }
+ } else {
+ bound = page;
+ boundIndex = index;
+ }
+
+ if (!direction) {
+ SPage swap = page;
+ page = bound;
+ bound = swap;
+ int upperIndex = boundIndex;
+ boundIndex = index;
+ index = upperIndex;
+ }
+
+ if (!valid) {
+ page = null;
+ }
+ }
+
+ private void setPage(List<?> lowerBound) throws TeiidComponentException {
+ if (values != null) {
+ int possibleIndex = Collections.binarySearch(values.getTuples(), lowerBound, tree.comparator);
+ if (possibleIndex != -1 && possibleIndex != -values.getTuples().size() -1) {
+ index = possibleIndex;
+ if (possibleIndex < 0) {
+ index = -index -1;
+ }
+ return;
+ }
+ }
+ resetState();
+ LinkedList<SearchResult> places = new LinkedList<SearchResult>();
+ this.tree.find(lowerBound, places);
+
+ SearchResult sr = places.getLast();
+ page = sr.page;
+ index = sr.index;
+ if (index < 0) {
+ index = -index - 1;
+ }
+ values = sr.values;
+ }
+
+ public List<?> next() throws TeiidComponentException {
+ for (;;) {
+ if (page == null) {
+ return null;
+ }
+ if (values == null) {
+ values = page.getValues();
+ if (direction) {
+ index = 0;
+ } else {
+ index = values.getTuples().size() - 1;
+ }
+ }
+ if (index >= 0 && index < values.getTuples().size()) {
+ List<?> result = values.getTuples().get(index);
+ if (page == bound && index == boundIndex) {
+ resetState();
+ page = null; //terminate
+ } else if (otherValues != null && !range) {
+ if (!otherValues.isEmpty()) {
+ List newBound = direction?otherValues.remove(0):otherValues.remove(otherValues.size() -1);
+ setPage(newBound);
+ } else {
+ otherValues = null;
+ if (page != bound) {
+ resetState();
+ }
+ page = bound;
+ index = boundIndex;
+ values = bound.values;
+ }
+ } else {
+ index+=getOffset();
+ }
+ return result;
+ }
+ resetState();
+ if (direction) {
+ page = page.next;
+ } else {
+ page = page.prev;
+ }
+ }
+ }
+
+ private void resetState() throws TeiidComponentException {
+ if (updated) {
+ page.setValues(values);
+ }
+ updated = false;
+ values = null;
+ }
+
+ private int getOffset() {
+ return direction?1:-1;
+ }
+
+ /**
+ * Perform an in-place update of the tuple just returned by the next method
+ * WARNING - this must not change the key value
+ * @param tuple
+ * @throws TeiidComponentException
+ */
+ public void update(List<?> tuple) throws TeiidComponentException {
+ values.getTuples().set(index - getOffset(), tuple);
+ updated = true;
+ }
+
+ /**
+ * Notify the browser that the last value was deleted.
+ */
+ public void removed() {
+ index-=getOffset();
+ }
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -45,6 +45,13 @@
tempCaps = new BasicSourceCapabilities();
tempCaps.setCapabilitySupport(Capability.BULK_UPDATE, true);
tempCaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ tempCaps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
+ tempCaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ tempCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ tempCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ tempCaps.setCapabilitySupport(Capability.CRITERIA_ISNULL, true);
+ tempCaps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
+ tempCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, true);
}
return tempCaps;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -37,7 +37,7 @@
* value, but that is not true if the value is null. In that case, the type is unknown
* and is set to the null type until the type is resolved at a later point.
*/
-public class Constant implements Expression {
+public class Constant implements Expression, Comparable<Constant> {
private Object value;
private Class type;
@@ -181,5 +181,19 @@
public String toString() {
return SQLStringVisitor.getSQLString(this);
}
+
+ @Override
+ public int compareTo(Constant o) {
+ if (isNull()) {
+ if (o.isNull()) {
+ return 0;
+ }
+ return -1;
+ }
+ if (o.isNull()) {
+ return 1;
+ }
+ return ((Comparable)this.value).compareTo(o.getValue());
+ }
}
Added: trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.tempdata;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+
+class IndexCondition {
+
+ static IndexCondition[] getIndexConditions(Criteria condition, List<ElementSymbol> keyColumns) {
+ List<Criteria> crits = Criteria.separateCriteriaByAnd(condition);
+ IndexCondition[] conditions = new IndexCondition[keyColumns.size()];
+ for (int i = 0; i < conditions.length; i++) {
+ if (i > 0 && (conditions[i - 1].range || conditions[i -1].upper != null)) {
+ break; //don't yet support any other types of composite key lookups
+ }
+ conditions[i] = new IndexCondition();
+ ElementSymbol keyColumn = keyColumns.get(i);
+ for (Iterator<Criteria> critIter = crits.iterator(); critIter.hasNext();) {
+ Criteria criteria = critIter.next();
+ if (criteria instanceof CompareCriteria) {
+ CompareCriteria cc = (CompareCriteria)criteria;
+ if (cc.getOperator() == CompareCriteria.NE
+ || !(cc.getRightExpression() instanceof Constant) || (cc.getOperator() != CompareCriteria.EQ && i > 0)) {
+ critIter.remove();
+ continue;
+ }
+ if (!cc.getLeftExpression().equals(keyColumn)) {
+ continue;
+ }
+ conditions[i].addCondition((Constant)cc.getRightExpression(), cc.getOperator());
+ critIter.remove();
+ } else if (criteria instanceof IsNullCriteria) {
+ IsNullCriteria inc = (IsNullCriteria)criteria;
+ if (inc.isNegated() || !inc.getExpression().equals(keyColumn)) {
+ continue;
+ }
+ conditions[i].addCondition(new Constant(null), CompareCriteria.EQ);
+ critIter.remove();
+ } else {
+ if (i > 0) {
+ critIter.remove();
+ continue;
+ }
+ if (criteria instanceof MatchCriteria) {
+ MatchCriteria matchCriteria = (MatchCriteria)criteria;
+ if (matchCriteria.isNegated() || !matchCriteria.getLeftExpression().equals(keyColumn) || !(matchCriteria.getRightExpression() instanceof Constant)) {
+ continue;
+ }
+ Constant value = (Constant)matchCriteria.getRightExpression();
+ String pattern = (String)value.getValue();
+ boolean escaped = false;
+ StringBuilder prefix = new StringBuilder();
+ for (int j = 0; i < pattern.length(); j++) {
+ char character = pattern.charAt(j);
+
+ if (character == matchCriteria.getEscapeChar() && character != MatchCriteria.NULL_ESCAPE_CHAR) {
+ if (escaped) {
+ prefix.append(character);
+ escaped = false;
+ } else {
+ escaped = true;
+ }
+ } else if (character == MatchCriteria.WILDCARD_CHAR || character == MatchCriteria.MATCH_CHAR) {
+ break;
+ } else {
+ prefix.append(character);
+ }
+ }
+ if (prefix.length() > 0) {
+ conditions[i].addCondition(new Constant(prefix.toString()), CompareCriteria.GE);
+ }
+ } else if (criteria instanceof SetCriteria) {
+ SetCriteria setCriteria = (SetCriteria)criteria;
+ if (!setCriteria.getExpression().equals(keyColumn)) {
+ continue;
+ }
+ TreeSet<Constant> values = new TreeSet<Constant>();
+ for (Expression expr : (List<? extends Expression>)setCriteria.getValues()) {
+ if (!(expr instanceof Constant)) {
+ continue;
+ }
+ values.add((Constant)expr);
+ }
+ conditions[i].addSet(values);
+ }
+ }
+ }
+ }
+ return conditions;
+ }
+
+ Constant lower = null;
+ Constant upper = null;
+ boolean range = true;
+ TreeSet<Constant> otherValues = new TreeSet<Constant>();
+
+ void addCondition(Constant value, int comparisionMode) {
+ switch (comparisionMode) {
+ case CompareCriteria.EQ:
+ otherValues.clear();
+ lower = value;
+ upper = null;
+ range = false;
+ break;
+ case CompareCriteria.GE:
+ case CompareCriteria.GT:
+ if (lower == null) {
+ range = true;
+ lower = value;
+ }
+ break;
+ case CompareCriteria.LE:
+ case CompareCriteria.LT:
+ if (upper == null && range) {
+ upper = value;
+ }
+ break;
+ }
+ }
+
+ void addSet(TreeSet<Constant> values) {
+ if (!range && lower != null) {
+ return;
+ }
+ Iterator<Constant> iter = values.iterator();
+ Constant lowest = iter.next();
+ iter.remove();
+ lower = lowest;
+ range = false;
+ iter = values.descendingIterator();
+ if (iter.hasNext()) {
+ Constant highest = iter.next();
+ upper = highest;
+ iter.remove();
+ }
+ otherValues.addAll(values);
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -34,37 +34,93 @@
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.STree;
+import org.teiid.common.buffer.TupleBrowser;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.TupleSource;
import org.teiid.common.buffer.BufferManager.TupleSourceType;
-import org.teiid.common.buffer.STree.TupleBrowser;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.Evaluator;
+import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.processor.relational.RelationalNode;
import org.teiid.query.processor.relational.SortUtility;
import org.teiid.query.processor.relational.SortUtility.Mode;
-import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.SetClauseList;
-import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.SingleElementSymbol;
/**
* A Teiid Temp Table
- * TODO: an update will not happen unless the tuplesource is accessed
- * TODO: better handling for blocked exceptions (should be rare)
+ * TODO: in this implementation blocked exceptions will not happen
+ * allowing for subquery evaluation though would cause pauses
*/
class TempTable {
+ private final class QueryTupleSource extends TupleBrowserTupleSource {
+ private final Evaluator eval;
+ private final List<SingleElementSymbol> projectedCols;
+ private final Criteria condition;
+ private final boolean project;
+ private final int[] indexes;
+
+ private QueryTupleSource(TupleBrowser browser, Map map,
+ List<SingleElementSymbol> projectedCols, Criteria condition) {
+ super(browser);
+ this.indexes = RelationalNode.getProjectionIndexes(map, projectedCols);
+ this.eval = new Evaluator(map, null, null);
+ this.projectedCols = projectedCols;
+ this.condition = condition;
+ this.project = shouldProject();
+ }
+
+ @Override
+ public List<?> nextTuple() throws TeiidComponentException,
+ TeiidProcessingException {
+ for (;;) {
+ List<?> next = super.nextTuple();
+ if (next == null) {
+ return null;
+ }
+ if (rowId != null) {
+ next = next.subList(1, next.size());
+ }
+ if (condition != null && !eval.evaluate(condition, next)) {
+ continue;
+ }
+ if (project) {
+ next = RelationalNode.projectTuple(indexes, next);
+ }
+ return next;
+ }
+ }
+
+ private boolean shouldProject() {
+ if (indexes.length == getColumns().size()) {
+ for (int i = 0; i < indexes.length; i++) {
+ if (indexes[i] != i) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public List<? extends Expression> getSchema() {
+ return projectedCols;
+ }
+ }
+
private class TupleBrowserTupleSource implements TupleSource {
private final TupleBrowser browser;
@@ -94,18 +150,17 @@
}
}
- private abstract class UpdateTupleSource implements TupleSource {
+ private abstract class UpdateProcessor {
private TupleSource ts;
protected final Map lookup;
protected final Evaluator eval;
private final Criteria crit;
protected int updateCount = 0;
- protected boolean done;
private List currentTuple;
protected TupleBuffer undoLog;
- UpdateTupleSource(Criteria crit, TupleSource ts) throws TeiidComponentException {
+ UpdateProcessor(Criteria crit, TupleSource ts) throws TeiidComponentException {
this.ts = ts;
this.lookup = RelationalNode.createLookupMap(columns);
this.eval = new Evaluator(lookup, null, null);
@@ -113,32 +168,21 @@
this.undoLog = bm.createTupleBuffer(columns, sessionID, TupleSourceType.PROCESSOR);
}
- void process() throws TeiidComponentException, TeiidProcessingException {
- //still have to worry about blocked exceptions...
- while (currentTuple != null || (currentTuple = ts.nextTuple()) != null) {
- if (crit == null || eval.evaluate(crit, currentTuple)) {
- tuplePassed(currentTuple);
- updateCount++;
- undoLog.addTuple(currentTuple);
+ int process() throws ExpressionEvaluationException, TeiidComponentException, TeiidProcessingException {
+ boolean success = false;
+ try {
+ while (currentTuple != null || (currentTuple = ts.nextTuple()) != null) {
+ if (crit == null || eval.evaluate(crit, currentTuple)) {
+ tuplePassed(currentTuple);
+ updateCount++;
+ undoLog.addTuple(currentTuple);
+ }
+ currentTuple = null;
}
- currentTuple = null;
- }
- }
-
- @Override
- public List<?> nextTuple() throws TeiidComponentException,
- TeiidProcessingException {
- if (done) {
- return null;
- }
- try {
- process();
- done = true;
- } catch (BlockedException e) {
- //this is horrible...
- throw e;
+ success();
+ success = true;
} finally {
- if (!done) {
+ if (!success) {
TupleSource undoTs = undoLog.createIndexedTupleSource();
List<?> tuple = null;
try {
@@ -149,26 +193,19 @@
}
}
+ close();
}
- return Arrays.asList(updateCount);
+ return updateCount;
}
+
+ @SuppressWarnings("unused")
+ void success() throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {}
protected abstract void tuplePassed(List tuple) throws BlockedException, TeiidComponentException, TeiidProcessingException;
protected abstract void undo(List tuple) throws TeiidComponentException, TeiidProcessingException;
- @Override
- public List<SingleElementSymbol> getSchema() {
- return Command.getUpdateCommandSymbol();
- }
-
- @Override
- public int available() {
- return 0;
- }
-
- @Override
- public void closeSource() {
+ public void close() {
ts.closeSource();
undoLog.remove();
}
@@ -180,8 +217,10 @@
private List<ElementSymbol> columns;
private BufferManager bm;
private String sessionID;
+ private TempMetadataID tid;
- TempTable(BufferManager bm, List<ElementSymbol> columns, int primaryKeyLength, String sessionID) {
+ TempTable(TempMetadataID tid, BufferManager bm, List<ElementSymbol> columns, int primaryKeyLength, String sessionID) {
+ this.tid = tid;
this.bm = bm;
if (primaryKeyLength == 0) {
ElementSymbol id = new ElementSymbol("rowId"); //$NON-NLS-1$
@@ -196,8 +235,9 @@
this.sessionID = sessionID;
}
- public TupleSource createTupleSource(List<SingleElementSymbol> cols, Criteria condition, OrderBy orderBy) throws TeiidComponentException, TeiidProcessingException {
+ public TupleSource createTupleSource(final List<SingleElementSymbol> projectedCols, final Criteria condition, OrderBy orderBy) throws TeiidComponentException, TeiidProcessingException {
Map map = RelationalNode.createLookupMap(getColumns());
+
Boolean direction = null;
boolean orderByUsingIndex = false;
if (orderBy != null && rowId == null) {
@@ -239,39 +279,9 @@
if (!orderByUsingIndex) {
direction = OrderBy.ASC;
}
- TupleBrowser browser = createTupleBrower(null, direction);
- final int[] indexes = RelationalNode.getProjectionIndexes(map, cols);
- final ArrayList<SingleElementSymbol> projectedCols = new ArrayList<SingleElementSymbol>(cols);
- for (SingleElementSymbol singleElementSymbol : projectedCols) {
- if (singleElementSymbol instanceof AliasSymbol) {
-
- }
- }
- final boolean project = shouldProject(indexes);
- TupleSource ts = new TupleBrowserTupleSource(browser) {
-
- @Override
- public List<?> nextTuple() throws TeiidComponentException,
- TeiidProcessingException {
- List<?> next = super.nextTuple();
- if (next == null) {
- return null;
- }
- if (rowId != null) {
- next = next.subList(1, next.size());
- }
- if (project) {
- next = RelationalNode.projectTuple(indexes, next);
- }
- return next;
- }
-
- @Override
- public List<? extends Expression> getSchema() {
- return projectedCols;
- }
- };
+ TupleBrowser browser = createTupleBrower(condition, direction);
+ TupleSource ts = new QueryTupleSource(browser, map, projectedCols, condition);
TupleBuffer tb = null;
if (!orderByUsingIndex && orderBy != null) {
@@ -289,22 +299,37 @@
return tb.createIndexedTupleSource(true);
}
- private boolean shouldProject(final int[] indexes) {
- if (indexes.length == getColumns().size()) {
- for (int i = 0; i < indexes.length; i++) {
- if (indexes[i] != i) {
- return true;
+ private TupleBrowser createTupleBrower(Criteria condition, boolean direction) throws TeiidComponentException {
+ List lower = null;
+ List upper = null;
+ List<List<?>> otherValues = null;
+ boolean range = true;
+ if (condition != null && rowId == null) {
+ IndexCondition[] indexConditions = IndexCondition.getIndexConditions(condition, columns.subList(0, tree.getKeyLength()));
+ if (indexConditions.length > 1 && indexConditions[indexConditions.length - 1] != null) {
+ lower = new ArrayList(indexConditions.length);
+ for (IndexCondition indexCondition : indexConditions) {
+ lower.add(indexCondition.lower.getValue());
}
+ range = false;
+ //TODO: support other composite key lookups
+ } else {
+ if (indexConditions[0].lower != null) {
+ lower = Arrays.asList(indexConditions[0].lower.getValue());
+ }
+ if (indexConditions[0].upper != null) {
+ upper = Arrays.asList(indexConditions[0].upper.getValue());
+ }
+ otherValues = new ArrayList<List<?>>();
+ for (Constant constant : indexConditions[0].otherValues) {
+ otherValues.add(Arrays.asList(constant.getValue()));
+ }
+ range = indexConditions[0].range;
}
- return false;
- }
- return true;
+ }
+ return new TupleBrowser(this.tree, lower, upper, otherValues, range, direction);
}
- private TupleBrowser createTupleBrower(List<Criteria> conditions, boolean direction) {
- return tree.browse(null, null, direction);
- }
-
public int getRowCount() {
return tree.getRowCount();
}
@@ -324,8 +349,8 @@
return columns;
}
- public TupleSource insert(List<List<Object>> tuples) throws TeiidComponentException {
- UpdateTupleSource uts = new UpdateTupleSource(null, new CollectionTupleSource(tuples.iterator(), getColumns())) {
+ public TupleSource insert(List<List<Object>> tuples) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
+ UpdateProcessor up = new UpdateProcessor(null, new CollectionTupleSource(tuples.iterator(), getColumns())) {
protected void tuplePassed(List tuple)
throws BlockedException, TeiidComponentException, TeiidProcessingException {
@@ -341,16 +366,18 @@
}
};
- return uts;
+ int updateCount = up.process();
+ tid.setCardinality(tree.getRowCount());
+ return CollectionTupleSource.createUpdateCountTupleSource(updateCount);
}
- public TupleSource update(Criteria crit, final SetClauseList update) throws TeiidComponentException {
+ public TupleSource update(Criteria crit, final SetClauseList update) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
final boolean primaryKeyChangePossible = canChangePrimaryKey(update);
- final TupleBrowser browser = createTupleBrower(null, OrderBy.ASC);
- UpdateTupleSource uts = new UpdateTupleSource(crit, new TupleBrowserTupleSource(browser)) {
+ final TupleBrowser browser = createTupleBrower(crit, OrderBy.ASC);
+ UpdateProcessor up = new UpdateProcessor(crit, new TupleBrowserTupleSource(browser)) {
protected TupleBuffer changeSet;
- protected TupleSource changeSetProcessor;
+ protected UpdateProcessor changeSetProcessor;
@Override
protected void tuplePassed(List tuple)
@@ -373,14 +400,21 @@
}
@Override
- void process() throws TeiidComponentException,
- TeiidProcessingException {
- super.process();
+ protected void undo(List tuple) throws TeiidComponentException, TeiidProcessingException {
+ if (primaryKeyChangePossible) {
+ insertTuple(tuple);
+ } else {
+ updateTuple(tuple);
+ }
+ }
+
+ @Override
+ void success() throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
//existing tuples have been removed
//changeSet contains possible updates
if (primaryKeyChangePossible) {
if (changeSetProcessor == null) {
- changeSetProcessor = new UpdateTupleSource(null, changeSet.createIndexedTupleSource(true)) {
+ changeSetProcessor = new UpdateProcessor(null, changeSet.createIndexedTupleSource(true)) {
@Override
protected void tuplePassed(List tuple) throws BlockedException,
TeiidComponentException, TeiidProcessingException {
@@ -395,24 +429,15 @@
};
}
- changeSetProcessor.nextTuple(); //when this returns, we're up to date
+ changeSetProcessor.process(); //when this returns, we're up to date
}
}
@Override
- protected void undo(List tuple) throws TeiidComponentException, TeiidProcessingException {
- if (primaryKeyChangePossible) {
- insertTuple(tuple);
- } else {
- updateTuple(tuple);
- }
- }
-
- @Override
- public void closeSource() {
- super.closeSource();
+ public void close() {
+ super.close();
if (changeSetProcessor != null) {
- changeSetProcessor.closeSource(); // causes a revert of the change set
+ changeSetProcessor.close(); // causes a revert of the change set
}
if (changeSet != null) {
changeSet.remove();
@@ -420,7 +445,8 @@
}
};
- return uts;
+ int updateCount = up.process();
+ return CollectionTupleSource.createUpdateCountTupleSource(updateCount);
}
private boolean canChangePrimaryKey(final SetClauseList update) {
@@ -434,9 +460,9 @@
return false;
}
- public TupleSource delete(Criteria crit) throws TeiidComponentException {
- final TupleBrowser browser = createTupleBrower(null, OrderBy.ASC);
- UpdateTupleSource uts = new UpdateTupleSource(crit, new TupleBrowserTupleSource(browser)) {
+ public TupleSource delete(Criteria crit) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
+ final TupleBrowser browser = createTupleBrower(crit, OrderBy.ASC);
+ UpdateProcessor up = new UpdateProcessor(crit, new TupleBrowserTupleSource(browser)) {
@Override
protected void tuplePassed(List tuple)
throws ExpressionEvaluationException,
@@ -450,7 +476,9 @@
insertTuple(tuple);
}
};
- return uts;
+ int updateCount = up.process();
+ tid.setCardinality(tree.getRowCount());
+ return CollectionTupleSource.createUpdateCountTupleSource(updateCount);
}
private void insertTuple(List<Object> list) throws TeiidComponentException, TeiidProcessingException {
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -95,7 +95,7 @@
columns.removeAll(primaryKey);
columns.addAll(0, primaryKey);
}
- TempTable tempTable = new TempTable(buffer, columns, create.getPrimaryKey().size(), sessionID);
+ TempTable tempTable = new TempTable(id, buffer, columns, create.getPrimaryKey().size(), sessionID);
groupToTupleSourceID.put(tempTableName, tempTable);
}
@@ -131,10 +131,7 @@
return element;
}
};
- PostOrderNavigator.doVisit(query.getSelect(), emv);
- if (query.getOrderBy() != null) {
- PostOrderNavigator.doVisit(query.getOrderBy(), emv);
- }
+ PostOrderNavigator.doVisit(query, emv);
return table.createTupleSource(command.getProjectedSymbols(), query.getCriteria(), query.getOrderBy());
}
if (command instanceof ProcedureContainer) {
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -57,6 +57,7 @@
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Create;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.Delete;
import org.teiid.query.sql.lang.DependentSetCriteria;
@@ -1061,6 +1062,13 @@
}
}
+ @Override
+ public void visit(Create obj) {
+ if (!obj.getPrimaryKey().isEmpty()) {
+ validateSortable(obj.getPrimaryKey());
+ }
+ }
+
/**
* @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.Drop)
*/
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-07-28 04:40:32 UTC (rev 2382)
@@ -276,7 +276,7 @@
ERR.015.012.0023 = Unable to translate criteria on the update command against the virtual group, the element {0} is mapped to an expression whose elements are not present on the command in the procedure using the translated criteria.
ERR.015.012.0024 = The following data elements are not supported in the SELECT clause: {0}.
ERR.015.012.0025 = Command must project at least one symbol
-ERR.015.012.0026 = Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used in SELECT DISTINCT, ORDER BY, GROUP BY, or non-all set queries: [{0}]
+ERR.015.012.0026 = Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used in SELECT DISTINCT, ORDER BY, GROUP BY, KEYS, or non-all set queries: [{0}]
ERR.015.012.0027 = Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used in comparison: {0}.
ValidationVisitor.expression_requires_name = Non-column expressions require a name in XMLATTRIBUTES, XMLFOREST, or QUERYSTRING
ValidationVisitor.invalid_lookup_key=Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used as LOOKUP key columns: {0}.
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -157,4 +157,35 @@
execute("select * from x order by e1", new List[] {Arrays.asList("a", 3), Arrays.asList("b", 2)}); //$NON-NLS-1$
}
+ @Test public void testCompareEqualsWithIndex() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e2))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (3, 'a')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x where e2 = 3", new List[] {Arrays.asList("a", 3)}); //$NON-NLS-1$
+ }
+
+ @Test public void testLikeWithIndex() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (3, 'a')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x where e1 like 'z%'", new List[0]); //$NON-NLS-1$
+ }
+
+ @Test public void testIsNullWithIndex() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (3, null)", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x where e1 is null", new List[] {Arrays.asList(null, 3)}); //$NON-NLS-1$
+ }
+
+ @Test public void testInWithIndex() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (3, 'a')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (1, 'c')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (0, 'd')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (-1, 'e')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x where e1 in ('a', 'c', 'e')", new List[] {Arrays.asList("a", 3), Arrays.asList("c", 1), Arrays.asList("e", -1)}); //$NON-NLS-1$
+ }
+
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLPlanningEnhancements.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLPlanningEnhancements.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLPlanningEnhancements.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -454,7 +454,7 @@
ExecSqlInstruction instr = (ExecSqlInstruction)list.get(2);
- ProcessorPlan plan = (ProcessorPlan)instr.info.getPlan();
+ ProcessorPlan plan = instr.info.getPlan();
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
@@ -468,7 +468,7 @@
0, // Null
0, // PlanExecution
1, // Project
- 1, // Select
+ 0, // Select
0, // Sort
0 // UnionAll
});
@@ -494,7 +494,7 @@
ExecSqlInstruction instr = (ExecSqlInstruction)list.get(2);
- ProcessorPlan plan = (ProcessorPlan)instr.info.getPlan();
+ ProcessorPlan plan = instr.info.getPlan();
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
0, // DependentAccess
@@ -507,7 +507,7 @@
0, // Null
0, // PlanExecution
1, // Project
- 1, // Select
+ 0, // Select
0, // Sort
0 // UnionAll
});
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-07-27 23:06:31 UTC (rev 2381)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-07-28 04:40:32 UTC (rev 2382)
@@ -1879,6 +1879,12 @@
@Test public void testSelectIntoWithNull() {
helpValidate("SELECT null, null, null, null INTO pm1.g1 FROM pm1.g2", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
}
+
+ @Test public void testCreateWithNonSortablePrimaryKey() {
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+ Command command = helpResolve("create local temporary table x (column1 string, column2 clob, primary key (column2))", metadata); //$NON-NLS-1$
+ helpRunValidator(command, new String[] {"column2"}, FakeMetadataFactory.example1Cached());
+ }
@Test public void testDropNonTemporary() {
QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
14 years, 5 months
teiid SVN: r2381 - in branches/7.0.x/console: src/main/java/org/teiid/rhq/admin and 2 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-07-27 19:06:31 -0400 (Tue, 27 Jul 2010)
New Revision: 2381
Modified:
branches/7.0.x/console/pom.xml
branches/7.0.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Log:
TEIID-1169: Changed discovery of the Teiid RuntimeEngineDeployer and services to use the Component Name instead of the "name" value for all components of type Teiid and subtype DQP.
Modified: branches/7.0.x/console/pom.xml
===================================================================
--- branches/7.0.x/console/pom.xml 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/pom.xml 2010-07-27 23:06:31 UTC (rev 2381)
@@ -16,10 +16,11 @@
<org.jboss.jopr.as4.version>1.2.0.GA</org.jboss.jopr.as4.version>
-->
<org.jboss.jopr.as5.version>1.2.0.GA</org.jboss.jopr.as5.version>
+ <jopr.jboss.as5.plugin.version>1.4.0.B01</jopr.jboss.as5.plugin.version>
<org.rhq.version>1.3.0.GA</org.rhq.version>
- <org.jboss.jopr.version>1.2.0.GA</org.jboss.jopr.version>
<apache.ant.version>1.7.0</apache.ant.version>
+
</properties>
<dependencies>
@@ -57,14 +58,14 @@
<artifactId>rhq-jmx-plugin</artifactId>
<version>${org.rhq.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-util</artifactId>
- <version>${org.rhq.version}</version>
- </dependency>
<dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${org.rhq.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>mc4j</groupId>
<artifactId>org-mc4j-ems</artifactId>
<version>1.2.6</version>
@@ -127,19 +128,18 @@
</dependency>
<dependency>
- <groupId>org.jboss.jopr</groupId>
- <artifactId>jopr-embedded-jbas5</artifactId>
- <type>war</type>
- <version>${org.jboss.jopr.as5.version}</version>
- </dependency>
-
- <dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
<version>5.1.0.CR2</version>
</dependency>
<dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-5-plugin</artifactId>
+ <version>${jopr.jboss.as5.plugin.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
@@ -150,35 +150,31 @@
<version>1.3.2</version>
</dependency>
- <!-- <dependency>
- <groupId>org.jboss.on</groupId>
- <artifactId>jopr-jboss-as-5-plugin</artifactId>
- <version>2.3.0.EmbJopr.1.2.0-1</version>
- </dependency> -->
+
</dependencies>
-
+
<build>
- <outputDirectory>target/classes</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- <exclude>**/*.properties</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
</project>
\ No newline at end of file
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -22,6 +22,7 @@
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
import org.teiid.adminapi.Transaction;
@@ -36,7 +37,8 @@
public class DQPManagementView implements PluginConstants {
private static ManagedComponent mc = null;
- private static final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private static final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
private static final MetaValueFactory metaValueFactory = MetaValueFactory
.getInstance();
@@ -47,37 +49,38 @@
/*
* Metric methods
*/
- public Object getMetric(String componentType, String identifier,
- String metric, Map<String, Object> valueMap) {
+ public Object getMetric(ProfileServiceConnection connection,
+ String componentType, String identifier, String metric,
+ Map<String, Object> valueMap) {
Object resultObject = new Object();
if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
- resultObject = getPlatformMetric(componentType, metric, valueMap);
+ resultObject = getPlatformMetric(connection, componentType, metric, valueMap);
} else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
- resultObject = getVdbMetric(componentType, identifier, metric,
- valueMap);
+ resultObject = getVdbMetric(connection, componentType, identifier,
+ metric, valueMap);
}
return resultObject;
}
- private Object getPlatformMetric(String componentType, String metric,
+ private Object getPlatformMetric(ProfileServiceConnection connection, String componentType, String metric,
Map<String, Object> valueMap) {
Object resultObject = new Object();
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
- resultObject = new Double(getQueryCount().doubleValue());
+ resultObject = new Double(getQueryCount(connection).doubleValue());
} else {
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount().doubleValue());
+ resultObject = new Double(getSessionCount(connection).doubleValue());
} else {
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(),
+ getRequestCollectionValue(getLongRunningQueries(connection),
longRunningQueries);
resultObject = new Double(longRunningQueries.size());
}
@@ -87,29 +90,31 @@
return resultObject;
}
- private Object getVdbMetric(String componentType, String identifier,
- String metric, Map<String, Object> valueMap) {
+ private Object getVdbMetric(ProfileServiceConnection connection,
+ String componentType, String identifier, String metric,
+ Map<String, Object> valueMap) {
Object resultObject = new Object();
if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getErrorCount((String) valueMap.get(VDB.NAME));
+ resultObject = getErrorCount(connection, (String) valueMap.get(VDB.NAME));
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getVDBStatus((String) valueMap.get(VDB.NAME), 1);
+ resultObject = getVDBStatus(connection, (String) valueMap
+ .get(VDB.NAME), 1);
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
- resultObject = new Double(getQueryCount().doubleValue());
+ resultObject = new Double(getQueryCount(connection).doubleValue());
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount().doubleValue());
+ resultObject = new Double(getSessionCount(connection).doubleValue());
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(),
+ getRequestCollectionValue(getLongRunningQueries(connection),
longRunningQueries);
resultObject = new Double(longRunningQueries.size());
@@ -122,48 +127,49 @@
* Operation methods
*/
- public void executeOperation(ExecutedResult operationResult,
- final Map<String, Object> valueMap) {
+ public void executeOperation(ProfileServiceConnection connection,
+ ExecutedResult operationResult, final Map<String, Object> valueMap) {
if (operationResult.getComponentType().equals(
PluginConstants.ComponentType.Platform.NAME)) {
- executePlatformOperation(operationResult, operationResult
- .getOperationName(), valueMap);
+ executePlatformOperation(connection, operationResult,
+ operationResult.getOperationName(), valueMap);
} else if (operationResult.getComponentType().equals(
PluginConstants.ComponentType.VDB.NAME)) {
- executeVdbOperation(operationResult, operationResult
+ executeVdbOperation(connection, operationResult, operationResult
.getOperationName(), valueMap);
}
}
- private void executePlatformOperation(ExecutedResult operationResult,
- final String operationName, final Map<String, Object> valueMap) {
+ private void executePlatformOperation(ProfileServiceConnection connection,
+ ExecutedResult operationResult, final String operationName,
+ final Map<String, Object> valueMap) {
Collection<Request> resultObject = new ArrayList<Request>();
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
Collection<Transaction> transactionsCollection = new ArrayList<Transaction>();
if (operationName.equals(Platform.Operations.GET_LONGRUNNINGQUERIES)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- getRequestCollectionValue(getLongRunningQueries(), resultObject);
+ getRequestCollectionValue(getLongRunningQueries(connection), resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(Platform.Operations.GET_SESSIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValue(sessionMetaValue,
activeSessionsCollection);
operationResult.setContent(createReportResultList(fieldNameList,
activeSessionsCollection.iterator()));
} else if (operationName.equals(Platform.Operations.GET_REQUESTS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue requestMetaValue = getRequests();
+ MetaValue requestMetaValue = getRequests(connection);
getRequestCollectionValue(requestMetaValue, resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(Platform.Operations.GET_TRANSACTIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue transactionMetaValue = getTransactions();
+ MetaValue transactionMetaValue = getTransactions(connection);
getTransactionCollectionValue(transactionMetaValue,
transactionsCollection);
operationResult.setContent(createReportResultList(fieldNameList,
@@ -174,7 +180,7 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(mc,
+ executeManagedOperation(connection, mc,
Platform.Operations.KILL_TRANSACTION, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.KILL_TRANSACTION; //$NON-NLS-1$
@@ -185,7 +191,7 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(mc, Platform.Operations.KILL_SESSION,
+ executeManagedOperation(connection, mc, Platform.Operations.KILL_SESSION,
args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.KILL_SESSION; //$NON-NLS-1$
@@ -198,7 +204,7 @@
metaValueFactory.create(requestID),
metaValueFactory.create(sessionID) };
try {
- executeManagedOperation(mc, Platform.Operations.KILL_REQUEST,
+ executeManagedOperation(connection, mc, Platform.Operations.KILL_REQUEST,
args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.KILL_REQUEST; //$NON-NLS-1$
@@ -207,30 +213,31 @@
}
}
- private void executeVdbOperation(ExecutedResult operationResult,
+ private void executeVdbOperation(ProfileServiceConnection connection, ExecutedResult operationResult,
final String operationName, final Map<String, Object> valueMap) {
Collection<Request> resultObject = new ArrayList<Request>();
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
String vdbName = (String) valueMap
.get(PluginConstants.ComponentType.VDB.NAME);
String vdbVersion = (String) valueMap
- .get(PluginConstants.ComponentType.VDB.VERSION);
+ .get(PluginConstants.ComponentType.VDB.VERSION);
if (operationName.equals(VDB.Operations.GET_PROPERTIES)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- getProperties(PluginConstants.ComponentType.VDB.NAME);
+ getProperties(connection, PluginConstants.ComponentType.VDB.NAME);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(VDB.Operations.GET_SESSIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValueForVDB(sessionMetaValue,
activeSessionsCollection, vdbName);
operationResult.setContent(createReportResultList(fieldNameList,
activeSessionsCollection.iterator()));
} else if (operationName.equals(VDB.Operations.GET_REQUESTS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue requestMetaValue = getRequestsForVDB(vdbName, Integer.parseInt(vdbVersion));
+ MetaValue requestMetaValue = getRequestsForVDB(connection, vdbName, Integer
+ .parseInt(vdbVersion));
getRequestCollectionValue(requestMetaValue, resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
@@ -242,13 +249,13 @@
* Helper methods
*/
- public MetaValue getProperties(final String component) {
+ public MetaValue getProperties(ProfileServiceConnection connection, final String component) {
MetaValue propertyValue = null;
MetaValue args = null;
try {
- propertyValue = executeManagedOperation(mc,
+ propertyValue = executeManagedOperation(connection, mc,
PluginConstants.Operation.GET_PROPERTIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_PROPERTIES; //$NON-NLS-1$
@@ -259,13 +266,14 @@
}
- protected MetaValue getRequests() {
+ protected MetaValue getRequests(ProfileServiceConnection connection) {
MetaValue requestsCollection = null;
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
+
PluginConstants.Operation.GET_REQUESTS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_REQUESTS; //$NON-NLS-1$
@@ -276,15 +284,15 @@
}
- protected MetaValue getRequestsForVDB(String vdbName, int vdbVersion) {
+ protected MetaValue getRequestsForVDB(ProfileServiceConnection connection, String vdbName, int vdbVersion) {
MetaValue requestsCollection = null;
MetaValue[] args = new MetaValue[] {
MetaValueFactory.getInstance().create(vdbName),
- MetaValueFactory.getInstance().create(vdbVersion)};
+ MetaValueFactory.getInstance().create(vdbVersion) };
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
PluginConstants.ComponentType.VDB.Operations.GET_REQUESTS,
args);
} catch (Exception e) {
@@ -296,13 +304,13 @@
}
- protected MetaValue getTransactions() {
+ protected MetaValue getTransactions(ProfileServiceConnection connection) {
MetaValue transactionsCollection = null;
MetaValue args = null;
try {
- transactionsCollection = executeManagedOperation(mc,
+ transactionsCollection = executeManagedOperation(connection, mc,
Platform.Operations.GET_TRANSACTIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_TRANSACTIONS; //$NON-NLS-1$
@@ -313,13 +321,13 @@
}
- public MetaValue getSessions() {
+ public MetaValue getSessions(ProfileServiceConnection connection) {
MetaValue sessionCollection = null;
MetaValue args = null;
try {
- sessionCollection = executeManagedOperation(mc,
+ sessionCollection = executeManagedOperation(connection, mc,
PluginConstants.Operation.GET_SESSIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_SESSIONS; //$NON-NLS-1$
@@ -329,12 +337,13 @@
}
- public static String getVDBStatus(String vdbName, int version) {
+ public static String getVDBStatus(ProfileServiceConnection connection,
+ String vdbName, int version) {
ManagedComponent mcVdb = null;
try {
mcVdb = ProfileServiceUtil
- .getManagedComponent(
+ .getManagedComponent(connection,
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -347,13 +356,14 @@
LOG.error(msg, e);
}
- return ProfileServiceUtil.getSimpleValue(mcVdb, "status", String.class);
+ return ProfileServiceUtil.getSimpleValue(mcVdb, "status", String.class); //$NON-NLS-1$
}
- public static MetaValue executeManagedOperation(ManagedComponent mc,
+ public static MetaValue executeManagedOperation(
+ ProfileServiceConnection connection, ManagedComponent mc,
String operation, MetaValue... args) throws Exception {
- mc = getDQPManagementView(mc);
+ mc = getDQPManagementView(connection, mc);
for (ManagedOperation mo : mc.getOperations()) {
String opName = mo.getName();
@@ -370,7 +380,7 @@
}
}
}
- throw new Exception("No operation found with given name =" + operation);
+ throw new Exception("No operation found with given name =" + operation); //$NON-NLS-1$
}
@@ -378,9 +388,10 @@
* @param mc
* @return
*/
- private static ManagedComponent getDQPManagementView(ManagedComponent mc) {
+ private static ManagedComponent getDQPManagementView(
+ ProfileServiceConnection connection, ManagedComponent mc) {
try {
- mc = ProfileServiceUtil.getDQPManagementView();
+ mc = ProfileServiceUtil.getTeiidEngineManagedComponent(connection);
} catch (NamingException e) {
final String msg = "NamingException getting the DQPManagementView"; //$NON-NLS-1$
LOG.error(msg, e);
@@ -391,10 +402,11 @@
return mc;
}
- public static MetaValue getManagedProperty(ManagedComponent mc,
+ public static MetaValue getManagedProperty(
+ ProfileServiceConnection connection, ManagedComponent mc,
String property, MetaValue... args) throws Exception {
- mc = getDQPManagementView(mc);
+ mc = getDQPManagementView(connection, mc);
try {
mc.getProperty(property);
@@ -403,17 +415,17 @@
LOG.error(msg, e);
}
- throw new Exception("No property found with given name =" + property);
+ throw new Exception("No property found with given name =" + property); //$NON-NLS-1$
}
- private Integer getQueryCount() {
+ private Integer getQueryCount(ProfileServiceConnection connection) {
Integer count = new Integer(0);
MetaValue requests = null;
Collection<Request> requestsCollection = new ArrayList<Request>();
- requests = getRequests();
+ requests = getRequests(connection);
getRequestCollectionValue(requests, requestsCollection);
@@ -424,10 +436,10 @@
return count;
}
- private Integer getSessionCount() {
+ private Integer getSessionCount(ProfileServiceConnection connection) {
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValue(sessionMetaValue, activeSessionsCollection);
return activeSessionsCollection.size();
}
@@ -437,12 +449,12 @@
* @return count
* @throws Exception
*/
- private int getErrorCount(String vdbName) {
+ private int getErrorCount(ProfileServiceConnection connection, String vdbName) {
ManagedComponent mcVdb = null;
try {
mcVdb = ProfileServiceUtil
- .getManagedComponent(
+ .getManagedComponent(connection,
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -457,7 +469,7 @@
// Get models from VDB
int count = 0;
- ManagedProperty property = mcVdb.getProperty("models");
+ ManagedProperty property = mcVdb.getProperty("models"); //$NON-NLS-1$
CollectionValueSupport valueSupport = (CollectionValueSupport) property
.getValue();
MetaValue[] metaValues = valueSupport.getElements();
@@ -468,7 +480,7 @@
.getValue();
// Get any model errors/warnings
- MetaValue errors = managedObject.getProperty("errors").getValue();
+ MetaValue errors = managedObject.getProperty("errors").getValue(); //$NON-NLS-1$
if (errors != null) {
CollectionValueSupport errorValueSupport = (CollectionValueSupport) errors;
MetaValue[] errorArray = errorValueSupport.getElements();
@@ -478,13 +490,13 @@
return count;
}
- protected MetaValue getLongRunningQueries() {
+ protected MetaValue getLongRunningQueries(ProfileServiceConnection connection) {
MetaValue requestsCollection = null;
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
Platform.Operations.GET_LONGRUNNINGQUERIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.GET_LONGRUNNINGQUERIES; //$NON-NLS-1$
@@ -507,15 +519,15 @@
list.add(request);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
}
- private Collection<Session> getSessionsForVDB(String vdbName) {
+ private Collection<Session> getSessionsForVDB(ProfileServiceConnection connection, String vdbName) {
Collection<Session> activeSessionsCollection = Collections.emptyList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValueForVDB(sessionMetaValue,
activeSessionsCollection, vdbName);
return activeSessionsCollection;
@@ -533,8 +545,8 @@
list.add(transaction);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
- }
+ + " is not a Composite type"); //$NON-NLS-1$
+ }
}
}
}
@@ -551,7 +563,7 @@
list.add(Session);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -571,7 +583,7 @@
}
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -71,6 +71,8 @@
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jbossas5.ProfileServiceComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
import org.teiid.rhq.plugin.objects.ExecutedResult;
@@ -82,7 +84,7 @@
* This class implements required RHQ interfaces and provides common logic used
* by all MetaMatrix components.
*/
-public abstract class Facet implements ResourceComponent, MeasurementFacet,
+public abstract class Facet implements ProfileServiceComponent<ResourceComponent>, MeasurementFacet,
OperationFacet, ConfigurationFacet, ContentFacet, DeleteResourceFacet,
CreateChildResourceFacet {
@@ -146,6 +148,8 @@
deploymentName = context.getResourceKey();
}
+
+
/**
* This is called when the component is being stopped, usually due to the
* plugin container shutting down. You can perform some cleanup here; though
@@ -206,10 +210,10 @@
}
- protected void execute(final ExecutedResult result, final Map valueMap) {
+ protected void execute(final ProfileServiceConnection connection, final ExecutedResult result, final Map valueMap) {
DQPManagementView dqp = new DQPManagementView();
- dqp.executeOperation(result, valueMap);
+ dqp.executeOperation(connection, result, valueMap);
}
@@ -267,7 +271,7 @@
setOperationArguments(name, configuration, valueMap);
- execute(result, valueMap);
+ execute(getConnection(), result, valueMap);
return ((ExecutedOperationResultImpl) result).getOperationResult();
@@ -328,8 +332,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ managementView = getConnection().getManagementView();
managedComponent = managementView.getComponent(this.name, componentType);
Map<String, ManagedProperty> managedProperties = managedComponent
.getProperties();
@@ -371,8 +374,7 @@
throws Exception {
log.trace("Updating " + this.name + " with component "
+ managedComponent.toString() + "...");
- ManagementView managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), false);
+ ManagementView managementView = getConnection().getManagementView();
managementView.updateComponent(managedComponent);
}
@@ -380,7 +382,7 @@
@Override
public void deleteResource() throws Exception {
- DeploymentManager deploymentManager = ProfileServiceUtil
+ DeploymentManager deploymentManager = getConnection()
.getDeploymentManager();
log.debug("Stopping deployment [" + this.deploymentName + "]...");
@@ -512,14 +514,9 @@
.getComponentType(resourceType);
ManagementView managementView = null;
;
- try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
- } catch (NamingException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- if (ProfileServiceUtil.isManagedComponent(managementView, resourceName,
+ managementView = getConnection().getManagementView();
+
+ if (ProfileServiceUtil.isManagedComponent(getConnection(), resourceName,
componentType)) {
createResourceReport.setStatus(CreateResourceStatus.FAILURE);
createResourceReport.setErrorMessage("A " + resourceType.getName()
@@ -593,7 +590,7 @@
}
- DeploymentManager deploymentManager = ProfileServiceUtil
+ DeploymentManager deploymentManager = getConnection()
.getDeploymentManager();
DeploymentUtils
.deployArchive(deploymentManager, archiveFile, false);
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -34,6 +34,7 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.RunState;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -42,7 +43,12 @@
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.ProfileServiceComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -53,10 +59,11 @@
*
*/
public class PlatformComponent extends Facet {
- private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- String[] PLATFORM_SERVICES_NAMES = { "org.teiid.jboss.deployers.RuntimeEngineDeployer",
- "org.teiid.services.BufferServiceImpl", "org.teiid.services.SessionServiceImpl", "org.teiid.transport.SocketConfiguration" };
+ String[] PLATFORM_SERVICES_NAMES = { "RuntimeEngineDeployer", //$NON-NLS-1$
+ "BufferService", "SessionService", "JdbcSocketConfiguration" }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
/*
* (non-Javadoc)
@@ -86,15 +93,17 @@
RunState runState;
try {
- runState = ProfileServiceUtil.getDQPManagementView().getRunState();
+ ManagedComponent mc = ProfileServiceUtil
+ .getTeiidEngineManagedComponent(getConnection());
+ runState = mc.getRunState();
} catch (NamingException e) {
LOG
- .error("Naming exception getting: "
+ .error("Naming exception getting: " //$NON-NLS-1$
+ PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
return AvailabilityType.DOWN;
} catch (Exception e) {
LOG
- .error("Exception getting: "
+ .error("Exception getting: " //$NON-NLS-1$
+ PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
return AvailabilityType.DOWN;
}
@@ -137,10 +146,11 @@
// Initialize any parameters to be used in the retrieval of
// metric values
-
- Object metricReturnObject = view.getMetric(getComponentType(),
- this.getComponentIdentifier(), name, valueMap);
+ Object metricReturnObject = view.getMetric(getConnection(),
+ getComponentType(), this.getComponentIdentifier(),
+ name, valueMap);
+
try {
if (request
.getName()
@@ -205,37 +215,44 @@
ComponentType componentType = new ComponentType(
PluginConstants.ComponentType.Platform.TEIID_TYPE,
PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE);
-
- ManagedComponent managedComponent = null;
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
+ Set<ManagedComponent> mcSet = ProfileServiceUtil
+ .getManagedComponents(getConnection(), componentType);
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
- for (String serviceName : PLATFORM_SERVICES_NAMES) {
+ managementView = getConnection().getManagementView();
- managedComponent = managementView.getComponent(serviceName,
- componentType);
- Map<String, ManagedProperty> managedProperties = managedComponent
- .getProperties();
+ for (ManagedComponent mc : mcSet) {
- ProfileServiceUtil.convertConfigurationToManagedProperties(
- managedProperties, resourceConfig, resourceContext
- .getResourceType());
+ for (String serviceName : PLATFORM_SERVICES_NAMES) {
- try {
- managementView.updateComponent(managedComponent);
- } catch (Exception e) {
- LOG.error("Unable to update component ["
- + managedComponent.getName() + "] of type "
- + componentType + ".", e);
- report.setStatus(ConfigurationUpdateStatus.FAILURE);
- report.setErrorMessageFromThrowable(e);
+ if (mc.getComponentName().equals(serviceName)) {
+ Map<String, ManagedProperty> managedProperties = mc
+ .getProperties();
+
+ ProfileServiceUtil.convertConfigurationToManagedProperties(
+ managedProperties, resourceConfig, resourceContext
+ .getResourceType());
+
+ try {
+ managementView.updateComponent(mc);
+ } catch (Exception e) {
+ LOG.error("Unable to update component [" //$NON-NLS-1$
+ + mc.getComponentName()
+ + "] of type " //$NON-NLS-1$
+ + componentType + ".", e); //$NON-NLS-1$
+ report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ report.setErrorMessageFromThrowable(e);
+ }
+ break;
+ }else{
+ continue;
+ }
}
}
} catch (Exception e) {
- LOG.error("Unable to process update request", e);
+ LOG.error("Unable to process update request", e); //$NON-NLS-1$
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
}
@@ -270,16 +287,18 @@
Set<ManagedComponent> mcSet = null;
try {
mcSet = ProfileServiceUtil
- .getManagedComponents(new org.jboss.managed.api.ComponentType(
- PluginConstants.ComponentType.Platform.TEIID_TYPE,
- PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
+ .getManagedComponents(
+ getConnection(),
+ new org.jboss.managed.api.ComponentType(
+ PluginConstants.ComponentType.Platform.TEIID_TYPE,
+ PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
} catch (NamingException e) {
LOG
- .error("NamingException getting components in Platform loadConfiguration(): "
+ .error("NamingException getting components in Platform loadConfiguration(): " //$NON-NLS-1$
+ e.getMessage());
} catch (Exception e) {
LOG
- .error("Exception getting components in Platform loadConfiguration(): "
+ .error("Exception getting components in Platform loadConfiguration(): " //$NON-NLS-1$
+ e.getMessage());
}
@@ -293,7 +312,8 @@
* @param mcMap
* @param configuration
*/
- private void setProperties(Map<String, ManagedProperty> mcMap, Configuration configuration) {
+ private void setProperties(Map<String, ManagedProperty> mcMap,
+ Configuration configuration) {
for (ManagedProperty mProp : mcMap.values()) {
try {
String value = ProfileServiceUtil.stringValue(mProp.getValue());
@@ -301,10 +321,22 @@
configuration.put(prop);
} catch (Exception e) {
LOG
- .error("Exception setting properties in Platform loadConfiguration(): "
+ .error("Exception setting properties in Platform loadConfiguration(): " //$NON-NLS-1$
+ e.getMessage());
}
}
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return ((ApplicationServerComponent) this.resourceContext
+ .getParentResourceComponent()).getConnection();
+ }
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
\ No newline at end of file
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -34,6 +34,8 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -42,7 +44,8 @@
*/
public class PlatformDiscoveryComponent implements ResourceDiscoveryComponent {
- private final Log log = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log log = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
/**
* Review the javadoc for both {@link ResourceDiscoveryComponent} and
@@ -57,14 +60,13 @@
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
- ManagedComponent mc = ProfileServiceUtil.getManagedComponent(
- new ComponentType(
- PluginConstants.ComponentType.Platform.TEIID_TYPE,
- PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE),
- PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
-
- String version = ProfileServiceUtil.getSimpleValue(mc, "runtimeVersion", String.class);
-
+ ManagedComponent mc = ProfileServiceUtil
+ .getTeiidEngineManagedComponent(((ApplicationServerComponent) discoveryContext
+ .getParentResourceComponent()).getConnection());
+
+ String version = ProfileServiceUtil.getSimpleValue(mc,
+ "runtimeVersion", String.class); //$NON-NLS-1$
+
/**
*
* A discovered resource must have a unique key, that must stay the same
@@ -73,7 +75,8 @@
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
mc.getName(), // Resource Key
- PluginConstants.ComponentType.Platform.TEIID_ENGINE_RESOURCE_NAME, // Resource name
+ PluginConstants.ComponentType.Platform.TEIID_ENGINE_RESOURCE_NAME, // Resource
+ // name
version,
PluginConstants.ComponentType.Platform.TEIID_ENGINE_RESOURCE_DESCRIPTION, // Description
discoveryContext.getDefaultPluginConfiguration(), // Plugin
@@ -88,7 +91,7 @@
// Add to return values
discoveredResources.add(detail);
- log.info("Discovered Teiid instance: " + mc.getName());
+ log.info("Discovered Teiid instance: " + mc.getName()); //$NON-NLS-1$
return discoveredResources;
}
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -34,6 +34,7 @@
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
@@ -43,11 +44,12 @@
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
/**
- * Component class for the MetaMatrix Host Controller process.
+ * Component class for the Teiid Translator.
*
*/
public class TranslatorComponent extends Facet {
@@ -131,7 +133,7 @@
ManagedComponent translator = null;
try {
translator = ProfileServiceUtil
- .getManagedComponent(new ComponentType(
+ .getManagedComponent(getConnection(), new ComponentType(
PluginConstants.ComponentType.Translator.TYPE,
PluginConstants.ComponentType.Translator.SUBTYPE), this.name);
} catch (NamingException e) {
@@ -183,4 +185,16 @@
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return ((PlatformComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ }
+
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
\ No newline at end of file
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -41,6 +41,8 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -56,9 +58,11 @@
ResourceDiscoveryContext discoveryContext)
throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
-
+ ProfileServiceConnection connection = ((PlatformComponent) discoveryContext
+ .getParentResourceComponent()).getConnection();
+
Set<ManagedComponent> translators = ProfileServiceUtil
- .getManagedComponents(new ComponentType(
+ .getManagedComponents(connection, new ComponentType(
PluginConstants.ComponentType.Translator.TYPE,
PluginConstants.ComponentType.Translator.SUBTYPE));
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -50,6 +50,7 @@
import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.Property;
@@ -64,7 +65,10 @@
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.adminapi.impl.PropertyMetadata;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
@@ -132,7 +136,7 @@
// TODO Remove vdb version after no longer viable in Teiid
String version = this.resourceConfiguration.getSimpleValue(
"version", null);
- String status = DQPManagementView.getVDBStatus(this.name, Integer.parseInt(version));
+ String status = DQPManagementView.getVDBStatus(getConnection(), this.name, Integer.parseInt(version));
if (status.equals("ACTIVE")) {
return AvailabilityType.UP;
}
@@ -162,7 +166,7 @@
String name = request.getName();
LOG.debug("Measurement name = " + name); //$NON-NLS-1$
- Object metricReturnObject = view.getMetric(getComponentType(), this
+ Object metricReturnObject = view.getMetric(getConnection(), getComponentType(), this
.getComponentIdentifier(), name, valueMap);
try {
@@ -255,8 +259,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ managementView = getConnection().getManagementView();
managedComponent = managementView.getComponent(this.name,
componentType);
ManagedProperty mp = managedComponent.getProperty("models");//$NON-NLS-1$
@@ -343,7 +346,7 @@
ManagedComponent mcVdb = null;
try {
- mcVdb = ProfileServiceUtil.getManagedComponent(
+ mcVdb = ProfileServiceUtil.getManagedComponent( getConnection(),
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -643,4 +646,16 @@
}
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return ((PlatformComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ }
+
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -34,6 +34,7 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -43,15 +44,18 @@
*/
public class VDBDiscoveryComponent implements ResourceDiscoveryComponent {
- private final Log log = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log log = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext discoveryContext)
throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+ ProfileServiceConnection connection = ((PlatformComponent) discoveryContext
+ .getParentResourceComponent()).getConnection();
Set<ManagedComponent> vdbs = ProfileServiceUtil
- .getManagedComponents(new ComponentType(
+ .getManagedComponents(connection, new ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE));
@@ -104,6 +108,5 @@
return discoveredResources;
}
-
}
\ No newline at end of file
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -33,10 +33,6 @@
* getting a handle to a specific component related to Teiid.
*/
- // The system key is the value used to obtain a connection.
- // In embedded, its a predefined value
- // In enterprise, its the installation directory
- // public final static String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
/**
* These are global properties used by all components
*/
@@ -63,7 +59,8 @@
public final static String TEIID_SUB_TYPE = "dqp"; //$NON-NLS-1$
public final static String TYPE = "ConnectionFactory"; //$NON-NLS-1$
public final static String SUBTYPE = "NoTx"; //$NON-NLS-1$
- public final static String TEIID_RUNTIME_ENGINE = "org.teiid.jboss.deployers.RuntimeEngineDeployer"; //$NON-NLS-1$
+ public final static String COMPNAME = "compName"; //$NON-NLS-1$
+ public final static String TEIID_RUNTIME_ENGINE = "RuntimeEngineDeployer"; //$NON-NLS-1$
public final static String TEIID_ENGINE_RESOURCE_NAME = "Data Services"; //$NON-NLS-1$
public final static String TEIID_ENGINE_RESOURCE_DESCRIPTION = "Teiid Data Service Runtime Engine"; //$NON-NLS-1$
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-07-27 23:06:31 UTC (rev 2381)
@@ -36,7 +36,6 @@
import java.util.Map;
import java.util.Set;
-import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.commons.logging.Log;
@@ -70,6 +69,7 @@
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.TranslatorComponent;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
@@ -80,13 +80,11 @@
protected final static Log LOG = LogFactory
.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");
- private static String DQPNAME = "org.teiid.jboss.deployers.RuntimeEngineDeployer";
+ private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static String DQPNAME = "RuntimeEngineDeployer"; //$NON-NLS-1$
private static final Map<String, ComponentType> COMPONENT_TYPE_CACHE = new HashMap<String, ComponentType>();
- private static final Map<String, KnownDeploymentTypes> DEPLOYMENT_TYPE_CACHE = new HashMap<String, KnownDeploymentTypes>();
- private static final Map<String, Configuration> DEFAULT_PLUGIN_CONFIG_CACHE = new HashMap<String, Configuration>();
- protected static final String PLUGIN = "ProfileService";
+ protected static final String PLUGIN = "ProfileService"; //$NON-NLS-1$
public static ComponentType getComponentType(
@NotNull ResourceType resourceType) {
@@ -96,18 +94,18 @@
Configuration defaultPluginConfig = getDefaultPluginConfiguration(resourceType);
String type = defaultPluginConfig.getSimpleValue(
TranslatorComponent.Config.COMPONENT_TYPE, null);
- if (type == null || type.equals(""))
+ if (type == null || type.equals("")) //$NON-NLS-1$
throw new IllegalStateException(
- "Required plugin configuration property '"
+ "Required plugin configuration property '" //$NON-NLS-1$
+ TranslatorComponent.Config.COMPONENT_TYPE
- + "' is not defined in default template.");
+ + "' is not defined in default template."); //$NON-NLS-1$
String subtype = defaultPluginConfig.getSimpleValue(
TranslatorComponent.Config.COMPONENT_SUBTYPE, null);
- if (subtype == null || subtype.equals(""))
+ if (subtype == null || subtype.equals("")) //$NON-NLS-1$
throw new IllegalStateException(
- "Required plugin configuration property '"
+ "Required plugin configuration property '" //$NON-NLS-1$
+ TranslatorComponent.Config.COMPONENT_SUBTYPE
- + "' is not defined in default template.");
+ + "' is not defined in default template."); //$NON-NLS-1$
ComponentType componentType = new ComponentType(type, subtype);
COMPONENT_TYPE_CACHE.put(resourceTypeName, componentType);
return componentType;
@@ -127,13 +125,14 @@
* @param componentType
* @return
*/
- public static boolean isManagedComponent(ManagementView managementView,
- String name, ComponentType componentType) {
+ public static boolean isManagedComponent(
+ ProfileServiceConnection connection, String name,
+ ComponentType componentType) {
boolean isDeployed = false;
if (name != null) {
try {
- ManagedComponent component = getManagedComponent(componentType,
- name);
+ ManagedComponent component = getManagedComponent(connection,
+ componentType, name);
if (component != null)
isDeployed = true;
} catch (Exception e) {
@@ -154,13 +153,11 @@
* @throws Exception
*/
public static ManagedComponent getManagedComponent(
- ComponentType componentType, String componentName)
- throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, true);
+ ProfileServiceConnection connection, ComponentType componentType,
+ String componentName) throws NamingException, Exception {
+ ManagedComponent mc = connection.getManagementView().getComponent(
+ componentName, componentType);
- ManagedComponent mc = mv.getComponent(componentName, componentType);
-
return mc;
}
@@ -174,16 +171,52 @@
* @throws Exception
*/
public static Set<ManagedComponent> getManagedComponents(
- ComponentType componentType) throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, true);
+ ProfileServiceConnection connection, ComponentType componentType)
+ throws NamingException, Exception {
- Set<ManagedComponent> mcSet = mv.getComponentsForType(componentType);
+ Set<ManagedComponent> mcSet = connection.getManagementView()
+ .getComponentsForType(componentType);
return mcSet;
}
/**
+ * Get the {@link ManagedComponent} for the {@link ComponentType} and sub
+ * type.
+ *
+ * @return Set of {@link ManagedComponent}s
+ * @throws NamingException
+ * @throws Exception
+ */
+ public static ManagedComponent getTeiidEngineManagedComponent(
+ ProfileServiceConnection connection) throws NamingException,
+ Exception {
+
+ ManagedComponent mc = null;
+
+ try {
+ Set<ManagedComponent> mcSet = ProfileServiceUtil.getManagedComponents(
+ connection, new ComponentType(
+ PluginConstants.ComponentType.Platform.TEIID_TYPE,
+ PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
+
+ for (ManagedComponent mcInstance : mcSet) {
+ String compName = (String) mcInstance.getComponentName();
+ if (compName != null
+ && compName
+ .equals(PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE)) {
+ mc = mcInstance;
+ break;
+ }
+ }
+ }catch(RuntimeException e){
+ throw new Exception("Exception getting Teiid Runtime Engine: "+ e.getMessage()); //$NON-NLS-1$
+ }
+
+ return mc;
+ }
+
+ /**
* @param {@link ManagementView}
* @return
*/
@@ -203,39 +236,26 @@
* @throws NamingException
* @throws Exception
*/
- public static DeploymentManager getDeploymentManager()
- throws NamingException, Exception {
- ProfileService ps = getProfileService();
- DeploymentManager deploymentManager = ps.getDeploymentManager();
+ public static DeploymentManager getDeploymentManager(
+ ProfileServiceConnection connection) throws NamingException,
+ Exception {
- return deploymentManager;
+ return connection.getDeploymentManager();
}
/**
- * @return {@link ProfileService}
- * @throws NamingException
- * , Exception
- */
- public static ProfileService getProfileService() throws NamingException {
- InitialContext ic = new InitialContext();
- ProfileService ps = (ProfileService) ic
- .lookup(PluginConstants.PROFILE_SERVICE);
- return ps;
- }
-
- /**
* @return {@link File}
* @throws NamingException
* , Exception
*/
- public static File getDeployDirectory() throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, false);
+ public static File getDeployDirectory(ProfileServiceConnection connection)
+ throws NamingException, Exception {
Set<ManagedDeployment> warDeployments;
try {
- warDeployments = mv
- .getDeploymentsForType(KnownDeploymentTypes.JavaEEWebApplication
- .getType());
+ warDeployments = connection
+ .getManagementView()
+ .getDeploymentsForType(
+ KnownDeploymentTypes.JavaEEWebApplication.getType());
} catch (Exception e) {
throw new IllegalStateException(e);
}
@@ -261,12 +281,6 @@
return deployDir;
}
- public static ManagedComponent getDQPManagementView()
- throws NamingException, Exception {
-
- return getManagedComponent(DQPTYPE, DQPNAME);
- }
-
public static String stringValue(MetaValue v1) throws Exception {
if (v1 != null) {
MetaType type = v1.getMetaType();
@@ -274,7 +288,7 @@
SimpleValue simple = (SimpleValue) v1;
return simple.getValue().toString();
}
- throw new Exception("Failed to convert value to string value");
+ throw new Exception("Failed to convert value to string value"); //$NON-NLS-1$
}
return null;
}
@@ -286,7 +300,7 @@
SimpleValue simple = (SimpleValue) v1;
return Boolean.valueOf(simple.getValue().toString());
}
- throw new Exception("Failed to convert value to boolean value");
+ throw new Exception("Failed to convert value to boolean value"); //$NON-NLS-1$
}
return null;
}
@@ -305,41 +319,43 @@
return expectedType.cast((enumValue != null) ? enumValue
.getValue() : null);
}
- throw new IllegalStateException(prop + " is not a simple type");
+ throw new IllegalStateException(prop + " is not a simple type"); //$NON-NLS-1$
}
return null;
}
-
- public static <T> T getSimpleValue(ManagedCommon mc, String prop, Class<T> expectedType) {
- ManagedProperty mp = mc.getProperty(prop);
- if (mp != null) {
- MetaType metaType = mp.getMetaType();
- if (metaType.isSimple()) {
- SimpleValue simpleValue = (SimpleValue)mp.getValue();
- return expectedType.cast((simpleValue != null) ? simpleValue.getValue() : null);
- }
- else if (metaType.isEnum()) {
- EnumValue enumValue = (EnumValue)mp.getValue();
- return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
- }
- throw new IllegalArgumentException(prop+ " is not a simple type"); //$NON-NLS-1$
- }
- return null;
- }
+ public static <T> T getSimpleValue(ManagedCommon mc, String prop,
+ Class<T> expectedType) {
+ ManagedProperty mp = mc.getProperty(prop);
+ if (mp != null) {
+ MetaType metaType = mp.getMetaType();
+ if (metaType.isSimple()) {
+ SimpleValue simpleValue = (SimpleValue) mp.getValue();
+ return expectedType.cast((simpleValue != null) ? simpleValue
+ .getValue() : null);
+ } else if (metaType.isEnum()) {
+ EnumValue enumValue = (EnumValue) mp.getValue();
+ return expectedType.cast((enumValue != null) ? enumValue
+ .getValue() : null);
+ }
+ throw new IllegalArgumentException(prop + " is not a simple type"); //$NON-NLS-1$
+ }
+ return null;
+ }
+
public static Map<String, PropertySimple> getCustomProperties(
Configuration pluginConfig) {
Map<String, PropertySimple> customProperties = new LinkedHashMap<String, PropertySimple>();
if (pluginConfig == null)
return customProperties;
- PropertyMap customPropsMap = pluginConfig.getMap("custom-properties");
+ PropertyMap customPropsMap = pluginConfig.getMap("custom-properties"); //$NON-NLS-1$
if (customPropsMap != null) {
Collection<Property> customProps = customPropsMap.getMap().values();
for (Property customProp : customProps) {
if (!(customProp instanceof PropertySimple)) {
LOG
- .error("Custom property definitions in plugin configuration must be simple properties - property "
- + customProp + " is not - ignoring...");
+ .error("Custom property definitions in plugin configuration must be simple properties - property " //$NON-NLS-1$
+ + customProp + " is not - ignoring..."); //$NON-NLS-1$
continue;
}
customProperties.put(customProp.getName(),
@@ -365,14 +381,14 @@
if (!managedProperty.hasViewUse(ViewUse.STATISTIC))
LOG
.debug(resourceType
- + " does not define a property corresponding to ManagedProperty '"
- + propName + "'.");
+ + " does not define a property corresponding to ManagedProperty '" //$NON-NLS-1$
+ + propName + "'."); //$NON-NLS-1$
continue;
}
if (managedProperty == null) {
// This should never happen, but don't let it blow us up.
- LOG.error("ManagedProperty '" + propName
- + "' has a null value in the ManagedProperties Map.");
+ LOG.error("ManagedProperty '" + propName //$NON-NLS-1$
+ + "' has a null value in the ManagedProperties Map."); //$NON-NLS-1$
continue;
}
MetaValue metaValue = managedProperty.getValue();
@@ -390,12 +406,12 @@
.getPropertyAdapter(metaValue);
if (propertyAdapter == null) {
LOG
- .error("Unable to find a PropertyAdapter for ManagedProperty '"
+ .error("Unable to find a PropertyAdapter for ManagedProperty '" //$NON-NLS-1$
+ propName
- + "' with MetaType ["
+ + "' with MetaType [" //$NON-NLS-1$
+ metaValue.getMetaType()
- + "] for ResourceType '"
- + resourceType.getName() + "'.");
+ + "] for ResourceType '" //$NON-NLS-1$
+ + resourceType.getName() + "'."); //$NON-NLS-1$
continue;
}
Property property = propertyAdapter.convertToProperty(metaValue,
@@ -414,19 +430,20 @@
String propertyName = managedProperty.getName();
PropertyDefinition propertyDefinition = configDefinition
.get(propertyName);
- if (propertyDefinition==null){
- //The managed property is not defined in the configuration
+ if (propertyDefinition == null) {
+ // The managed property is not defined in the configuration
continue;
}
populateManagedPropertyFromProperty(managedProperty,
- propertyDefinition, configuration);
- }
+ propertyDefinition, configuration);
+ }
return;
}
- public static void populateManagedPropertyFromProperty(ManagedProperty managedProperty,
+ public static void populateManagedPropertyFromProperty(
+ ManagedProperty managedProperty,
PropertyDefinition propertyDefinition, Configuration configuration) {
- // If the ManagedProperty defines a default value, assume it's more
+ // If the ManagedProperty defines a default value, assume it's more
// definitive than any default value that may
// have been defined in the plugin descriptor, and update the
// PropertyDefinition to use that as its default
@@ -438,29 +455,31 @@
MetaValue metaValue = managedProperty.getValue();
PropertyAdapter propertyAdapter = null;
if (metaValue != null) {
- LOG.trace("Populating existing MetaValue of type "
- + metaValue.getMetaType() + " from Teiid property "
- + propertyDefinition.getName() + " with definition " + propertyDefinition
- + "...");
+ LOG.trace("Populating existing MetaValue of type " //$NON-NLS-1$
+ + metaValue.getMetaType() + " from Teiid property " //$NON-NLS-1$
+ + propertyDefinition.getName() + " with definition " //$NON-NLS-1$
+ + propertyDefinition + "..."); //$NON-NLS-1$
propertyAdapter = PropertyAdapterFactory
- .getPropertyAdapter(metaValue);
-
- propertyAdapter.populateMetaValueFromProperty(configuration.getSimple(propertyDefinition.getName()), metaValue,
- propertyDefinition);
+ .getPropertyAdapter(metaValue);
+
+ propertyAdapter.populateMetaValueFromProperty(configuration
+ .getSimple(propertyDefinition.getName()), metaValue,
+ propertyDefinition);
managedProperty.setValue(metaValue);
} else {
- MetaType metaType = managedProperty.getMetaType();
+ MetaType metaType = managedProperty.getMetaType();
if (propertyAdapter == null)
propertyAdapter = PropertyAdapterFactory
.getPropertyAdapter(metaType);
- LOG.trace("Converting property " + propertyDefinition.getName() + " with definition "
- + propertyDefinition + " to MetaValue of type " + metaType
- + "...");
- metaValue = propertyAdapter.convertToMetaValue(configuration.getSimple(propertyDefinition.getName()),
- propertyDefinition, metaType);
+ LOG.trace("Converting property " + propertyDefinition.getName() //$NON-NLS-1$
+ + " with definition " + propertyDefinition //$NON-NLS-1$
+ + " to MetaValue of type " + metaType + "..."); //$NON-NLS-1$ //$NON-NLS-2$
+ metaValue = propertyAdapter.convertToMetaValue(configuration
+ .getSimple(propertyDefinition.getName()),
+ propertyDefinition, metaType);
managedProperty.setValue(metaValue);
}
-
+
}
private static void updateDefaultValueOnPropertyDefinition(
@@ -468,17 +487,16 @@
@NotNull MetaValue defaultValue) {
if (!(propertyDefinition instanceof PropertyDefinitionSimple)) {
LOG
- .debug("Cannot update default value on non-simple property definition "
- + propertyDefinition
- + "(default value is "
- + defaultValue + ").");
+ .debug("Cannot update default value on non-simple property definition " //$NON-NLS-1$
+ + propertyDefinition + "(default value is " //$NON-NLS-1$
+ + defaultValue + ")."); //$NON-NLS-1$
return;
}
MetaType metaType = defaultValue.getMetaType();
if (!metaType.isSimple() && !metaType.isEnum()) {
- LOG.debug("Cannot update default value on " + propertyDefinition
- + ", because default value's type (" + metaType
- + ") is not simple or enum.");
+ LOG.debug("Cannot update default value on " + propertyDefinition //$NON-NLS-1$
+ + ", because default value's type (" + metaType //$NON-NLS-1$
+ + ") is not simple or enum."); //$NON-NLS-1$
return;
}
PropertyDefinitionSimple propertyDefinitionSimple = (PropertyDefinitionSimple) propertyDefinition;
@@ -525,88 +543,91 @@
}
return memberMetaType;
}
-
- private static MetaType convertPropertySimpleTypeToSimpleMetaType(PropertySimpleType memberSimpleType)
- {
- MetaType memberMetaType;
- Class memberClass;
- switch (memberSimpleType)
- {
- case BOOLEAN:
- memberClass = Boolean.class;
- break;
- case INTEGER:
- memberClass = Integer.class;
- break;
- case LONG:
- memberClass = Long.class;
- break;
- case FLOAT:
- memberClass = Float.class;
- break;
- case DOUBLE:
- memberClass = Double.class;
- break;
- default:
- memberClass = String.class;
- break;
- }
- memberMetaType = SimpleMetaType.resolve(memberClass.getName());
- return memberMetaType;
- }
-
- public static SimpleValue wrap(MetaType type, String value) throws Exception {
- if (type instanceof SimpleMetaType) {
- SimpleMetaType st = (SimpleMetaType)type;
-
- if (SimpleMetaType.BIGDECIMAL.equals(st)) {
- return new SimpleValueSupport(st, new BigDecimal(value));
- } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
- return new SimpleValueSupport(st, new BigInteger(value));
- } else if (SimpleMetaType.BOOLEAN.equals(st)) {
- return new SimpleValueSupport(st, Boolean.valueOf(value));
- } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Boolean.valueOf(value).booleanValue());
- } else if (SimpleMetaType.BYTE.equals(st)) {
- return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
- } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, value.getBytes()[0]);
- } else if (SimpleMetaType.CHARACTER.equals(st)) {
- return new SimpleValueSupport(st, new Character(value.charAt(0)));
- } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st,value.charAt(0));
- } else if (SimpleMetaType.DATE.equals(st)) {
- try {
- return new SimpleValueSupport(st, SimpleDateFormat.getInstance().parse(value));
- } catch (ParseException e) {
- throw new Exception("Failed to convert value to SimpleValue", e); //$NON-NLS-1$
- }
- } else if (SimpleMetaType.DOUBLE.equals(st)) {
- return new SimpleValueSupport(st, Double.valueOf(value));
- } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Double.parseDouble(value));
- } else if (SimpleMetaType.FLOAT.equals(st)) {
- return new SimpleValueSupport(st, Float.parseFloat(value));
- } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Float.valueOf(value));
- } else if (SimpleMetaType.INTEGER.equals(st)) {
- return new SimpleValueSupport(st, Integer.valueOf(value));
- } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Integer.parseInt(value));
- } else if (SimpleMetaType.LONG.equals(st)) {
- return new SimpleValueSupport(st, Long.valueOf(value));
- } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Long.parseLong(value));
- } else if (SimpleMetaType.SHORT.equals(st)) {
- return new SimpleValueSupport(st, Short.valueOf(value));
- } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Short.parseShort(value));
- } else if (SimpleMetaType.STRING.equals(st)) {
- return new SimpleValueSupport(st,value);
+
+ private static MetaType convertPropertySimpleTypeToSimpleMetaType(
+ PropertySimpleType memberSimpleType) {
+ MetaType memberMetaType;
+ Class memberClass;
+ switch (memberSimpleType) {
+ case BOOLEAN:
+ memberClass = Boolean.class;
+ break;
+ case INTEGER:
+ memberClass = Integer.class;
+ break;
+ case LONG:
+ memberClass = Long.class;
+ break;
+ case FLOAT:
+ memberClass = Float.class;
+ break;
+ case DOUBLE:
+ memberClass = Double.class;
+ break;
+ default:
+ memberClass = String.class;
+ break;
+ }
+ memberMetaType = SimpleMetaType.resolve(memberClass.getName());
+ return memberMetaType;
+ }
+
+ public static SimpleValue wrap(MetaType type, String value)
+ throws Exception {
+ if (type instanceof SimpleMetaType) {
+ SimpleMetaType st = (SimpleMetaType) type;
+
+ if (SimpleMetaType.BIGDECIMAL.equals(st)) {
+ return new SimpleValueSupport(st, new BigDecimal(value));
+ } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
+ return new SimpleValueSupport(st, new BigInteger(value));
+ } else if (SimpleMetaType.BOOLEAN.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value));
+ } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value)
+ .booleanValue());
+ } else if (SimpleMetaType.BYTE.equals(st)) {
+ return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
+ } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, value.getBytes()[0]);
+ } else if (SimpleMetaType.CHARACTER.equals(st)) {
+ return new SimpleValueSupport(st,
+ new Character(value.charAt(0)));
+ } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, value.charAt(0));
+ } else if (SimpleMetaType.DATE.equals(st)) {
+ try {
+ return new SimpleValueSupport(st, SimpleDateFormat
+ .getInstance().parse(value));
+ } catch (ParseException e) {
+ throw new Exception(
+ "Failed to convert value to SimpleValue", e); //$NON-NLS-1$
}
+ } else if (SimpleMetaType.DOUBLE.equals(st)) {
+ return new SimpleValueSupport(st, Double.valueOf(value));
+ } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Double.parseDouble(value));
+ } else if (SimpleMetaType.FLOAT.equals(st)) {
+ return new SimpleValueSupport(st, Float.parseFloat(value));
+ } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Float.valueOf(value));
+ } else if (SimpleMetaType.INTEGER.equals(st)) {
+ return new SimpleValueSupport(st, Integer.valueOf(value));
+ } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Integer.parseInt(value));
+ } else if (SimpleMetaType.LONG.equals(st)) {
+ return new SimpleValueSupport(st, Long.valueOf(value));
+ } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Long.parseLong(value));
+ } else if (SimpleMetaType.SHORT.equals(st)) {
+ return new SimpleValueSupport(st, Short.valueOf(value));
+ } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Short.parseShort(value));
+ } else if (SimpleMetaType.STRING.equals(st)) {
+ return new SimpleValueSupport(st, value);
}
- throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
- }
+ }
+ throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
+ }
-
}
14 years, 5 months
teiid SVN: r2380 - trunk/runtime/src/main/java/org/teiid/services.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-07-27 13:38:29 -0400 (Tue, 27 Jul 2010)
New Revision: 2380
Modified:
trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
Log:
TEIID-1169: adding a fixed management name as these are singletons
Modified: trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2010-07-27 17:15:15 UTC (rev 2379)
+++ trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2010-07-27 17:38:29 UTC (rev 2380)
@@ -30,7 +30,6 @@
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
-import org.teiid.cache.CacheFactory;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.impl.BufferManagerImpl;
import org.teiid.common.buffer.impl.FileStorageManager;
@@ -48,7 +47,7 @@
* a mixed disk/memory model which requires use of a directory on the disk
* for file service access.
*/
-@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
+@ManagementObject(name="BufferService", componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
public class BufferServiceImpl implements BufferService, Serializable {
private static final long serialVersionUID = -6217808623863643531L;
private static final long MB = 1<<20;
@@ -59,7 +58,6 @@
private boolean useDisk = true;
private int processorBatchSize = BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE;
private int connectorBatchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
- private CacheFactory cacheFactory;
private int maxOpenFiles = FileStorageManager.DEFAULT_MAX_OPEN_FILES;
private long maxFileSize = FileStorageManager.DEFAULT_MAX_FILESIZE; // 2GB
private int maxProcessingBatchesColumns = BufferManager.DEFAULT_MAX_PROCESSING_BATCHES;
@@ -163,10 +161,6 @@
return this.connectorBatchSize;
}
- public void setCacheFactory(CacheFactory cf) {
- this.cacheFactory = cf;
- }
-
public void setMaxFileSize(long maxFileSize) {
this.maxFileSize = maxFileSize;
}
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-07-27 17:15:15 UTC (rev 2379)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-07-27 17:38:29 UTC (rev 2380)
@@ -62,7 +62,7 @@
/**
* This class serves as the primary implementation of the Session Service.
*/
-@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
+@ManagementObject(name="SessionService", componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
public class SessionServiceImpl implements SessionService {
public static final String SECURITY_DOMAINS = "securitydomains"; //$NON-NLS-1$
14 years, 5 months
teiid SVN: r2379 - in trunk/engine/src: main/java/org/teiid/dqp/internal/process and 10 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-27 13:15:15 -0400 (Tue, 27 Jul 2010)
New Revision: 2379
Added:
trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java
Modified:
trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java
trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-1167 adding support for ordering by the index. also updating the alias generation logic to support stripping aliases for sources that don't support expression projection.
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -72,8 +72,6 @@
}
}
- static int unnecessaryReads;
-
static SearchResult search(SPage page, List k, LinkedList<SearchResult> parent) throws TeiidComponentException {
TupleBatch previousValues = null;
for (;;) {
@@ -81,7 +79,6 @@
int index = Collections.binarySearch(values.getTuples(), k, page.stree.comparator);
int flippedIndex = - index - 1;
if (previousValues != null) {
- unnecessaryReads++;
if (flippedIndex == 0) {
//systemic weakness of the algorithm
return new SearchResult(-previousValues.getTuples().size() - 1, page.prev, previousValues);
@@ -207,7 +204,7 @@
result.append(tb.getBeginRow());
if (children == null) {
if (tb.getTuples().size() <= 1) {
- result.append(values);
+ result.append(tb.getTuples());
} else {
result.append("[").append(tb.getTuples().get(0)).append(" . ").append(tb.getTuples().size()). //$NON-NLS-1$ //$NON-NLS-2$
append(" . ").append(tb.getTuples().get(tb.getTuples().size() - 1)).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -65,7 +65,6 @@
int keyLength,
String[] types) {
randomSeed = seedGenerator.nextInt() | 0x00000100; // ensure nonzero
- //randomSeed=-1031212234;
this.manager = recman;
this.comparator = comparator;
this.pageSize = Math.max(pageSize, SPage.MIN_PERSISTENT_SIZE);
@@ -115,13 +114,11 @@
*/
private List find(List n, LinkedList<SearchResult> places) throws TeiidComponentException {
SPage x = null;
- SearchResult parent = null;
for (int i = header.length - 1; i >= 0; i--) {
if (x == null) {
x = header[i];
}
SearchResult s = SPage.search(x, n, places);
- parent = s;
if (places != null) {
places.add(s);
}
@@ -209,6 +206,9 @@
}
nextPage.next = page.next;
nextPage.prev = page;
+ if (nextPage.next != null) {
+ nextPage.next.prev = nextPage;
+ }
page.next = nextPage;
boolean inNext = false;
if (index <= pageSize/2) {
@@ -314,7 +314,7 @@
}
public TupleBrowser browse(List lowerBound, List upperBound, boolean direction) {
- return new TupleBrowser();
+ return new TupleBrowser(direction);
}
public int truncate() {
@@ -337,7 +337,17 @@
int index;
TupleBatch values;
boolean updated;
+ boolean direction;
+ public TupleBrowser(boolean direction) {
+ this.direction = direction;
+ if (!direction) {
+ while (page.prev != null) {
+ page = page.prev;
+ }
+ }
+ }
+
public boolean matchedLower() {
return false;
}
@@ -350,23 +360,37 @@
for (;;) {
if (values == null) {
values = page.getValues();
+ if (direction) {
+ index = 0;
+ } else {
+ index = values.getTuples().size() - 1;
+ }
}
- if (index < values.getTuples().size()) {
- return values.getTuples().get(index++);
+ if (index >= 0 && index < values.getTuples().size()) {
+ List result = values.getTuples().get(index);
+ index+=getOffset();
+ return result;
}
if (updated) {
page.setValues(values);
}
+ updated = false;
values = null;
- index = 0;
- page = page.next;
- updated = false;
+ if (direction) {
+ page = page.next;
+ } else {
+ page = page.prev;
+ }
if (page == null) {
return null;
}
}
}
+ private int getOffset() {
+ return direction?1:-1;
+ }
+
/**
* Perform an in-place update of the tuple just returned by the next method
* WARNING - this must not change the key value
@@ -374,7 +398,7 @@
* @throws TeiidComponentException
*/
public void update(List tuple) throws TeiidComponentException {
- values.getTuples().set(index - 1, tuple);
+ values.getTuples().set(index - getOffset(), tuple);
updated = true;
}
@@ -382,7 +406,7 @@
* Notify the browser that the last value was deleted.
*/
public void removed() {
- index--;
+ index-=getOffset();
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -59,6 +59,7 @@
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.eval.SecurityFunctionEvaluator;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempCapabilitiesFinder;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.optimizer.QueryOptimizer;
@@ -172,7 +173,7 @@
}
// Prepare dependencies for running the optimizer
this.capabilitiesFinder = new CachedFinder(this.connectorManagerRepo, workContext.getVDB());
-
+ this.capabilitiesFinder = new TempCapabilitiesFinder(this.capabilitiesFinder);
metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
Added: trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.metadata;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+
+public class TempCapabilitiesFinder implements CapabilitiesFinder {
+
+ private static BasicSourceCapabilities tempCaps;
+ private final CapabilitiesFinder delegate;
+
+ public TempCapabilitiesFinder(CapabilitiesFinder delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public SourceCapabilities findCapabilities(String modelName)
+ throws TeiidComponentException {
+ if (TempMetadataAdapter.TEMP_MODEL.getID().equals(modelName)) {
+ if (tempCaps == null) {
+ tempCaps = new BasicSourceCapabilities();
+ tempCaps.setCapabilitySupport(Capability.BULK_UPDATE, true);
+ tempCaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ }
+ return tempCaps;
+ }
+ return delegate.findCapabilities(modelName);
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/query/metadata/TempCapabilitiesFinder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -53,7 +53,7 @@
public class TempMetadataAdapter extends BasicQueryMetadataWrapper {
private static final String SEPARATOR = "."; //$NON-NLS-1$
- private static final TempMetadataID TEMP_MODEL = new TempMetadataID("__TEMP__", Collections.EMPTY_LIST); //$NON-NLS-1$
+ public static final TempMetadataID TEMP_MODEL = new TempMetadataID("__TEMP__", Collections.EMPTY_LIST); //$NON-NLS-1$
private TempMetadataStore tempStore;
private Map materializationTables;
@@ -322,7 +322,7 @@
throws TeiidComponentException, QueryMetadataException {
if(modelID.equals(TEMP_MODEL)) {
- return true;
+ return false;
}
return this.actualMetadata.isVirtualModel(modelID);
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -168,7 +168,7 @@
return true;
}
- if(obj == null || !(obj instanceof TempMetadataID)) {
+ if(!(obj instanceof TempMetadataID)) {
return false;
}
return this.getID().equals( ((TempMetadataID) obj).getID());
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -33,6 +33,7 @@
import org.teiid.core.id.IntegerIDFactory;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempCapabilitiesFinder;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.optimizer.batch.BatchedUpdatePlanner;
@@ -76,6 +77,10 @@
context = new CommandContext();
}
+ if (!(capFinder instanceof TempCapabilitiesFinder)) {
+ capFinder = new TempCapabilitiesFinder(capFinder);
+ }
+
boolean debug = analysisRecord.recordDebug();
Map tempMetadata = command.getTemporaryMetadata();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -186,12 +186,18 @@
}
private NamingVisitor visitor;
- private int groupIndex = 0;
- private int viewIndex = 0;
+ private int groupIndex;
+ private int viewIndex;
+ private boolean stripColumnAliases;
public AliasGenerator(boolean aliasGroups) {
+ this(aliasGroups, false);
+ }
+
+ public AliasGenerator(boolean aliasGroups, boolean stripColumnAliases) {
super(new NamingVisitor(aliasGroups));
this.visitor = (NamingVisitor)this.getVisitor();
+ this.stripColumnAliases = stripColumnAliases;
}
/**
@@ -209,15 +215,16 @@
}
public void visit(Select obj) {
+ super.visit(obj);
List selectSymbols = obj.getSymbols();
HashMap<SingleElementSymbol, String> symbols = new HashMap<SingleElementSymbol, String>(selectSymbols.size());
for (int i = 0; i < selectSymbols.size(); i++) {
SingleElementSymbol symbol = (SingleElementSymbol)selectSymbols.get(i);
+
+ boolean needsAlias = visitor.namingContext.aliasColumns;
String newAlias = "c_" + i; //$NON-NLS-1$
- boolean needsAlias = true;
-
Expression expr = SymbolMap.getExpression(symbol);
SingleElementSymbol newSymbol = symbol;
@@ -225,11 +232,12 @@
if (!(expr instanceof SingleElementSymbol)) {
newSymbol = new ExpressionSymbol(newSymbol.getShortName(), expr);
} else if (expr instanceof ElementSymbol) {
- if (!needsAlias(newAlias, (ElementSymbol)expr)) {
- needsAlias = false;
- ((ElementSymbol)expr).setOutputName(newAlias);
+ newSymbol = (ElementSymbol)expr;
+ if (!needsAlias) {
+ newAlias = newSymbol.getOutputName();
+ } else {
+ needsAlias &= needsAlias(newAlias, (ElementSymbol)expr);
}
- newSymbol = (ElementSymbol)expr;
} else {
newSymbol = (SingleElementSymbol)expr;
}
@@ -242,7 +250,6 @@
selectSymbols.set(i, newSymbol);
}
- super.visit(obj);
visitor.namingContext.currentSymbols = symbols;
}
@@ -256,7 +263,7 @@
*/
public void visit(Query obj) {
if (obj.getOrderBy() != null || obj.getLimit() != null) {
- visitor.namingContext.aliasColumns = true;
+ visitor.namingContext.aliasColumns = true && !stripColumnAliases;
}
visitNode(obj.getFrom());
visitNode(obj.getCriteria());
@@ -337,15 +344,15 @@
continue;
}
String name = visitor.namingContext.getElementName(element, false);
+ boolean needsAlias = visitor.namingContext.aliasColumns;
if (name != null) {
- boolean needsAlias = true;
Expression expr = SymbolMap.getExpression(element);
if (!(expr instanceof SingleElementSymbol)) {
expr = new ExpressionSymbol(element.getShortName(), expr);
} else if (expr instanceof ElementSymbol) {
- needsAlias = needsAlias(name, (ElementSymbol)expr);
+ needsAlias &= needsAlias(name, (ElementSymbol)expr);
}
if (needsAlias) {
@@ -355,11 +362,9 @@
element.setOutputName(name);
}
- visitNode(element);
-
- if (name != null && element instanceof ElementSymbol) {
- element.setOutputName(SingleElementSymbol.getShortName(element.getOutputName()));
- }
+ if (!(element instanceof ElementSymbol)) {
+ visitNode(element);
+ }
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -309,7 +309,7 @@
//-- special handling for temp tables. currently they cannot perform projection
try {
if (command instanceof Query) {
- processNode = correctProjectionInternalTables(node, aNode, (Query)command);
+ processNode = correctProjectionInternalTables(node, aNode);
}
} catch (QueryMetadataException err) {
throw new TeiidComponentException(err);
@@ -319,7 +319,9 @@
try {
command = (Command)command.clone();
- command.acceptVisitor(new AliasGenerator(modelID != null && CapabilitiesUtil.supportsGroupAliases(modelID, metadata, capFinder)));
+ boolean aliasGroups = modelID != null && CapabilitiesUtil.supportsGroupAliases(modelID, metadata, capFinder);
+ boolean aliasColumns = modelID != null && CapabilitiesUtil.supports(Capability.QUERY_SELECT_EXPRESSION, modelID, metadata, capFinder);
+ command.acceptVisitor(new AliasGenerator(aliasGroups, !aliasColumns));
} catch (QueryMetadataException err) {
throw new TeiidComponentException(err);
}
@@ -461,7 +463,7 @@
}
private RelationalNode correctProjectionInternalTables(PlanNode node,
- AccessNode aNode, Query query) throws QueryMetadataException,
+ AccessNode aNode) throws QueryMetadataException,
TeiidComponentException {
if (node.getGroups().size() != 1) {
return aNode;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -435,15 +435,17 @@
* @return
*/
static ProcessorPlan getNestedPlan(PlanNode accessNode) {
- ProcessorPlan plan = null;
PlanNode sourceNode = accessNode.getFirstChild();
+ if (sourceNode == null) {
+ return null;
+ }
if(sourceNode.getType() != NodeConstants.Types.SOURCE) {
sourceNode = sourceNode.getFirstChild();
}
- if(sourceNode.getType() == NodeConstants.Types.SOURCE) {
- plan = (ProcessorPlan) sourceNode.getProperty(NodeConstants.Info.PROCESSOR_PLAN);
+ if(sourceNode != null && sourceNode.getType() == NodeConstants.Types.SOURCE) {
+ return (ProcessorPlan) sourceNode.getProperty(NodeConstants.Info.PROCESSOR_PLAN);
}
- return plan;
+ return null;
}
/**
@@ -454,23 +456,19 @@
* @return The actual stored procedure
*/
static Command getNonQueryCommand(PlanNode node) {
- if (node.getChildCount() == 0) {
- return null;
- }
PlanNode sourceNode = node.getFirstChild();
+ if (sourceNode == null) {
+ return null;
+ }
if(sourceNode.getType() != NodeConstants.Types.SOURCE) {
- if (sourceNode.getChildCount() == 0) {
- return null;
- }
sourceNode = sourceNode.getFirstChild();
}
- if(sourceNode.getType() == NodeConstants.Types.SOURCE) {
+ if(sourceNode != null && sourceNode.getType() == NodeConstants.Types.SOURCE) {
Command command = (Command) sourceNode.getProperty(NodeConstants.Info.VIRTUAL_COMMAND);
if(! (command instanceof QueryCommand)) {
return command;
}
}
-
return null;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.List;
import org.teiid.api.exception.query.QueryMetadataException;
@@ -56,6 +57,7 @@
import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.Limit;
import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.Select;
@@ -417,7 +419,15 @@
}
private void processOrderBy(PlanNode node, QueryCommand query) {
- query.setOrderBy((OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER));
+ OrderBy orderBy = (OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER);
+ query.setOrderBy(orderBy);
+ if (query instanceof Query) {
+ List<SingleElementSymbol> cols = query.getProjectedSymbols();
+ for (OrderByItem item : orderBy.getOrderByItems()) {
+ item.setExpressionPosition(cols.indexOf(item.getSymbol()));
+ }
+ QueryRewriter.rewriteOrderBy(query, orderBy, query.getProjectedSymbols(), new LinkedList<OrderByItem>());
+ }
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -121,6 +121,16 @@
return null;
}
}
+
+ /*
+ * TODO: this creates an extraneous project node in many circumstances.
+ * However we don't actually support project in this case, so allowing it to be pushed
+ * causes problems with stored procedures and the assumptions made for proc/relational
+ * planning.
+ */
+ if (FrameUtil.isProcedure(parentNode)) {
+ return null;
+ }
return performRaise(rootNode, accessNode, parentNode);
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -84,7 +84,7 @@
* order.
*/
public ListNestedSortComparator( int[] sortParameters ) {
- this( sortParameters, false );
+ this( sortParameters, true );
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -44,6 +44,7 @@
import org.teiid.query.processor.QueryProcessor;
import org.teiid.query.processor.BatchCollector.BatchProducer;
import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.util.CommandContext;
@@ -344,11 +345,11 @@
/**
* Helper method for all the node that will filter the elements needed for the next node.
*/
- public static int[] getProjectionIndexes(Map<SingleElementSymbol, Integer> tupleElements, List<SingleElementSymbol> projectElements) {
+ public static int[] getProjectionIndexes(Map<SingleElementSymbol, Integer> tupleElements, List<? extends Expression> projectElements) {
int[] result = new int[projectElements.size()];
int i = 0;
- for (SingleElementSymbol symbol : projectElements) {
+ for (Expression symbol : projectElements) {
Integer index = tupleElements.get(symbol);
Assertion.isNotNull(index);
result[i++] = index;
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -790,34 +790,13 @@
}
Select select = queryCommand.getProjectedQuery().getSelect();
final List projectedSymbols = select.getProjectedSymbols();
- HashSet<Expression> previousExpressions = new HashSet<Expression>();
- boolean hasUnrelatedExpression = false;
-
LinkedList<OrderByItem> unrelatedItems = new LinkedList<OrderByItem>();
- for (int i = 0; i < orderBy.getVariableCount(); i++) {
- SingleElementSymbol querySymbol = orderBy.getVariable(i);
- int index = orderBy.getExpressionPosition(i);
- if (index == -1) {
- unrelatedItems.add(orderBy.getOrderByItems().get(i));
- hasUnrelatedExpression |= (querySymbol instanceof ExpressionSymbol);
- continue; // must be unrelated
- }
- querySymbol = (SingleElementSymbol)projectedSymbols.get(index);
- Expression expr = SymbolMap.getExpression(querySymbol);
- if (!previousExpressions.add(expr) || (queryCommand instanceof Query && EvaluatableVisitor.isFullyEvaluatable(expr, true))) {
- orderBy.removeOrderByItem(i--);
- } else {
- orderBy.getOrderByItems().get(i).setSymbol((SingleElementSymbol)querySymbol.clone());
- }
- }
- if (orderBy.getVariableCount() == 0) {
- queryCommand.setOrderBy(null);
- return queryCommand;
- }
+ boolean hasUnrelatedExpression = rewriteOrderBy(queryCommand, orderBy,
+ projectedSymbols, unrelatedItems);
- if (!hasUnrelatedExpression) {
+ if (orderBy.getVariableCount() == 0 || !hasUnrelatedExpression) {
return queryCommand;
}
@@ -860,6 +839,33 @@
top.setOrderBy(orderBy);
return top;
}
+
+ public static boolean rewriteOrderBy(QueryCommand queryCommand,
+ final OrderBy orderBy, final List projectedSymbols,
+ LinkedList<OrderByItem> unrelatedItems) {
+ boolean hasUnrelatedExpression = false;
+ HashSet<Expression> previousExpressions = new HashSet<Expression>();
+ for (int i = 0; i < orderBy.getVariableCount(); i++) {
+ SingleElementSymbol querySymbol = orderBy.getVariable(i);
+ int index = orderBy.getExpressionPosition(i);
+ if (index == -1) {
+ unrelatedItems.add(orderBy.getOrderByItems().get(i));
+ hasUnrelatedExpression |= (querySymbol instanceof ExpressionSymbol);
+ continue; // must be unrelated
+ }
+ querySymbol = (SingleElementSymbol)projectedSymbols.get(index);
+ Expression expr = SymbolMap.getExpression(querySymbol);
+ if (!previousExpressions.add(expr) || (queryCommand instanceof Query && EvaluatableVisitor.isFullyEvaluatable(expr, true))) {
+ orderBy.removeOrderByItem(i--);
+ } else {
+ orderBy.getOrderByItems().get(i).setSymbol((SingleElementSymbol)querySymbol.clone());
+ }
+ }
+ if (orderBy.getVariableCount() == 0) {
+ queryCommand.setOrderBy(null);
+ }
+ return hasUnrelatedExpression;
+ }
/**
* This method will alias each of the select into elements to the corresponding column name in the
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -46,10 +46,14 @@
import org.teiid.query.eval.Evaluator;
import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.SortUtility;
+import org.teiid.query.processor.relational.SortUtility.Mode;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.SetClauseList;
+import org.teiid.query.sql.symbol.AliasSymbol;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.SingleElementSymbol;
@@ -61,6 +65,35 @@
*/
class TempTable {
+ private class TupleBrowserTupleSource implements TupleSource {
+ private final TupleBrowser browser;
+
+ private TupleBrowserTupleSource(TupleBrowser browser) {
+ this.browser = browser;
+ }
+
+ @Override
+ public List<?> nextTuple() throws TeiidComponentException,
+ TeiidProcessingException {
+ return browser.next();
+ }
+
+ @Override
+ public List<? extends Expression> getSchema() {
+ return columns;
+ }
+
+ @Override
+ public void closeSource() {
+
+ }
+
+ @Override
+ public int available() {
+ return 0;
+ }
+ }
+
private abstract class UpdateTupleSource implements TupleSource {
private TupleSource ts;
protected final Map lookup;
@@ -154,8 +187,7 @@
ElementSymbol id = new ElementSymbol("rowId"); //$NON-NLS-1$
id.setType(DataTypeManager.DefaultDataClasses.INTEGER);
columns.add(0, id);
- //we start at max, since the default sort order is ascending
- rowId = new AtomicInteger(Integer.MAX_VALUE);
+ rowId = new AtomicInteger();
tree = bm.createSTree(columns, sessionID, TupleSourceType.PROCESSOR, 1);
} else {
tree = bm.createSTree(columns, sessionID, TupleSourceType.PROCESSOR, primaryKeyLength);
@@ -164,39 +196,113 @@
this.sessionID = sessionID;
}
- public TupleSource createTupleSource(List<SingleElementSymbol> projectedCols, List<Criteria> conditions, OrderBy orderBy) throws TeiidComponentException {
- TupleBrowser browser = createTupleBrower(conditions, orderBy);
- TupleBuffer tb = bm.createTupleBuffer(getColumns(), sessionID, TupleSourceType.PROCESSOR);
+ public TupleSource createTupleSource(List<SingleElementSymbol> cols, Criteria condition, OrderBy orderBy) throws TeiidComponentException, TeiidProcessingException {
Map map = RelationalNode.createLookupMap(getColumns());
- int[] indexes = RelationalNode.getProjectionIndexes(map, projectedCols);
- boolean project = false;
- if (indexes.length == getColumns().size()) {
- for (int i = 0; i < indexes.length; i++) {
- if (indexes[i] != i) {
- project = true;
- break;
+ Boolean direction = null;
+ boolean orderByUsingIndex = false;
+ if (orderBy != null && rowId == null) {
+ int[] orderByIndexes = RelationalNode.getProjectionIndexes(map, orderBy.getSortKeys());
+ if (orderByIndexes.length < tree.getKeyLength()) {
+ orderByUsingIndex = false;
+ } else {
+ orderByUsingIndex = true;
+ for (int i = 0; i < tree.getKeyLength(); i++) {
+ if (orderByIndexes[i] != i) {
+ orderByUsingIndex = false;
+ break;
+ }
}
+ if (orderByUsingIndex) {
+ for (int i = 0; i < tree.getKeyLength(); i++) {
+ OrderByItem item = orderBy.getOrderByItems().get(i);
+ if (item.getNullOrdering() != null) {
+ orderByUsingIndex = false;
+ break;
+ }
+ if (item.isAscending()) {
+ if (direction == null) {
+ direction = OrderBy.ASC;
+ } else if (direction != OrderBy.ASC) {
+ orderByUsingIndex = false;
+ break;
+ }
+ } else if (direction == null) {
+ direction = OrderBy.DESC;
+ } else if (direction != OrderBy.DESC) {
+ orderByUsingIndex = false;
+ break;
+ }
+ }
+ }
}
- } else {
- project = true;
}
- List next = null;
- while ((next = browser.next()) != null) {
- if (rowId != null) {
- next = next.subList(1, next.size());
+ if (!orderByUsingIndex) {
+ direction = OrderBy.ASC;
+ }
+ TupleBrowser browser = createTupleBrower(null, direction);
+
+ final int[] indexes = RelationalNode.getProjectionIndexes(map, cols);
+ final ArrayList<SingleElementSymbol> projectedCols = new ArrayList<SingleElementSymbol>(cols);
+ for (SingleElementSymbol singleElementSymbol : projectedCols) {
+ if (singleElementSymbol instanceof AliasSymbol) {
+
}
- if (project) {
- next = RelationalNode.projectTuple(indexes, next);
+ }
+ final boolean project = shouldProject(indexes);
+ TupleSource ts = new TupleBrowserTupleSource(browser) {
+
+ @Override
+ public List<?> nextTuple() throws TeiidComponentException,
+ TeiidProcessingException {
+ List<?> next = super.nextTuple();
+ if (next == null) {
+ return null;
+ }
+ if (rowId != null) {
+ next = next.subList(1, next.size());
+ }
+ if (project) {
+ next = RelationalNode.projectTuple(indexes, next);
+ }
+ return next;
}
- tb.addTuple(next);
+
+ @Override
+ public List<? extends Expression> getSchema() {
+ return projectedCols;
+ }
+ };
+
+ TupleBuffer tb = null;
+ if (!orderByUsingIndex && orderBy != null) {
+ SortUtility sort = new SortUtility(ts, orderBy.getOrderByItems(), Mode.SORT, bm, sessionID);
+ tb = sort.sort();
+ } else {
+ tb = bm.createTupleBuffer(getColumns(), sessionID, TupleSourceType.PROCESSOR);
+ List next = null;
+ while ((next = ts.nextTuple()) != null) {
+ tb.addTuple(next);
+ }
}
tb.close();
tb.setForwardOnly(true);
return tb.createIndexedTupleSource(true);
}
+
+ private boolean shouldProject(final int[] indexes) {
+ if (indexes.length == getColumns().size()) {
+ for (int i = 0; i < indexes.length; i++) {
+ if (indexes[i] != i) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
- private TupleBrowser createTupleBrower(List<Criteria> conditions, OrderBy orderBy) throws TeiidComponentException {
- return tree.browse(null, null, OrderBy.ASC);
+ private TupleBrowser createTupleBrower(List<Criteria> conditions, boolean direction) {
+ return tree.browse(null, null, direction);
}
public int getRowCount() {
@@ -224,7 +330,7 @@
protected void tuplePassed(List tuple)
throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (rowId != null) {
- tuple.add(0, rowId.getAndAdd(-1));
+ tuple.add(0, rowId.getAndAdd(1));
}
insertTuple(tuple);
}
@@ -238,36 +344,10 @@
return uts;
}
- private TupleSource asTupleSource(final TupleBrowser browser) {
- return new TupleSource() {
-
- @Override
- public List<?> nextTuple() throws TeiidComponentException,
- TeiidProcessingException {
- return browser.next();
- }
-
- @Override
- public List<? extends Expression> getSchema() {
- return columns;
- }
-
- @Override
- public void closeSource() {
-
- }
-
- @Override
- public int available() {
- return 0;
- }
- };
- }
-
public TupleSource update(Criteria crit, final SetClauseList update) throws TeiidComponentException {
final boolean primaryKeyChangePossible = canChangePrimaryKey(update);
- final TupleBrowser browser = createTupleBrower(null, null);
- UpdateTupleSource uts = new UpdateTupleSource(crit, asTupleSource(browser)) {
+ final TupleBrowser browser = createTupleBrower(null, OrderBy.ASC);
+ UpdateTupleSource uts = new UpdateTupleSource(crit, new TupleBrowserTupleSource(browser)) {
protected TupleBuffer changeSet;
protected TupleSource changeSetProcessor;
@@ -355,8 +435,8 @@
}
public TupleSource delete(Criteria crit) throws TeiidComponentException {
- final TupleBrowser browser = createTupleBrower(null, null);
- UpdateTupleSource uts = new UpdateTupleSource(crit, asTupleSource(browser)) {
+ final TupleBrowser browser = createTupleBrower(null, OrderBy.ASC);
+ UpdateTupleSource uts = new UpdateTupleSource(crit, new TupleBrowserTupleSource(browser)) {
@Override
protected void tuplePassed(List tuple)
throws ExpressionEvaluationException,
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -118,19 +118,24 @@
if (!group.isTempGroupSymbol()) {
return null;
}
- TempTable table = getTempTable(group.getNonCorrelationName().toUpperCase(), command);
+ final String tableName = group.getNonCorrelationName().toUpperCase();
+ TempTable table = getTempTable(tableName, command);
//convert to the actual table symbols (this is typically handled by the languagebridgefactory
ExpressionMappingVisitor emv = new ExpressionMappingVisitor(null) {
@Override
public Expression replaceExpression(Expression element) {
if (element instanceof ElementSymbol) {
- ((ElementSymbol) element).setName(((ElementSymbol) element).getOutputName());
+ ElementSymbol es = (ElementSymbol)element;
+ ((ElementSymbol) element).setName(tableName + ElementSymbol.SEPARATOR + es.getShortName());
}
return element;
}
};
PostOrderNavigator.doVisit(query.getSelect(), emv);
- return table.createTupleSource(command.getProjectedSymbols(), Criteria.separateCriteriaByAnd(query.getCriteria()), query.getOrderBy());
+ if (query.getOrderBy() != null) {
+ PostOrderNavigator.doVisit(query.getOrderBy(), emv);
+ }
+ return table.createTupleSource(command.getProjectedSymbols(), query.getCriteria(), query.getOrderBy());
}
if (command instanceof ProcedureContainer) {
GroupSymbol group = ((ProcedureContainer)command).getGroup();
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -648,6 +648,7 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
@@ -690,6 +691,7 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -268,7 +268,7 @@
String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -529,6 +529,7 @@
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
caps.setCapabilitySupport(Capability.ROW_OFFSET, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
// pm1 model supports order by
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
@@ -596,6 +597,7 @@
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
// pm1 model supports order by
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
@@ -630,6 +632,7 @@
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
caps.setCapabilitySupport(Capability.ROW_OFFSET, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
// pm1 model supports order by
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -92,7 +92,7 @@
import org.teiid.query.validator.ValidatorReport;
import org.teiid.translator.SourceSystemFunctions;
-@SuppressWarnings("nls")
+@SuppressWarnings({"nls", "unchecked"})
public class TestOptimizer {
public interface DependentJoin {}
@@ -268,7 +268,8 @@
final GroupSymbol symbol = (GroupSymbol)groups.iterator().next();
Object modelId = md.getModelID(symbol.getMetadataID());
boolean supportsGroupAliases = CapabilitiesUtil.supportsGroupAliases(modelId, md, capFinder);
- command.acceptVisitor(new AliasGenerator(supportsGroupAliases));
+ boolean supportsProjection = CapabilitiesUtil.supports(Capability.QUERY_SELECT_EXPRESSION, modelId, md, capFinder);
+ command.acceptVisitor(new AliasGenerator(supportsGroupAliases, !supportsProjection));
expectedQueries.add(command.toString());
} catch (Exception err) {
throw new RuntimeException(err);
@@ -5504,7 +5505,7 @@
}
/**
- * Since can now guarantee unique select column names, it's ok to have repeated entries in the order by clause.
+ * A final rewrite will ensure the correct order by
*/
@Test public void testOrderByDuplicates() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -5527,7 +5528,7 @@
ProcessorPlan plan = helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT g_0.intkey AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_1, c_0"}, //$NON-NLS-1$
+ new String[] {"SELECT g_0.intkey, g_0.intkey FROM bqt1.smalla AS g_0 ORDER BY g_0.intkey"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -5743,8 +5744,8 @@
null,
capFinder,
new String[] {
- "SELECT bqt2.smallb.intkey AS c_0, bqt2.smalla.intkey AS c_1 FROM bqt2.smalla, bqt2.smallb WHERE bqt2.smalla.stringkey = bqt2.smallb.stringkey ORDER BY c_0, c_1", //$NON-NLS-1$
- "SELECT bqt1.smalla.intkey AS c_0 FROM bqt1.smalla ORDER BY c_0"}, //$NON-NLS-1$
+ "SELECT bqt2.smallb.intkey, bqt2.smalla.intkey FROM bqt2.smalla, bqt2.smallb WHERE bqt2.smalla.stringkey = bqt2.smallb.stringkey ORDER BY bqt2.smallb.intkey, bqt2.smalla.intkey", //$NON-NLS-1$
+ "SELECT bqt1.smalla.intkey FROM bqt1.smalla ORDER BY bqt1.smalla.intkey"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -348,7 +348,22 @@
ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp3()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
new String[] { "EXEC pm1.sp3()" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
}
// test implicit type conversion of argument
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -45,10 +45,10 @@
private Command helpTest(String sql,
String expected,
boolean aliasGroups,
- QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException {
+ boolean stripColumnAliases, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException {
Command command = TestResolver.helpResolve(sql, metadata, null);
command = QueryRewriter.rewrite(command, metadata, null);
- command.acceptVisitor(new AliasGenerator(aliasGroups));
+ command.acceptVisitor(new AliasGenerator(aliasGroups, stripColumnAliases));
assertEquals(expected, command.toString());
return command;
}
@@ -67,13 +67,13 @@
@Test public void testLongOrderByAlias() throws Exception {
String sql = "select pm1.g1.e1 || pm1.g1.e2 as asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa, pm1.g1.e2 from pm1.g1 order by asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa"; //$NON-NLS-1$
String expected = "SELECT concat(g_0.e1, g_0.e2) AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.example1Cached());
}
@Test public void testOrderBySymbolName() throws Exception {
String sql = "select e1 from pm1.g1 order by e1"; //$NON-NLS-1$
String expected = "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
- Query command = (Query)helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
+ Query command = (Query)helpTest(sql, expected, true, false, FakeMetadataFactory.example1Cached());
assertEquals(command.getOrderBy().getSortKeys().get(0).getName(), "e1"); //$NON-NLS-1$
assertEquals(((SingleElementSymbol)command.getProjectedSymbols().get(0)).getShortName(), "e1"); //$NON-NLS-1$
}
@@ -81,73 +81,85 @@
@Test public void testInlineViewWithSubQuery() throws Exception {
String sql = "select intnum from (select intnum from bqt1.smallb where intnum in (select intnum a from bqt1.smalla)) b"; //$NON-NLS-1$
String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT g_1.intnum FROM bqt1.smalla AS g_1)) AS v_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testInlineViewOrderBy() throws Exception {
String sql = "select intnum from (select intnum from bqt1.smallb) b order by b.intnum"; //$NON-NLS-1$
String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0 ORDER BY c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testNestedInlineViewOrderBy() throws Exception {
String sql = "select x from (select intnum x from (select intnum from bqt1.smallb) b order by x) y order by x"; //$NON-NLS-1$
String expected = "SELECT v_1.c_0 FROM (SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0) AS v_1 ORDER BY c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testInlineViewWithOnClause() throws Exception {
String sql = "select abcd.efg from (select intkey as efg from bqt1.smalla) abcd inner join (select intnum from bqt1.smallb) b on (b.intnum = abcd.efg)"; //$NON-NLS-1$
String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intkey AS c_0 FROM bqt1.smalla AS g_0) AS v_0 INNER JOIN (SELECT g_1.intnum AS c_0 FROM bqt1.smallb AS g_1) AS v_1 ON v_1.c_0 = v_0.c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testUnionOrderBy() throws Exception {
String sql = "select e1, e2 as c_0 from pm1.g1 union all select 1, e1 from pm1.g2 order by e1"; //$NON-NLS-1$
String expected = "SELECT g_1.e1 AS c_0, g_1.e2 AS c_1 FROM pm1.g1 AS g_1 UNION ALL SELECT '1' AS c_0, g_0.e1 AS c_1 FROM pm1.g2 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.example1Cached());
}
@Test public void testDuplicateShortElementName() throws Exception {
String sql = "select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 order by pm1.g1.e1, pm1.g2.e1"; //$NON-NLS-1$
String expected = "SELECT g_0.e1 AS c_0, g_1.e1 AS c_1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 ORDER BY c_0, c_1"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.example1Cached());
}
@Test public void testCorrelatedRefernce() throws Exception {
String sql = "select intnum, stringnum from (select intnum, stringnum from bqt1.smallb) b where intnum in (select b.stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
String expected = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intnum AS c_0, g_0.stringnum AS c_1 FROM bqt1.smallb AS g_0) AS v_0 WHERE v_0.c_0 IN (SELECT concat(v_0.c_1, v_1.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_1)"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testCorrelatedRefernce1() throws Exception {
String sql = "select intnum, stringnum from bqt1.smallb where intnum in (select stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
String expected = "SELECT g_0.intnum, g_0.stringnum FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT concat(g_0.stringnum, v_0.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_0)"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testGroupAliasNotSupported() throws Exception {
String sql = "select b.intkey from bqt1.smalla b"; //$NON-NLS-1$
String expected = "SELECT bqt1.smalla.intkey FROM bqt1.smalla"; //$NON-NLS-1$
- helpTest(sql, expected, false, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, false, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testUnionAliasing() throws Exception {
String sql = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA"; //$NON-NLS-1$
String expected = "SELECT BQT1.SmallA.IntKey AS c_0 FROM BQT1.SmallA UNION ALL SELECT BQT1.SmallA.IntNum AS c_0 FROM BQT1.SmallA"; //$NON-NLS-1$
- helpTest(sql, expected, false, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, false, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testUnrelatedOrderBy() throws Exception {
String sql = "SELECT b.IntKey FROM BQT1.SmallA a, BQT1.SmallA b ORDER BY a.StringKey"; //$NON-NLS-1$
String expected = "SELECT g_1.IntKey AS c_0 FROM BQT1.SmallA AS g_0, BQT1.SmallA AS g_1 ORDER BY g_0.StringKey"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.exampleBQTCached());
}
@Test public void testUnrelatedOrderBy1() throws Exception {
String sql = "SELECT b.IntKey FROM (select intkey, stringkey from BQT1.SmallA) a, (select intkey, stringkey from BQT1.SmallA) b ORDER BY a.StringKey"; //$NON-NLS-1$
String expected = "SELECT v_1.c_0 FROM (SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM BQT1.SmallA AS g_0) AS v_0, (SELECT g_1.intkey AS c_0, g_1.stringkey AS c_1 FROM BQT1.SmallA AS g_1) AS v_1 ORDER BY v_0.c_1"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ helpTest(sql, expected, true, false, FakeMetadataFactory.exampleBQTCached());
}
+ @Test public void testStripAliases() throws Exception {
+ String sql = "select intkey as a, stringkey as b from BQT1.SmallA ORDER BY a, b"; //$NON-NLS-1$
+ String expected = "SELECT g_0.intkey, g_0.stringkey FROM BQT1.SmallA AS g_0 ORDER BY g_0.intkey, g_0.stringkey"; //$NON-NLS-1$
+ helpTest(sql, expected, true, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testStripAliases1() throws Exception {
+ String sql = "select intkey as a, stringkey as b from BQT1.SmallA ORDER BY a, b"; //$NON-NLS-1$
+ String expected = "SELECT BQT1.SmallA.intkey, BQT1.SmallA.stringkey FROM BQT1.SmallA ORDER BY BQT1.SmallA.intkey, BQT1.SmallA.stringkey"; //$NON-NLS-1$
+ helpTest(sql, expected, false, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -7342,7 +7342,7 @@
FakeDataManager dataManager = new FakeDataManager();
sampleData2(dataManager);
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT (5 + 1)"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"SELECT pm1.g1.e1 FROM pm1.g1 LIMIT (5 + 1)"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
helpProcess(plan, dataManager, expected);
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-07-27 14:22:24 UTC (rev 2378)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-07-27 17:15:15 UTC (rev 2379)
@@ -143,4 +143,18 @@
execute("select e2, e1 from x where e2 = 1", new List[] {Arrays.asList(1, "one")}); //$NON-NLS-1$
}
+ @Test public void testOrderByWithIndex() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e2))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (3, 'one')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (2, 'one')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x as y order by e2 desc", new List[] {Arrays.asList("one", 3), Arrays.asList("one", 2)}); //$NON-NLS-1$
+ }
+
+ @Test public void testOrderByWithoutIndex() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e2))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (3, 'a')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x order by e1", new List[] {Arrays.asList("a", 3), Arrays.asList("b", 2)}); //$NON-NLS-1$
+ }
+
}
14 years, 5 months
teiid SVN: r2378 - trunk/documentation/client-developers-guide/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-07-27 10:22:24 -0400 (Tue, 27 Jul 2010)
New Revision: 2378
Modified:
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
Log:
TEIID-1048: adding documentation about passthough to the URL and data source connection properties.
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2010-07-27 14:21:35 UTC (rev 2377)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2010-07-27 14:22:24 UTC (rev 2378)
@@ -208,6 +208,19 @@
</entry>
<entry>(typically not set as a connection property) Can be ON|OFF; ON prevents query execution, but parsing and planning will still occur. Default OFF.</entry>
</row>
+ <row>
+ <entry>
+ <code>PassthroughAuthentication</code>
+ </entry>
+ <entry>
+ <code>boolean</code>
+ </entry>
+ <entry>Only applies to embedded connections. When this option is set to "true", then Teiid looks for
+ already authenticated security context on the calling thread. If one found it uses that users credentials
+ to create session. Teiid also verifies that the same user is using this connection during the life of the connection.
+ if it finds a different security context on the calling thread, it switches the identity on the connection,
+ if the new user is also eligible to log in to Teiid otherwise connection fails to execute.</entry>
+ </row>
</tbody>
</tgroup>
@@ -312,7 +325,21 @@
<code>String</code>
</entry>
<entry>Name given to this data source</entry>
- </row>
+ </row>
+ <row>
+ <entry>
+ <code>PassthroughAuthentication</code>
+ </entry>
+ <entry>
+ <code>boolean</code>
+ </entry>
+ <entry>Only applies to embedded connections. When this option is set to "true", then Teiid looks for
+ already authenticated security context on the calling thread. If one found it uses that users credentials
+ to create session. Teiid also verifies that the same user is using this connection during the life of the connection.
+ if it finds a different security context on the calling thread, it switches the identity on the connection,
+ if the new user is also eligible to log in to Teiid otherwise connection fails to execute.</entry>
+ </row>
+
</tbody>
</tgroup>
</table>
14 years, 5 months