teiid SVN: r2468 - trunk/build/kits/jboss-container.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-08-17 11:50:45 -0400 (Tue, 17 Aug 2010)
New Revision: 2468
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
Log:
verbose bold
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-08-17 13:42:24 UTC (rev 2467)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-08-17 15:50:45 UTC (rev 2468)
@@ -42,7 +42,7 @@
<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>
+ <LI>
<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>Improved Insert Support</B> - Cross source inserts using a query expression can defer to the source to perform the entire insert atomically with source controlled batching.
See maxPreparedInsertBatchSize on any JDBC translator supporting the InsertWithIterator capability.
14 years, 4 months
teiid SVN: r2467 - in trunk: build/assembly/jboss-container and 6 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-08-17 09:42:24 -0400 (Tue, 17 Aug 2010)
New Revision: 2467
Modified:
trunk/build/assembly/docs.xml
trunk/build/assembly/jboss-container/dist.xml
trunk/documentation/caching-guide/
trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml
trunk/documentation/reference/src/main/docbook/en-US/content/system_schema.xml
trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java
Log:
TEIID-168 updating the matview/cache hint section of the docs, improving the ordered insert into a temptable, adding the caching doc to the kit
Modified: trunk/build/assembly/docs.xml
===================================================================
--- trunk/build/assembly/docs.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/build/assembly/docs.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -19,6 +19,7 @@
<include>org.jboss.teiid.documentation:developer-guide</include>
<include>org.jboss.teiid.documentation:quick-start-example</include>
<include>org.jboss.teiid.documentation:client-developers-guide</include>
+ <include>org.jboss.teiid.documentation:caching-guide</include>
</includes>
<sources>
Modified: trunk/build/assembly/jboss-container/dist.xml
===================================================================
--- trunk/build/assembly/jboss-container/dist.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/build/assembly/jboss-container/dist.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -90,7 +90,12 @@
<source>target/distribution/teiid-${version}-docs/client-developers-guide/en-US/pdf/teiid_client_developers_guide.pdf</source>
<outputDirectory>teiid-docs</outputDirectory>
<fileMode>0644</fileMode>
- </file>
+ </file>
+ <file>
+ <source>target/distribution/teiid-${version}-docs/caching-guide/en-US/pdf/teiid_caching_guide.pdf</source>
+ <outputDirectory>teiid-docs</outputDirectory>
+ <fileMode>0644</fileMode>
+ </file>
</files>
Property changes on: trunk/documentation/caching-guide
___________________________________________________________________
Name: svn:ignore
- target
+ target
.project
.classpath
Legal_Notice.html
.settings
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -3,6 +3,77 @@
%CustomDTD;
]>
<chapter id="cache-hint">
- <title>Cache Hint</title>
- <para></para>
+ <title>Cache Hint</title>
+ <para>A cache hint can be used to:</para>
+ <itemizedlist>
+ <listitem><para>Indicate that a user query is eligible for result set caching.
+ </para></listitem>
+ <listitem><para>Set the result set query cache entry memory preference or time to live.
+ </para></listitem>
+ <listitem><para>Set the materialized view memory preference, time to live, or updatablity.
+ </para></listitem>
+ </itemizedlist>
+ <para><synopsis>/*+ cache[([pref_mem] [ttl:n] [updatable])] */</synopsis>
+ <itemizedlist>
+ <listitem><para><emphasis>pref_mem</emphasis> - if present indicates that the cached results should prefer to remain in memory. They are not however required to be memory only.
+ </para></listitem>
+ <listitem><para><emphasis>ttl:n</emphasis> - if present n indicates the time to live value in milliseconds.
+ </para></listitem>
+ <listitem><para><emphasis>updatable</emphasis> - if present indicates that the cached results can be updated.
+ </para></listitem>
+ </itemizedlist>
+ </para>
+ <section>
+ <title>ResultSet Cache Query</title>
+ <para>The most basic form of the cache hint, <code>/*+ cache */</code>, is sufficient to inform the engine that the results of the non-update command should be cached.</para>
+ <example>
+ <title>PreparedStatement ResultSet Caching</title>
+ <programlisting>...
+PreparedStatement ps = connection.prepareStatement("/*+ cache */ select col from t where col2 = ?");
+ps.setInt(1, 5);
+ps.execute();
+...</programlisting>
+ <para>While no options are specified with the cache hint, it still informs the engine to use ResultSet caching.</para>
+ </example>
+ <para>The pref_mem and ttl options may also be used for ResultSet cache queries, however updatable only has an effect on materialized view tables.</para>
+ <example>
+ <title>Advanced ResultSet Caching</title>
+ <programlisting>/*+ cache(pref_mem ttl:60000 */ select col from t</programlisting>
+ <para>In this example the memory preference has been enabled and the time to live is set to 60000 milliseconds or 1 minute.
+ The ttl for an entry is actually treated as it's maximum age and the entry may be purged sooner if the maximum number of cache entries has been reached.</para>
+ </example>
+ <para>See the <link linkend="resultset">ResultSet Caching Chapter</link> for more.</para>
+ </section>
+ <section>
+ <title>Materialized Views</title>
+ <para>The cache hint, when used in the context of an internal materialized view transformation query, provides the ability to fine tune the materializated table.
+ The hint is not used for materialization targeted at an external source. See the <link linkend="resultset">Materialized View Chapter</link> for more on materialized views.</para>
+ <para>The pref_mem option also applies to internal materialized views. Internal table index pages already have a memory preference, so the perf_mem option indicates that the data pages should prefer memory as well.</para>
+ <section>
+ <title>TTL Snapshot Refresh</title>
+ <para>When the ttl is specified in the cache hint, a full refresh of the materialized view will be triggered automatically after the specified time interval.
+ The refresh is equivalent to <code>CALL SYS.refreshMatView('view name', false)</code>, but performed asynchronously so that user queries do not block on the load.
+ </para>
+ <para>The automatic loading is not intended for complex loading scenarios, as nested materialized views will be used by the refresh query.</para>
+ </section>
+ <section>
+ <title>Updatable</title>
+ <para>When the updatable option is specified, the materialized view may be targeted by the system function <code>refreshMatViewRow</code>.
+ The refreshMatViewRow function updates a single row of an internal materialized with the supplied key value.
+ The refresh query does use nested caches, so this refresh method should be used with caution.
+ </para>
+ <para>When the updatable option is not specified, accessing the materialized view table is more efficient because modifications do not need to be considered.
+ Therefore, only specify the updatable option if row based incremental updates are needed. Even when performing row updates, full snapshot refreshes may be needed to ensure consistency.</para>
+ </section>
+ </section>
+ <section>
+ <title>Limitations</title>
+ <itemizedlist>
+ <listitem><para>The form of the query hint must be matched exactly for the hint to have affect.
+ For a user query if the hint is not specified correctly, e.g. /*+ cach(pref_mem) */, it will not be used by the engine nor will
+ there be an informational log. As a workaround, the query plan may be checked though (see the Client Developers Guide) to see if the user command
+ in the plan has retained the proper hint.
+ </para></listitem>
+ </itemizedlist>
+ </section>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -34,7 +34,7 @@
</section>
<section>
<title>Limitations</title>
- <orderedlist>
+ <itemizedlist>
<listitem>
<para>The use of the lookup function automatically performs caching;
there is no option to use the lookup function and not perform
@@ -43,7 +43,7 @@
<listitem>
<para>No mechanism is provided to refresh code tables.</para>
</listitem>
- </orderedlist>
+ </itemizedlist>
</section>
<section>
<title>Materialized View Alternative</title>
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -4,63 +4,53 @@
]>
<chapter id="matviews">
<title>Materialized Views</title>
- <para>Teiid supports Materialized Views. These are Relational
- virtual tables and views (‘virtual groups’) for which the
- transformations are pre-computed and the results are stored in an
- external database. When queries are issued against these virtual
- groups through the Teiid Server, the cached results are used.
+ <para>Teiid supports materialized views. Materialized views are just like other views, but their
+ transformations are pre-computed and stored just like a regular table.
+ When queries are issued against the views through the Teiid Server, the cached results are used.
This saves the cost of accessing all the underlying data sources and
- re-computing the virtual group transforms each time a query is
- executed against the group. </para>
- <para>This strategy is appropriate when the underlying data does not
+ re-computing the view transforms each time a query is
+ executed.</para>
+ <para>Materialized views are appropriate when the underlying data does not
change rapidly, or when it is acceptable to retrieve data that is
- “stale” within some period of time, or when it is preferred for
+ "stale" within some period of time, or when it is preferred for
end-user queries to access staged data rather than placing additional
- query load on operational sources. Teiid provides a utility to
- refresh materialized tables. This utility uses the Teiid batched
- update functionality.</para>
+ query load on operational sources.</para>
<section>
<title>Support Summary</title>
- <orderedlist>
+ <itemizedlist>
<listitem>
<para>Caching of relational table or view records (pre-computing all
transformations)</para>
</listitem>
<listitem>
- <para>Model-based definition of virtual groups to cache</para>
+ <para>Model-based definition of virtual groups to cache (requires Teiid Designer)</para>
</listitem>
<listitem>
<para>User ability to override use of materialized view cache for
- specific queries</para>
+ specific queries through OPTION NO CACHE</para>
</listitem>
- <listitem>
- <para>Administrative utility to initially load and refresh cached
- data</para>
- </listitem>
- </orderedlist>
+ </itemizedlist>
</section>
<section>
<title>User Interaction</title>
<para>When client applications issue queries against a Relational
table or view that has been defined as a materialized view, the
Teiid query engine automatically routes that query to obtain the
- results from the cache database. </para>
+ results from the cache database.</para>
<para>Individual queries may override the use of materialized views by
- specifying OPTION NOCACHE on the query. This parameter must specify
+ specifying OPTION NOCACHE on the query. This parameter may specify
one or more virtual groups to override (separated by commas, spaces
- optional). If no virtual groups are specified, then it is the same
- as if the override option is not specified. Note that only virtual
- groups specified in the user or transformation query (in the FROM
- clause) can be specified to be overridden. If there are materialized
- virtual groups below that level (referenced in transformations), then
- the materialized view for those tables will be used. </para>
- <para>Examples:</para>
- <para>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE vg1, vg3
+ optional). If no virtual groups are specified, materialized views tables will not be used transitively.
</para>
- <para>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE</para>
- <para>The second query is equivalent to:</para>
- <para>SELECT * from vg1, vg2, vg3 WHERE OPTION NOCACHE vg1, vg2, vg3
- </para>
+ <example>
+ <title>Full NOCACHE</title>
+ <programlisting>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE</programlisting>
+ </example>
+ <example>
+ <title>Specific NOCACHE</title>
+ <programlisting>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE vg1, vg3</programlisting>
+ <para>Only the vg1 and vg3 caches will be skipped vg2 or any materialized views nested under vg1 and vg3 will be used.</para>
+ </example>
<para>The materialization override option may be specified in virtual
group transformation definitions. In that way, transformations can
specify to always use real-time data obtained directly from a source.
@@ -68,359 +58,36 @@
definitions, just as with user queries.</para>
</section>
<section>
- <title>Cache Configuration</title>
- <para>Materialized View Definition</para>
- <para>Materialized views are defined in the MetaBase Modeler by
- setting the materialized property on a table or view in a relational
+ <title>Materialized View Definition</title>
+ <para>Materialized views are defined in Teiid Designer by
+ setting the materialized property on a table or view in a virtual (view) relational
model. Setting this property's value to true (the default is false)
allows the data generated for this virtual table to be treated as a
materialized view. </para>
- <para>The Name In Source property for this table determines the name
- of the physical Materialized Views tables. If left blank the default
- naming scheme of MV10000001 is used, otherwise the name provided is
- used.</para>
- <para />
- <para>Virtual Database Definition</para>
- <para>Materialized views are relational tables (or views) in one or
- more models that have their materialized property set to true. When
- a set of virtual relational models containing materialized views is
- bundled into a virtual database (VDB) in the MetaBase Modeler, a
- physical relational model is automatically created and put into that
- VDB to represent the physical cache. The physical model is given the
- well-known name Materialization. The physical cache model will
- contain one physical table for each virtual group marked as a
- materialized view. </para>
- <para>Note that if no virtual groups are marked as materialized views,
- then the Materialization physical cache model will not be created or
- included in the VDB.</para>
- <para>Virtual Database Deployment </para>
- <para>When deploying a virtual database (VDB) in the Teiid
- Console, the Teiid administrator must define connector bindings
- for all physical models in the VDB. This is true for the well-known
- materialization cache model also. In the New VDB or New VDB Version
- wizard, the materialization model will show up in the Connector
- Binding definition panel. The administrator should select the
- appropriate JDBC connector for the data source where the materialized
- view cache will reside. </para>
- <para>When deploying a VDB containing materialized views, the
- Teiid administrator will be presented with the option to save
- administration scripts to the local file system. This is in the New
- VDB, New VDB Version, and Import VDB wizards. The administrator
- should save the scripts to a location where they can be accessed by a
- database administrator responsible for creating, loading, and
- refreshing the cache database. See Cache Administration section.
- </para>
- <para>This is a summary of what an administrator must do when
- deploying a VDB containing materialized views:</para>
- <orderedlist>
- <listitem>
- <para>Define connector binding from the materialization model to the
- physical cache database.</para>
+ <note><para>It is important to ensure that all key/index information is present as these will be used by the materialization process to enhance the performance of the materialized table.</para></note>
+ <para>The target materialized table may also be set in the properties. If the value is left blank, the default, then internal materialization will be used.
+ Otherwise for external materialization, the value should reference the fully qualified name of a table (or possibly view) with the same columns as the materialized view.
+ The choice between internal and external materialization should be made based upon:
+ <itemizedlist>
+ <listitem><para>Does the cached data need to be fully persistent? If yes, then external materialization should be used.
+ Internal materialization should not survive a cluster restart.</para>
</listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>This defines the DBMS type, subsequently used to save cache
- creation and loading scripts appropriate for that database type
- </para>
+ <listitem><para>Is full control needed of loading and refresh? If yes, then external materialzation should be used.
+ Internal materialization does offer several system supported methods for refreshing, but does not give full access to the materialized table.</para>
</listitem>
- <listitem>
- <para>The username and password used in the connector binding must
- have privileges for the cache database </para>
- </listitem>
- <listitem>
- <para>The cache database may not exist at this point, in which case
- the connector binding cannot be started, and the VDB cannot be
- activated.</para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>Define username and password for creating and manipulating
- (swapping and truncating) cache tables in the cache database.
- </para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>The username and password must directly connect to a schema or
- catalog in the database that is appropriate for the VDB version.
- This cache may be used by multiple VDB versions, but this is in
- general not recommended.</para>
- </listitem>
- <listitem>
- <para>This username and password will be used for executing the
- Create, Truncate, and Swap scripts.</para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>Define username and password for connecting to Teiid, to
- issue insert commands against the virtual groups during loading and
- reloading.</para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>This user information is not necessarily the same as the user
- information used in the connector binding, although it can be.
- </para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>Save DDL scripts to the file system. </para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>The administrator specifies the location to save the files.
- </para>
- </listitem>
- <listitem>
- <para>The location should be accessible to the DBA or the scheduling
- process that will execute the scripts against the database</para>
- </listitem>
- <listitem>
- <para>Four scripts will be saved with names appropriate to the VDB
- and version.</para>
- </listitem>
- </orderedlist>
- <para>Cache Characteristics</para>
- <para>Cache Persistence Mechanism</para>
- <para>Materialized views cache their data in an external database
- system. This database may be the same as the database used as the
- Teiid repository, or it may be a different one. In general it
- is recommended that the Teiid repository not be used for
- materialized view caching, as heavy use could impact the performance
- of other core functionality of the Teiid Server. </para>
- <para>The following DBMS systems are supported for this purpose:
+ </itemizedlist>
</para>
- <orderedlist>
- <listitem>
- <para>Oracle 8i or 9i or 10g</para>
- </listitem>
- <listitem>
- <para>SQL Server 2000</para>
- </listitem>
- <listitem>
- <para>DB2 8</para>
- </listitem>
- </orderedlist>
- <para>Cache Operational Policy</para>
+
+ </section>
+ <section>
+ <title>External Materialization</title>
+ <para>External materialized views cache their data in an external database
+ system. External materialized views give the administrator full control over the loading and refresh strategies.</para>
<para>Since the actual physical cache for materialized views is
maintained external to the Teiid system, there is no pre-defined
policy for clearing and managing the cache. These policies will be
defined and enforced by administrators of the Teiid system.
</para>
- <para>Cache Administration</para>
- <para>The cache used by materialized views is administered external to
- Teiid. This provides a great deal of flexibility on how that
- cache is managed, refreshed, backed up, and otherwise administered
- along with other enterprise sources.</para>
- <para>Administrator Responsibilities</para>
- <para>These are the responsibilities of administrators with respect to
- Teiid’s materialized view data caching.</para>
- <informaltable frame="all">
- <tgroup cols="3">
- <colspec colnum="1" colname="c1" />
- <colspec colnum="2" colname="c2" />
- <colspec colnum="3" colname="c3" />
- <tbody>
- <row>
- <entry>
- <para>Operation</para>
- </entry>
- <entry>
- <para>Run Against</para>
- </entry>
- <entry>
- <para>Required Rights for Cache Database</para>
- </entry>
- <entry>
- <para>Required Rights for Teiid</para>
- </entry>
- <entry>
- <para>Scripts Used</para>
- </entry>
- <entry>
- <para>Frequency</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Create cache database</para>
- </entry>
- <entry>
- <para>Cache database</para>
- </entry>
- <entry>
- <para>Create</para>
- </entry>
- <entry>
- <para>None</para>
- </entry>
- <entry>
- <para>Create</para>
- </entry>
- <entry>
- <para>Once per VDB version</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Initially populate cache </para>
- </entry>
- <entry>
- <para>Cache database and Teiid</para>
- </entry>
- <entry>
- <para>Alter, Insert</para>
- </entry>
- <entry>
- <para>CRUD</para>
- </entry>
- <entry>
- <para>Truncate</para>
- <para>Load</para>
- <para>Swap</para>
- </entry>
- <entry>
- <para>Once per VDB version</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Refresh cache </para>
- </entry>
- <entry>
- <para>Cache database and Teiid</para>
- </entry>
- <entry>
- <para>Alter, Insert </para>
- </entry>
- <entry>
- <para>CRUD </para>
- </entry>
- <entry>
- <para>Truncate</para>
- <para>Load</para>
- <para>Swap</para>
- </entry>
- <entry>
- <para>Desired cache refresh rate</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <para />
- <para>The refresh cache operation is recurring, basically at whatever
- frequency is appropriate for maintaining the desired data “freshness”
- for the VDB version. This operation can be scheduled to execute the
- Teiid scripts, using standard scheduling mechanisms such as cron
- on UNIX or the Windows scheduler.</para>
- <para>The truncate and swap scripts are used in the initial load. The
- truncate is a no-op in this case, and the swap happens because data
- is always loaded to the staging table, which must then be swapped
- with the real cache table. </para>
- <para>Teiid Administrative Scripts</para>
- <para>To perform the administrative operations, Teiid provides a
- set of 4 scripts. Here is a summary of the scripts. All the scripts
- use a similar template for their file names:
- VDBName_VDBVersion_Name.ddl).</para>
- <informaltable frame="all">
- <tgroup cols="5">
- <tbody>
- <row>
- <entry>
- <para>Script Base Name</para>
- </entry>
- <entry>
- <para>Use</para>
- </entry>
- <entry>
- <para>Description</para>
- </entry>
- <entry>
- <para>Run Against</para>
- </entry>
- <entry>
- <para>User Info</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Create</para>
- </entry>
- <entry>
- <para>Creation</para>
- </entry>
- <entry>
- <para>Create tables for cache</para>
- </entry>
- <entry>
- <para>Cache database</para>
- </entry>
- <entry>
- <para>Script user</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Truncate</para>
- </entry>
- <entry>
- <para>Reload</para>
- </entry>
- <entry>
- <para>Truncate temporary table when inserting new records</para>
- </entry>
- <entry>
- <para>Cache database</para>
- </entry>
- <entry>
- <para>Script user</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Load</para>
- </entry>
- <entry>
- <para>Load or reload </para>
- </entry>
- <entry>
- <para>Execute queries against materialized virtual groups, insert
- results into cache</para>
- </entry>
- <entry>
- <para>Teiid</para>
- </entry>
- <entry>
- <para>Access user</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Swap</para>
- </entry>
- <entry>
- <para>Reload</para>
- </entry>
- <entry>
- <para>Swap temporary table with cache table after new records
- inserted</para>
- </entry>
- <entry>
- <para>Cache database</para>
- </entry>
- <entry>
- <para>Script user</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
+ <para></para>
</section>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -6,12 +6,8 @@
<title>Overview</title>
<para>Teiid provides several capabilities for caching
data including: materialized views, result set caching, and code table caching.
- These can be used to significantly improve performance in many
- situations. </para>
-
- <section id="cache_hint">
- <title>Cache Hint</title>
- <para>Non-update user commands may be preceded with a cache hint, e.g. /*+ cache */ select ..., to inform the engine that the results of command should be cached. The scope of the result, either session or global, will be deteremined automatically from the determinism level of the source queries and functions executed.</para>
- <para>ResultSet caching must be enabled for this hint to have an effect.</para>
- </section>
+ These techniques can be used to significantly improve performance in many
+ situations.</para>
+ <para>With the exception of external materialized views, the cached data is accessed through the BufferManager.
+ For better performance, the BufferManager setting should be adjusted to the memory constraints of your installation.</para>
</chapter>
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -11,7 +11,7 @@
can yield significant performance gains if users of the system submit
the same queries often.</para>
<para>Result set caching will cache result sets based on an exact match
- of the incoming SQL string. Caching only applies to SELECT, set query, and stored procedure execution
+ of the incoming SQL string and PreparedStatement parameter values if present. Caching only applies to SELECT, set query, and stored procedure execution
statements; it does not apply to SELECT INTO statements, or INSERT,
UPDATE, or DELETE statements.</para>
<section>
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -47,7 +47,8 @@
</bookinfo>
<toc />
<xi:include href="content/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/resultset.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/codetable.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/cachehint.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>
\ No newline at end of file
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/system_schema.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/system_schema.xml 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/system_schema.xml 2010-08-17 13:42:24 UTC (rev 2467)
@@ -393,6 +393,128 @@
</informaltable>
</section>
<section>
+ <title>SYS.MatViews</title>
+ <para>This table supplies information about all the materailized views in the virtual database.</para>
+ <informaltable frame="all">
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>
+ <para>Column Name</para>
+ </entry>
+ <entry>
+ <para>Type</para>
+ </entry>
+ <entry>
+ <para>Description</para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>VDBName</para>
+ </entry>
+ <entry>
+ <para>string</para>
+ </entry>
+ <entry>
+ <para>VDB name</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>SchemaName</para>
+ </entry>
+ <entry>
+ <para>string</para>
+ </entry>
+ <entry>
+ <para>Schema Name</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Name</para>
+ </entry>
+ <entry>
+ <para>string</para>
+ </entry>
+ <entry>
+ <para>Short group name</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>TargetSchemaName</para>
+ </entry>
+ <entry>
+ <para>string</para>
+ </entry>
+ <entry>
+ <para>Name of the materialized table schema</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>TargetName</para>
+ </entry>
+ <entry>
+ <para>string</para>
+ </entry>
+ <entry>
+ <para>Name of the materialized table</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Valid</para>
+ </entry>
+ <entry>
+ <para>boolean</para>
+ </entry>
+ <entry>
+ <para>True if materialized table is currently valid.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>LoadState</para>
+ </entry>
+ <entry>
+ <para>boolean</para>
+ </entry>
+ <entry>
+ <para>The load state, can be one of NEEDS_LOADING, LOADING, LOADED, FAILED_LOAD</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Updated</para>
+ </entry>
+ <entry>
+ <para>timestamp</para>
+ </entry>
+ <entry>
+ <para>The timestamp of the last full refresh.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Cardinality</para>
+ </entry>
+ <entry>
+ <para>integer</para>
+ </entry>
+ <entry>
+ <para>The number of rows in the materialized view table.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section>
<title>SYS.Columns</title>
<para>This table supplies information about all the elements
(columns, tags, attributes, etc) in the virtual database.</para>
@@ -1646,6 +1768,28 @@
<para>A single column containing the schemas as clobs.</para>
</entry>
</row>
+ <row>
+ <entry>
+ <para>refreshMatView</para>
+ </entry>
+ <entry>
+ <para>(string ViewName, boolean Invalidate)</para>
+ </entry>
+ <entry>
+ <para>An return return value, RowsUpdated. See the Caching Guide for more.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>refreshMatViewRow</para>
+ </entry>
+ <entry>
+ <para>(string ViewName, object Key)</para>
+ </entry>
+ <entry>
+ <para>An return return value, RowsUpdated. See the Caching Guide for more.</para>
+ </entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-08-17 13:42:24 UTC (rev 2467)
@@ -212,7 +212,7 @@
} else {
SearchResult result = places.removeLast();
Object value = (i == 0 ? tuple : page);
- page = insert(key, result, places.peekLast(), value);
+ page = insert(key, result, places.peekLast(), value, mode == InsertMode.ORDERED);
}
}
return null;
@@ -222,19 +222,13 @@
return tuple.subList(0, keyLength);
}
- SPage insert(List k, SearchResult result, SearchResult parent, Object value) throws TeiidComponentException {
+ SPage insert(List k, SearchResult result, SearchResult parent, Object value, boolean ordered) throws TeiidComponentException {
SPage page = result.page;
int index = -result.index - 1;
if (result.values.getTuples().size() == pageSize) {
boolean leaf = !(value instanceof SPage);
SPage nextPage = new SPage(this, leaf);
TupleBatch nextValues = nextPage.getValues();
- nextValues.getTuples().addAll(result.values.getTuples().subList(pageSize/2, pageSize));
- result.values.getTuples().subList(pageSize/2, pageSize).clear();
- if (!leaf) {
- nextPage.children.addAll(page.children.subList(pageSize/2, pageSize));
- page.children.subList(pageSize/2, pageSize).clear();
- }
nextPage.next = page.next;
nextPage.prev = page;
if (nextPage.next != null) {
@@ -242,18 +236,30 @@
}
page.next = nextPage;
boolean inNext = false;
- if (index <= pageSize/2) {
- setValue(index, k, value, result.values, page);
+ if (!ordered) {
+ //split the values
+ nextValues.getTuples().addAll(result.values.getTuples().subList(pageSize/2, pageSize));
+ result.values.getTuples().subList(pageSize/2, pageSize).clear();
+ if (!leaf) {
+ nextPage.children.addAll(page.children.subList(pageSize/2, pageSize));
+ page.children.subList(pageSize/2, pageSize).clear();
+ }
+ if (index <= pageSize/2) {
+ setValue(index, k, value, result.values, page);
+ } else {
+ inNext = true;
+ setValue(index - pageSize/2, k, value, nextValues, nextPage);
+ }
+ page.setValues(result.values);
+ if (parent != null) {
+ List min = nextPage.getValues().getTuples().get(0);
+ SPage.correctParents(parent.page, min, page, nextPage);
+ }
} else {
inNext = true;
- setValue(index - pageSize/2, k, value, nextValues, nextPage);
+ setValue(0, k, value, nextValues, nextPage);
}
nextPage.setValues(nextValues);
- page.setValues(result.values);
- if (parent != null) {
- List min = nextPage.getValues().getTuples().get(0);
- SPage.correctParents(parent.page, min, page, nextPage);
- }
if (inNext) {
page = nextPage;
}
Modified: trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java 2010-08-16 20:06:21 UTC (rev 2466)
+++ trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java 2010-08-17 13:42:24 UTC (rev 2467)
@@ -26,18 +26,19 @@
import org.junit.Test;
+@SuppressWarnings("nls")
public class TestDefaultCache {
@Test public void testExpiration() throws InterruptedException {
- DefaultCache<Integer, Integer> cache = new DefaultCache<Integer, Integer>("foo", 2, 50);
+ DefaultCache<Integer, Integer> cache = new DefaultCache<Integer, Integer>("foo", 2, 70);
cache.put(1, 1);
- Thread.sleep(60);
+ Thread.sleep(100);
assertNull(cache.get(1));
cache.put(2, 2);
- Thread.sleep(30);
+ Thread.sleep(50);
cache.put(3, 3);
assertNotNull(cache.get(2));
- Thread.sleep(40);
+ Thread.sleep(50);
cache.put(4, 4);
//preferred to purge 2 instead of 3
assertNotNull(cache.get(3));
14 years, 4 months
teiid SVN: r2466 - trunk/documentation/reference/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-08-16 16:06:21 -0400 (Mon, 16 Aug 2010)
New Revision: 2466
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
Log:
updating the xmltable example
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-08-16 17:58:22 UTC (rev 2465)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-08-16 20:06:21 UTC (rev 2466)
@@ -914,7 +914,7 @@
<itemizedlist>
<para>Examples</para>
<listitem>
- <para>Use of passing, returns 1 row [1]: <programlisting>select * from xmltable('/a' PASSING {x '<a id="1"/>'} COLUMNS id integer PATH '@id') x</programlisting>
+ <para>Use of passing, returns 1 row [1]: <programlisting>select * from xmltable('/a' PASSING xmlparse(document '<a id="1"/>') COLUMNS id integer PATH '@id') x</programlisting>
</para>
</listitem>
<listitem>
14 years, 4 months
teiid SVN: r2465 - in trunk: client/src/main/java/org/teiid/adminapi/impl and 5 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-08-16 13:58:22 -0400 (Mon, 16 Aug 2010)
New Revision: 2465
Added:
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestAdminObjectBuilder.java
Removed:
trunk/jboss-integration/src/test/java/org/teiid/templates/connector/
Modified:
trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java
trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
Log:
TEIID-1208: Enum objects were not being handled by the AdminObjectBuilder. The support has been now added.
Modified: trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2010-08-16 17:57:20 UTC (rev 2464)
+++ trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2010-08-16 17:58:22 UTC (rev 2465)
@@ -63,24 +63,24 @@
* Is "CREATE" allowed?
* @return
*/
- Boolean isAllowCreate();
+ Boolean getAllowCreate();
/**
* Is "SELECT" allowed?
* @return
*/
- Boolean isAllowRead();
+ Boolean getAllowRead();
/**
* Is "INSERT/UPDATE" allowed?
* @return
*/
- Boolean isAllowUpdate();
+ Boolean getAllowUpdate();
/**
* Is "DELETE" allowed?
* @return
*/
- Boolean isAllowDelete();
+ Boolean getAllowDelete();
}
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2010-08-16 17:57:20 UTC (rev 2464)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2010-08-16 17:58:22 UTC (rev 2465)
@@ -173,7 +173,7 @@
@Override
@ManagementProperty(description="Allows Create")
- public Boolean isAllowCreate() {
+ public Boolean getAllowCreate() {
return allowCreate;
}
@@ -183,7 +183,7 @@
@Override
@ManagementProperty(description="Allows Read")
- public Boolean isAllowRead() {
+ public Boolean getAllowRead() {
return allowRead;
}
@@ -193,7 +193,7 @@
@Override
@ManagementProperty(description="Allows Update")
- public Boolean isAllowUpdate() {
+ public Boolean getAllowUpdate() {
return allowUpdate;
}
@@ -203,7 +203,7 @@
@Override
@ManagementProperty(description="Allows Delete")
- public Boolean isAllowDelete() {
+ public Boolean getAllowDelete() {
return allowDelete;
}
@@ -213,16 +213,16 @@
public String getType() {
StringBuilder sb = new StringBuilder();
- if (Boolean.TRUE.equals(isAllowCreate())) {
+ if (Boolean.TRUE.equals(getAllowCreate())) {
sb.append("C");//$NON-NLS-1$
}
- if (Boolean.TRUE.equals(isAllowRead())) {
+ if (Boolean.TRUE.equals(getAllowRead())) {
sb.append("R");//$NON-NLS-1$
}
- if (Boolean.TRUE.equals(isAllowUpdate())) {
+ if (Boolean.TRUE.equals(getAllowUpdate())) {
sb.append("U");//$NON-NLS-1$
}
- if (Boolean.TRUE.equals(isAllowDelete())) {
+ if (Boolean.TRUE.equals(getAllowDelete())) {
sb.append("D");//$NON-NLS-1$
}
return sb.toString();
@@ -231,13 +231,13 @@
public Boolean allows(PermissionType type) {
switch (type) {
case CREATE:
- return isAllowCreate();
+ return getAllowCreate();
case READ:
- return isAllowRead();
+ return getAllowRead();
case UPDATE:
- return isAllowUpdate();
+ return getAllowUpdate();
case DELETE:
- return isAllowDelete();
+ return getAllowDelete();
}
throw new AssertionError();
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-08-16 17:57:20 UTC (rev 2464)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-08-16 17:58:22 UTC (rev 2465)
@@ -210,6 +210,10 @@
return getValidationErrors(Severity.ERROR);
}
+ public void setErrors(List<ValidationError> errors){
+ this.errors = errors;
+ }
+
public List<ValidationError> getValidationErrors(ValidationError.Severity severity){
if (this.errors == null) {
return Collections.emptyList();
Modified: trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-08-16 17:57:20 UTC (rev 2464)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-08-16 17:58:22 UTC (rev 2465)
@@ -174,12 +174,12 @@
for (DataPolicy.DataPermission p: permissions) {
if (p.getResourceName().equalsIgnoreCase("myTable.T1")) { //$NON-NLS-1$
- assertTrue(p.isAllowRead());
- assertNull(p.isAllowDelete());
+ assertTrue(p.getAllowRead());
+ assertNull(p.getAllowDelete());
}
else {
- assertFalse(p.isAllowRead());
- assertTrue(p.isAllowDelete());
+ assertFalse(p.getAllowRead());
+ assertTrue(p.getAllowDelete());
}
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-08-16 17:57:20 UTC (rev 2464)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-08-16 17:58:22 UTC (rev 2465)
@@ -208,7 +208,7 @@
for (ManagedComponent mc: vdbComponents) {
String name = ManagedUtil.getSimpleValue(mc, "name", String.class);//$NON-NLS-1$
int version = ManagedUtil.getSimpleValue(mc, "version", Integer.class);//$NON-NLS-1$
- if (name.equals(vdbName) && version == vdbVersion) {
+ if (name.equalsIgnoreCase(vdbName) && version == vdbVersion) {
return mc;
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java 2010-08-16 17:57:20 UTC (rev 2464)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java 2010-08-16 17:58:22 UTC (rev 2465)
@@ -69,6 +69,12 @@
if (type.isSimple()) {
PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((SimpleValue)value).getValue());
}
+ else if (type.isPrimitive()) {
+ PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((SimpleValue)value).getValue());
+ }
+ else if (type.isEnum()) {
+ PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((org.jboss.metatype.api.values.EnumValue)value).getValue());
+ }
else if (type.isProperties()) {
}
@@ -104,9 +110,17 @@
else if (elementType.isComposite()) {
list.addAll((List)MetaValueFactory.getInstance().unwrap(value));
}
-
+ else {
+ throw new TeiidRuntimeException("unsupported type"); //$NON-NLS-1$
+ }
PropertiesUtils.setBeanProperty(t, mp.getMappedName(), list);
}
+ else if (type.isGeneric()) {
+ throw new TeiidRuntimeException("unsupported type"); //$NON-NLS-1$
+ }
+ else if (type.isTable()|| type.isArray()) {
+ throw new TeiidRuntimeException("unsupported type"); //$NON-NLS-1$
+ }
}
}
return clazz.cast(t);
Added: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestAdminObjectBuilder.java
===================================================================
--- trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestAdminObjectBuilder.java (rev 0)
+++ trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestAdminObjectBuilder.java 2010-08-16 17:58:22 UTC (rev 2465)
@@ -0,0 +1,190 @@
+/*
+ * 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.adminapi.jboss;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
+import org.junit.Test;
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.impl.DataPolicyMetadata;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.TranslatorMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.translator.ExecutionFactory;
+
+@SuppressWarnings("nls")
+public class TestAdminObjectBuilder {
+
+ @Test
+ public void testVDB() {
+
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("myVDB");
+ vdb.setDescription("vdb description");
+ vdb.setVersion(1);
+ vdb.addProperty("vdb-property", "vdb-value");
+
+ ModelMetaData modelOne = new ModelMetaData();
+ modelOne.setName("model-one");
+ modelOne.addSourceMapping("s1", "translator", "java:mybinding");
+ modelOne.setModelType(Model.Type.PHYSICAL);
+ modelOne.addProperty("model-prop", "model-value");
+ modelOne.addProperty("model-prop", "model-value-override");
+ modelOne.setVisible(false);
+ modelOne.addError("ERROR", "There is an error in VDB");
+ modelOne.setDescription("model description");
+
+ vdb.addModel(modelOne);
+
+ ModelMetaData modelTwo = new ModelMetaData();
+ modelTwo.setName("model-two");
+ modelTwo.addSourceMapping("s1", "translator", "java:binding-one");
+ modelTwo.addSourceMapping("s2", "translator", "java:binding-two");
+ modelTwo.setModelType(Model.Type.VIRTUAL);
+ modelTwo.addProperty("model-prop", "model-value");
+
+ vdb.addModel(modelTwo);
+
+ TranslatorMetaData t1 = new TranslatorMetaData();
+ t1.setName("oracleOverride");
+ t1.setType("oracle");
+ t1.addProperty("my-property", "my-value");
+ List<Translator> list = new ArrayList<Translator>();
+ list.add(t1);
+ vdb.setOverrideTranslators(list);
+
+ DataPolicyMetadata roleOne = new DataPolicyMetadata();
+ roleOne.setName("roleOne");
+ roleOne.setDescription("roleOne described");
+
+ PermissionMetaData perm1 = new PermissionMetaData();
+ perm1.setResourceName("myTable.T1");
+ perm1.setAllowRead(true);
+ roleOne.addPermission(perm1);
+
+ PermissionMetaData perm2 = new PermissionMetaData();
+ perm2.setResourceName("myTable.T2");
+ perm2.setAllowRead(false);
+ perm2.setAllowDelete(true);
+ roleOne.addPermission(perm2);
+
+ roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2"));
+
+ vdb.addDataPolicy(roleOne);
+
+ // convert to managed object and build the VDB out of MO
+ ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
+ ManagedObject mo = mof.initManagedObject(vdb, null, null);
+ vdb = AdminObjectBuilder.buildAO(mo, VDBMetaData.class);
+
+ assertEquals("myVDB", vdb.getName());
+ assertEquals("vdb description", vdb.getDescription());
+ assertEquals(1, vdb.getVersion());
+ assertEquals("vdb-value", vdb.getPropertyValue("vdb-property"));
+
+ assertNotNull(vdb.getModel("model-one"));
+ assertNotNull(vdb.getModel("model-two"));
+ assertNull(vdb.getModel("model-unknown"));
+
+ modelOne = vdb.getModel("model-one");
+ assertEquals("model-one", modelOne.getName());
+ assertEquals("s1", modelOne.getSourceNames().get(0));
+ assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
+ assertEquals("model-value-override", modelOne.getPropertyValue("model-prop"));
+ assertFalse(modelOne.isVisible());
+ assertEquals("model description", modelOne.getDescription());
+
+ modelTwo = vdb.getModel("model-two");
+ assertEquals("model-two", modelTwo.getName());
+ assertTrue(modelTwo.getSourceNames().contains("s1"));
+ assertTrue(modelTwo.getSourceNames().contains("s2"));
+ assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
+ assertEquals("model-value", modelTwo.getPropertyValue("model-prop"));
+
+
+ assertTrue(vdb.getValidityErrors().contains("There is an error in VDB"));
+
+ List<Translator> translators = vdb.getOverrideTranslators();
+ assertTrue(translators.size() == 1);
+
+ Translator translator = translators.get(0);
+ assertEquals("oracleOverride", translator.getName());
+ assertEquals("oracle", translator.getType());
+ assertEquals("my-value", translator.getPropertyValue("my-property"));
+
+ List<DataPolicy> roles = vdb.getDataPolicies();
+
+ assertTrue(roles.size() == 1);
+
+ DataPolicyMetadata role = vdb.getDataPolicy("roleOne");
+ assertEquals("roleOne described", role.getDescription());
+ assertNotNull(role.getMappedRoleNames());
+ assertTrue(role.getMappedRoleNames().contains("ROLE1"));
+ assertTrue(role.getMappedRoleNames().contains("ROLE2"));
+
+ List<DataPolicy.DataPermission> permissions = role.getPermissions();
+ assertEquals(2, permissions.size());
+
+ for (DataPolicy.DataPermission p: permissions) {
+ if (p.getResourceName().equalsIgnoreCase("myTable.T1")) {
+ assertTrue(p.getAllowRead());
+ assertNull(p.getAllowDelete());
+ }
+ else {
+ assertFalse(p.getAllowRead());
+ assertTrue(p.getAllowDelete());
+ }
+ }
+ }
+
+ @Test
+ public void testTranslator() {
+ TranslatorMetaData tm = new TranslatorMetaData();
+
+ tm.setExecutionFactoryClass(ExecutionFactory.class);
+ tm.setName("Oracle");
+ tm.addProperty("ExtensionTranslationClassName", "org.teiid.translator.jdbc.oracle.OracleSQLTranslator");
+
+ // convert to managed object and build the VDB out of MO
+ ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
+ ManagedObject mo = mof.initManagedObject(tm, null, null);
+ tm = AdminObjectBuilder.buildAO(mo, TranslatorMetaData.class);
+
+ assertEquals("Oracle", tm.getName());
+ assertEquals(ExecutionFactory.class.getName(), tm.getPropertyValue(Translator.EXECUTION_FACTORY_CLASS));
+ assertEquals("org.teiid.translator.jdbc.oracle.OracleSQLTranslator", tm.getPropertyValue("ExtensionTranslationClassName"));
+ }
+}
Property changes on: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestAdminObjectBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-08-16 17:57:20 UTC (rev 2464)
+++ trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-08-16 17:58:22 UTC (rev 2465)
@@ -124,16 +124,16 @@
for(DataPolicy.DataPermission permission: permissions) {
if (permission.getResourceName().equals("myTable.T1")) {
- assertTrue(permission.isAllowRead());
- assertFalse(permission.isAllowCreate());
- assertFalse(permission.isAllowDelete());
- assertFalse(permission.isAllowUpdate());
+ assertTrue(permission.getAllowRead());
+ assertFalse(permission.getAllowCreate());
+ assertFalse(permission.getAllowDelete());
+ assertFalse(permission.getAllowUpdate());
}
else if (permission.getResourceName().equals("myTable.T2")) {
- assertFalse(permission.isAllowRead());
- assertFalse(permission.isAllowCreate());
- assertTrue(permission.isAllowDelete());
- assertFalse(permission.isAllowUpdate());
+ assertFalse(permission.getAllowRead());
+ assertFalse(permission.getAllowCreate());
+ assertTrue(permission.getAllowDelete());
+ assertFalse(permission.getAllowUpdate());
}
else {
fail("there are only two types of permissions");
14 years, 4 months
teiid SVN: r2464 - in trunk: console/src/main/resources/META-INF and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-08-16 13:57:20 -0400 (Mon, 16 Aug 2010)
New Revision: 2464
Added:
trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml
Modified:
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
trunk/console/src/main/resources/META-INF/rhq-plugin.xml
trunk/documentation/caching-guide/pom.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml
trunk/documentation/docbook/custom.dtd
trunk/documentation/pom.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
Log:
TEIID-168 updating the rs caching section of the docs, updating JOPR to set max age on rs entries. ensuring that permissions are checked even on cached results
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2010-08-16 17:57:20 UTC (rev 2464)
@@ -21,6 +21,7 @@
*/
package org.teiid.cache.jboss;
+import java.util.HashSet;
import java.util.Set;
import org.jboss.cache.Cache;
@@ -78,9 +79,10 @@
public void clear() {
Node<K, V> node = getRootNode();
node.clearData();
- Set<Node<K,V>> nodes = node.getChildren();
+ Set<Node<K,V>> nodes = new HashSet<Node<K, V>>(node.getChildren());
for (Node<K, V> child : nodes) {
child.clearData();
+ node.removeChild(child.getFqn());
}
}
Modified: trunk/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-08-16 17:57:20 UTC (rev 2464)
@@ -259,10 +259,6 @@
<resource-configuration>
<c:group name="teiidProperties" displayName="Runtime Engine Properties"
hiddenByDefault="false">
- <c:simple-property name="resultSetCacheMaxEntries"
- displayName="Result Set Cache Max Entries"
- description="The maximum number of result set cache entries. 0 indicates no limit. (default 1024)"
- required="false" readOnly="false" />
<c:simple-property name="maxRowsFetchSize"
displayName="Max Rows Fetch Size"
description="The maximum number of result set cache entries. 0 indicates no limit. (default 1024)"
@@ -270,12 +266,8 @@
<c:simple-property name="processName" displayName="Process Name"
description="Name that uniquely identifies this process" required="false"
readOnly="false" />
- <c:simple-property name="preparedPlanCacheMaxCount"
- displayName="Prepared Plan Cache Max Count"
- description="The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250)"
- required="false" readOnly="false" />
<c:simple-property name="maxThreads" displayName="Max Threads"
- description="Process pool maximum thread count. (default 16) Increase this value if your load includes a large number of XQueries or if the system's available processors is larger than 8"
+ description="Process pool maximum thread count. (default 64)"
required="false" readOnly="false" />
<c:simple-property name="timeSliceInMilli"
displayName="Time Slice In Milliseconds"
@@ -283,12 +275,24 @@
required="false" readOnly="false" />
<c:simple-property name="lobChunkSizeInKB"
displayName="Lob Chunk Size In KB"
- description="The max lob chunk size in KB transferred each time when processing blobs, clobs(100KB default)"
+ description="The max lob chunk size in KB transferred to the client for xml, blobs, clobs (default 100KB)"
required="false" readOnly="false" />
<c:simple-property name="resultSetCacheEnabled"
displayName="Result Set Cache Enabled"
description="Denotes whether or not result set caching is enabled. (default true)"
required="false" readOnly="false" type="boolean" />
+ <c:simple-property name="resultSetCacheMaxEntries"
+ displayName="Result Set Cache Max Entries"
+ description="The maximum number of result set cache entries. -1 indicates no limit. (default 1024)"
+ required="false" readOnly="false" />
+ <c:simple-property name="resultSetCacheMaxEntryAge"
+ displayName="Result Set Cache Max Entry Age"
+ description="The maximum age of a result set cache entry in seconds. -1 indicates no max. (default 7200)"
+ required="false" readOnly="false" />
+ <c:simple-property name="preparedPlanCacheMaxCount"
+ displayName="Prepared Plan Cache Max Count"
+ description="The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250)"
+ required="false" readOnly="false" />
<c:simple-property name="activeSessionsCount"
displayName="Active Session Count" description="Count of active sessions"
required="false" readOnly="false" />
Modified: trunk/documentation/caching-guide/pom.xml
===================================================================
--- trunk/documentation/caching-guide/pom.xml 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/documentation/caching-guide/pom.xml 2010-08-16 17:57:20 UTC (rev 2464)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.1.0-SNAPSHOT</version>
+ <version>7.1.0.Final-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>caching-guide</artifactId>
@@ -20,6 +20,11 @@
<extensions>true</extensions>
<dependencies>
<dependency>
+ <groupId>net.sf.docbook</groupId>
+ <artifactId>docbook</artifactId>
+ <version>1.74.0</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-docbook-xslt</artifactId>
<version>1.1.0</version>
@@ -61,6 +66,8 @@
</formats>
<options>
<xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <docbookVersion>1.72.0</docbookVersion>
<localeSeparator>-</localeSeparator>
<useRelativeImageUris>false</useRelativeImageUris>
</options>
Added: trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml (rev 0)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml 2010-08-16 17:57:20 UTC (rev 2464)
@@ -0,0 +1,8 @@
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+<chapter id="cache-hint">
+ <title>Cache Hint</title>
+ <para></para>
+</chapter>
\ No newline at end of file
Property changes on: trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-08-16 17:57:20 UTC (rev 2464)
@@ -70,9 +70,15 @@
<title>Steps to create a materialized view:</title>
<listitem>
<para>Create a view selecting the appropriate columns from the desired table. In general, this view may have an arbitrarily complicated transformation query.</para>
+ </listitem>
+ <listitem>
<para>Designate the appropriate column(s) as the primary key.</para>
+ </listitem>
+ <listitem>
<para>Set the materailized property to true.</para>
- <para>Add a cache hint to the transformation query. To mimic the behavior of the implicit internal materialized view created by the lookup function, use /*+ cache(pref_mem) */ to indicate that the table data pages should prefer to remain in memory.</para>
+ </listitem>
+ <listitem>
+ <para>Add a cache hint to the transformation query. To mimic the behavior of the implicit internal materialized view created by the lookup function, use the <link linkend="cache-hint">cache hint</link> <code>/*+ cache(pref_mem) */</code> to indicate that the table data pages should prefer to remain in memory.</para>
</listitem>
</orderedlist>
<para>Just as with the lookup function, the materialized view table will be created on first use and reused subsequently. See the <link linkend="matviews">Materialized View Chapter</link> for more on materialized views.</para>
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-08-16 17:57:20 UTC (rev 2464)
@@ -4,251 +4,90 @@
]>
<chapter id="resultset">
<title>Result Set Caching</title>
- <para>Teiid provides the capability to store the results of
- specific queries. Teiid can be configured to store the results
- for end-user queries, or to cache the results of atomic queries issued
- to data sources in response to end-user queries, or both. When the
- exact same user query is submitted to the Teiid Server, the
- cached results will be returned. Similarly, if the exact same atomic
- query is encountered while processing an end-user query, the cached
- results will be used in processing that query, even if the end-user
- query is different than the original one. These caching techniques
+ <para>Teiid provides the capability to cache the results of
+ specific user queries. When the
+ exact same user query is submitted to Teiid, the
+ cached results will be returned. This caching technique
can yield significant performance gains if users of the system submit
- the same queries often, or if user queries result in the same queries
- being issued to the underlying data sources.</para>
+ the same queries often.</para>
<para>Result set caching will cache result sets based on an exact match
- of the incoming SQL string. It only applies to SELECT and EXEC
+ of the incoming SQL string. Caching only applies to SELECT, set query, and stored procedure execution
statements; it does not apply to SELECT INTO statements, or INSERT,
- UPDATE, and DELETE statements.</para>
+ UPDATE, or DELETE statements.</para>
<section>
<title>Support Summary</title>
- <orderedlist>
+ <itemizedlist>
<listitem>
- <para>Caching of end-user queries (on a per-query service basis)
- </para>
+ <para>Caching of user query results.</para>
</listitem>
<listitem>
- <para>Caching of data source queries (on a per-connector binding
- basis)</para>
+ <para>Scoping of results is automatically determined to be either VDB (replicated) or session level.</para>
</listitem>
<listitem>
- <para>Scoping of caching to either VDB or session level</para>
+ <para>Caching of XML document model results.</para>
</listitem>
<listitem>
- <para>Caching of XML result sets</para>
+ <para>Configurable number of cache entries and time to live.</para>
</listitem>
<listitem>
- <para>Users explicitly state whether to use a result set cache or
- not (if available)</para>
+ <para>Administrative clearing.</para>
</listitem>
- <listitem>
- <para>Administrative clearing of caches</para>
- </listitem>
- </orderedlist>
+ </itemizedlist>
</section>
<section>
<title>User Interaction</title>
<para>End users or client applications explicitly state whether to use
- result set caching for each query. This can be done by setting the
- JDBC ResultSetCacheMode execution property to true to enable the use
- of caching for that statement, or false to disable it. The default
- is true. Note that if this property is set to true, it only has an
- effect if caching has been enabled in the Server. </para>
- <para>Specification of result set caching for ODBC and SOAP is through
- extra URL properties, on a per-connection basis. </para>
- <para>Each query is re-checked for authorization for the user’s
- permissions, regardless of whether or not the query results have been
- cached.</para>
+ result set caching. This can be done by setting the
+ JDBC ResultSetCacheMode execution property to true (default false) or by adding a <link linkend="cache-hint">cache hint</link> to the query.
+ Note that if either of these mechanisms are used, Teiid must also have result set caching enabled (the default is enabled).</para>
+ <para>
+ To control the preference of individual results to remain in memory or the time to live see the <link linkend="cache-hint">cache hint</link>.
+ If a cache hint is not specified, then the default time to live of the result set caching configuration will be used.
+ </para>
+ <note><para>Each query is re-checked for authorization using the current user’s permissions,
+ regardless of whether or not the results have been cached.</para></note>
</section>
<section>
<title>Cache Configuration</title>
- <para>Result set caching in the Teiid Server is configured in the
- Teiid Console. By default, result set caching is disabled.
- When enabled, the default caching scope is restricted to a
- particular VDB.</para>
- <para>Result set caching can be enabled and configured in two places:
+ <para>By default result set caching is enabled with 1024 maximum entries with a maximum entry age of 2 hours.
+ There are actually 2 caches configured with these settings. One cache holds results that are specific to sessions and is local to each Teiid instance.
+ The other cache holds VDB scoped results and can be replicated.
+ See the &jboss-beans; config file or the Console's "Runtime Engine Properties" for tuning the configuration.
+ The user may also override the default maximum entry age via the <link linkend="cache-hint">cache hint</link>.</para>
+ <para>Result set caching is not limited to memory. There is no explicit limit on the size of the results that can be cached.
+ Cached results are primarily stored in the BufferManager and are subject to it's configuration - including the restriction of maximum buffer space.
</para>
- <orderedlist>
- <listitem>
- <para>End-user queries – In Configuration Deployment panel,
- QueryEngine PSC, QueryService properties (per Teiid process)
- </para>
- </listitem>
- <listitem>
- <para>Data source queries – In Configuration Connector Binding
- panel, properties</para>
- </listitem>
- </orderedlist>
- <para>The following are the properties that can be set at the query
- service and connector binding levels.</para>
- <informaltable frame="all">
- <tgroup cols="4">
- <tbody>
- <row>
- <entry>
- <para>Property</para>
- </entry>
- <entry>
- <para>Description</para>
- </entry>
- <entry>
- <para>Type</para>
- </entry>
- <entry>
- <para>Default</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ResultSet Cache Enabled</para>
- </entry>
- <entry>
- <para>Enable result set caching for the source</para>
- </entry>
- <entry>
- <para>Boolean</para>
- </entry>
- <entry>
- <para>false</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ResultSet Cache Maximum Age</para>
- </entry>
- <entry>
- <para>Maximum time before the cache is automatically cleared
- </para>
- </entry>
- <entry>
- <para>Integer – millsec</para>
- </entry>
- <entry>
- <para>0 (no limit)</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ResultSet Cache Maximum Size</para>
- </entry>
- <entry>
- <para>Maximum size the cache will be allowed to grow to before
- objects are removed</para>
- </entry>
- <entry>
- <para>Integer – MB </para>
- </entry>
- <entry>
- <para>0 (no limit)</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ResultSet Cache Scope</para>
- </entry>
- <entry>
- <para>Whether caching is restricted to a specific session
- (‘session’) or a specific VDB version (‘vdb’)</para>
- </entry>
- <entry>
- <para>String</para>
- </entry>
- <entry>
- <para>vdb</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <para />
- <para>End-User Cache Configuration</para>
- <para>End-user query result caching is controlled in properties for
- the individual Query Services in each PSC. These properties can be
- accessed in the Configuration Deployment panel, by selecting the
- QueryEngine PSC, then selecting an individual QueryService. The
- properties are shown at the bottom. </para>
- <para>
- <inlinegraphic fileref="embedded:graphics3" width="5.3866inch"
- depth="3.5646inch" />
- </para>
- <para>Data Source Cache Configuration</para>
- <para>Data source caching is controlled in properties for the
- individual connector bindings for each source. These properties can
- be accessed on the Configuration Connector Bindings panel, by
- selecting an individual connector binding and selecting the
- Properties tab. Note that these are all optional properties. Check
- the Include Optional Properties setting to see these properties.
- </para>
</section>
<section>
- <title>Cache Characteristics</title>
- <para>Cache Persistence Mechanism</para>
- <para>Result sets are persisted in object caches local to individual
- Java processes (virtual machines or VMs). User query result sets
- are cached in the VM of the individual query services running on host
- machines. Data source query results are cached in the VM of the
- individual connector bindings running on host machines. </para>
- <para>Cache Operational Policy</para>
- <para>Objects are removed from the cache on a least frequently used
- basis. When the cache reaches approximately 90% of its maximum size
- (as defined by the ResultSet Cache Maximum Size property), query
- result sets are removed to bring the cache back down to the 80%
- threshold.</para>
- </section>
- <section>
<title>Cache Administration</title>
- <para>Result set caching is administered using the servershell script
- under the <server install>/util directory. This script is
- called servershell.cmd on Windows systems, and servershell.sh on Unix
- systems. </para>
- <para>The following administrative operations can be performed for all
- caches of a given type, by specifying the appropriate parameters on
- the script’s command-line:</para>
- <orderedlist>
- <listitem>
- <para>Clear cache options</para>
- </listitem>
- <listitem>
- <para>clearQueryServiceResultSetCaches – clears all the result set
- caches in all the query services</para>
- </listitem>
- <listitem>
- <para>clearConnectorServiceResultSetCaches – clears all the result
- set caches in all the connector services</para>
- </listitem>
- </orderedlist>
- <para>These can be listed in help by executing the script with the
- command-line argument expertmode on. </para>
+ <para>The result set cache can be cleared through the AdminAPI using the <code>clearCache</code> method.
+ The expected cache key is "QUERY_SERVICE_RESULT_SET_CACHE".</para>
+ <example>
+ <title>Clearing the ResultSet Cache in AdminShell</title>
+ <programlisting>connectAsAdmin()
+clearCache("QUERY_SERVICE_RESULT_SET_CACHE")
+...</programlisting>
+ </example>
+ <para>See the Admin Guide for more on using the AdminAPI and AdminShell.</para>
</section>
<section>
<title>Limitations</title>
- <orderedlist>
+ <itemizedlist>
<listitem>
- <para>BLOBs and CLOBs cannot be cached. Therefore, any query
- retrieving BLOB or CLOB information will not be cached. </para>
+ <para>Non-XML document model results, BLOBs, and CLOBs cannot be cached.</para>
</listitem>
<listitem>
- <para>Caches are not distributed; they are bound to a particular
- Teiid process. So, if the same query is routed to two
- different host machines, the query will be executed twice, and
- cached independently on each machine. </para>
+ <para>The exact SQL string, including the cache hint if present, must match the cached entry for the results to be reused.
+ This allows cache usage to skip parsing and resolving for faster responses.</para>
</listitem>
<listitem>
- <para>Result set caching is not transactional and should not be used
- in the scope of XA transactions. Transactions depend on (and
- enforce) consistency of data, and cached data cannot be guaranteed
+ <para>Result set caching is not transactional. Transactions depend on (and
+ enforce) consistency of data, and cached data is not guaranteed
to be consistent with the data store’s data.</para>
</listitem>
<listitem>
- <para>ResultSet Cache Scope property values are not constrained, so
- users may type in the incorrect values (only vdb and session are
- allowed). [defect 14444]</para>
+ <para>Clearing the result set cache clears all cache entries for all VDBs.</para>
</listitem>
- </orderedlist>
+ </itemizedlist>
</section>
- <section>
- <title>Outstanding Issues</title>
- <para>Specification of result set caching for ODBC and SOAP is through
- extra URL properties, on a per-connection basis.</para>
- </section>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml 2010-08-16 17:57:20 UTC (rev 2464)
@@ -47,7 +47,7 @@
</bookinfo>
<toc />
<xi:include href="content/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <!-- <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> -->
+ <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/resultset.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/codetable.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>
\ No newline at end of file
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml 2010-08-16 17:57:20 UTC (rev 2464)
@@ -20,8 +20,7 @@
are encrypted using a <ulink url="http://en.wikipedia.org/wiki/Diffie-Hellman_key_exchange">Diffy-Hellman</ulink>
key that is negotiated per connection. This
encryption is controlled by <code>clientEncryptionEnabled</code> property in <code>JdbcSslConfiguration</code> and
- <code>AdminSslConfiguration</code> sections
- in <code><jboss-install>/server/<profile>/deploy/teiid/teiid-jboss-beans.xml</code> file.</para>
+ <code>AdminSslConfiguration</code> sections in the &jboss-beans; file.</para>
</section>
<section id="ssl_modes">
Modified: trunk/documentation/docbook/custom.dtd
===================================================================
--- trunk/documentation/docbook/custom.dtd 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/documentation/docbook/custom.dtd 2010-08-16 17:57:20 UTC (rev 2464)
@@ -5,3 +5,4 @@
<!ENTITY docUrl "&url;/docs.html">
<!ENTITY javaDocUrl "http://docs.jboss.org/teiid/&versionNumber;/apidocs">
<!ENTITY desDocUrl "http://www.jboss.org/teiiddesigner/docs.html">
+<!ENTITY jboss-beans "<code><jboss-install>/server/<profile>/deploy/teiid/teiid-jboss-beans.xml</code>">
Modified: trunk/documentation/pom.xml
===================================================================
--- trunk/documentation/pom.xml 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/documentation/pom.xml 2010-08-16 17:57:20 UTC (rev 2464)
@@ -16,5 +16,6 @@
<module>developer-guide</module>
<module>quick-start-example</module>
<module>client-developers-guide</module>
+ <module>caching-guide</module>
</modules>
</project>
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-08-16 15:47:22 UTC (rev 2463)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-08-16 17:57:20 UTC (rev 2464)
@@ -87,7 +87,7 @@
this.maxRowsFetchSize = maxRowsFetchSize;
}
- @ManagementProperty(description="The max lob chunk size in KB transferred each time when processing blobs, clobs(100KB default)")
+ @ManagementProperty(description="The max lob chunk size in KB transferred to the client for xml, blobs, clobs (default 100KB)")
public int getLobChunkSizeInKB() {
return this.lobChunkSizeInKB;
}
@@ -105,7 +105,7 @@
this.preparedPlanCacheMaxCount = preparedPlanCacheMaxCount;
}
- @ManagementProperty(description="The maximum number of result set cache entries. 0 indicates no limit. (default 1024)")
+ @ManagementProperty(description="The maximum number of result set cache entries. -1 indicates no limit. (default 1024)")
public int getResultSetCacheMaxEntries() {
return this.resultsetCacheConfig.getMaxEntries();
}
@@ -122,7 +122,16 @@
public boolean isResultSetCacheEnabled() {
return this.resultsetCacheConfig.isEnabled();
}
-
+
+ @ManagementProperty(description="The maximum age of a result set cache entry in seconds. -1 indicates no max. (default 7200)")
+ public int getResultSetCacheMaxEntryAge() {
+ return this.resultsetCacheConfig.getMaxAgeInSeconds();
+ }
+
+ public void setResultSetCacheMaxEntryAge(int maxAge) {
+ this.resultsetCacheConfig.setMaxAgeInSeconds(maxAge);
+ }
+
/**
* Determine whether role checking is enabled on the server.
* @return <code>true</code> if server-side role checking is enabled.
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-08-16 15:47:22 UTC (rev 2463)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-08-16 17:57:20 UTC (rev 2464)
@@ -344,6 +344,7 @@
this.analysisRecord = cr.getAnalysisRecord();
request.initMetadata();
this.originalCommand = cr.getCommand(requestMsg.getCommandString(), request.metadata, pi);
+ request.validateAccess(this.originalCommand);
this.doneProducingBatches();
return;
}
14 years, 4 months
teiid SVN: r2463 - in trunk: cache-jbosscache/src/main/java and 8 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-08-16 11:47:22 -0400 (Mon, 16 Aug 2010)
New Revision: 2463
Added:
trunk/engine/src/test/java/org/teiid/cache/
trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java
Removed:
trunk/cache-jbosscache/src/main/java/com/
Modified:
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
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/CacheConfiguration.java
trunk/engine/src/main/java/org/teiid/cache/DefaultCache.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/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java
Log:
TEIID-168 using the cache hint ttl for result set caching. adding ttl support for the default cache. always treating eviction as removal (until we do much more work with pinning, persistence, etc.) using a separate thread to load a mat view if it is currently valid
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-08-16 15:47:22 UTC (rev 2463)
@@ -49,13 +49,21 @@
<property name="clusteredCacheName">mvcc-shared</property>
</bean>
+ <!-- Configuration for result set caching.
+ There will be 2 caches with these settings.
+ One cache holds results that are specific to sessions.
+ The other cache holds vdb scoped results and can
+ be replicated.
+ -->
<bean name="ResultsetCacheConfig" class="org.teiid.cache.CacheConfiguration">
<property name="enabled">true</property>
- <!-- Max Entries allowed for ResultSet Cache -->
+ <!-- Max Entries allowed for ResultSet Cache (default 1024) -->
<property name="maxEntries">1024</property>
- <!-- 2 hrs -->
+ <!-- Max age in seconds (default 7200 - 2 hours) -->
<property name="maxAgeInSeconds">7200</property>
- <!-- Allowed values are LRU, FIFO, LFU, EXPIRATION -->
+ <!-- Allowed values are LRU, EXPIRATION.
+ Setting this value to LRU will cause cache hint TTL values
+ to be ignored. (default EXPIRATION) -->
<property name="type">EXPIRATION</property>
</bean>
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -21,10 +21,13 @@
*/
package org.teiid.cache.jboss;
+import java.util.Set;
+
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
+import org.teiid.cache.DefaultCache;
public class ExpirationAwareCache<K, V> extends JBossCache<K, V> {
@@ -35,28 +38,56 @@
@Override
public V get(K key) {
Node<K, V> node = getRootNode();
- Node child = node.getChild(Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode())));
+ Node child = node.getChild(getFqn(key));
if (child != null) {
return (V)child.get(key);
}
- return super.get(key);
+ return null;
}
+ private Fqn<String> getFqn(K key) {
+ return Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode()));
+ }
+
@Override
public V put(K key, V value) {
+ return this.put(key, value, null);
+ }
+
+ @Override
+ public V put(K key, V value, Long ttl) {
Node<K, V> node = getRootNode();
- Node child = node.addChild(Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode())));
- Long future = new Long(System.currentTimeMillis() + (config.getMaxAgeInSeconds()*1000));
+ Node child = node.addChild(getFqn(key));
+
+ long future = DefaultCache.getExpirationTime(config.getMaxAgeInSeconds()*1000, ttl);
child.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
return (V)child.put(key, value);
}
-
+
@Override
- public org.teiid.cache.Cache<K, V> addChild(String name) {
+ public V remove(K key) {
Node<K, V> node = getRootNode();
- Node child = node.addChild(Fqn.fromString(name));
- child.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, Long.MAX_VALUE);
- return new JBossCache<K, V>(this.cacheStore, child.getFqn());
+ Node child = node.getChild(getFqn(key));
+ if (child != null) {
+ return (V)child.remove(key);
+ }
+ return null;
}
+
+ @Override
+ public void clear() {
+ Node<K, V> node = getRootNode();
+ node.clearData();
+ Set<Node<K,V>> nodes = node.getChildren();
+ for (Node<K, V> child : nodes) {
+ child.clearData();
+ }
+ }
+
+ @Override
+ public int size() {
+ Node<K, V> node = getRootNode();
+ return node.getChildren().size();
+ }
}
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -50,30 +50,22 @@
this.rootFqn = fqn;
}
- /**
- * {@inheritDoc}
- */
public V get(K key) {
return this.cacheStore.get(this.rootFqn, key);
}
- /**
- * {@inheritDoc}
- */
public V put(K key, V value) {
return this.cacheStore.put(this.rootFqn, key, value);
}
+
+ public V put(K key, V value, Long ttl) {
+ return this.put(key, value);
+ }
- /**
- * {@inheritDoc}
- */
public V remove(K key) {
return this.cacheStore.remove(this.rootFqn, key);
}
- /**
- * {@inheritDoc}
- */
public Set<K> keySet() {
Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
if (node != null) {
@@ -82,9 +74,6 @@
return Collections.emptySet();
}
- /**
- * {@inheritDoc}
- */
public int size() {
Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
if (node != null) {
@@ -93,9 +82,6 @@
return 0;
}
- /**
- * {@inheritDoc}
- */
public void clear() {
Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
if (node != null) {
@@ -103,7 +89,6 @@
}
}
- @Override
public Collection<V> values() {
Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
if (node != null) {
@@ -120,28 +105,17 @@
this.cacheStore.addCacheListener(this.cacheListener);
}
- /**
- * {@inheritDoc}
- */
public synchronized void removeListener() {
this.cacheStore.removeCacheListener(this.cacheListener);
this.cacheListener = null;
}
- /**
- * {@inheritDoc}
- */
- @Override
public Cache<K, V> addChild(String name) {
Node<K, V> node = getRootNode();
Node<K, V> childNode = node.addChild(Fqn.fromString(name));
return new JBossCache<K, V>(this.cacheStore, childNode.getFqn());
}
- /**
- * {@inheritDoc}
- */
- @Override
public Cache<K, V> getChild(String name) {
Node<K, V> node = getRootNode();
Node<K, V> child = node.getChild(Fqn.fromString(name));
@@ -159,10 +133,6 @@
return node;
}
- /**
- * {@inheritDoc}
- */
- @Override
public List<Cache> getChildren() {
Node<K, V> node = getRootNode();
Set<Node<K,V>> nodes = node.getChildren();
@@ -176,10 +146,6 @@
return children;
}
- /**
- * {@inheritDoc}
- */
- @Override
public boolean removeChild(String name) {
Node<K, V> node = getRootNode();
return node.removeChild(Fqn.fromString(name));
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-08-14 21:19:46 UTC (rev 2462)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -31,8 +31,6 @@
import org.jboss.cache.config.EvictionAlgorithmConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
-import org.jboss.cache.eviction.FIFOAlgorithmConfig;
-import org.jboss.cache.eviction.LFUAlgorithmConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.eviction.RemoveOnEvictActionPolicy;
import org.teiid.cache.Cache;
@@ -96,16 +94,6 @@
lru.setTimeToLive(-1); // -1 no limit
evictionConfig = lru;
}
- else if (config.getPolicy() == Policy.FIFO) {
- FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig();
- fifo.setMaxNodes(config.getMaxEntries());
- evictionConfig = fifo;
- }
- else if (config.getPolicy() == Policy.LFU) {
- LFUAlgorithmConfig lfu = new LFUAlgorithmConfig();
- lfu.setMaxNodes(config.getMaxEntries());
- evictionConfig = lfu;
- }
else if (config.getPolicy() == Policy.EXPIRATION) {
ExpirationAlgorithmConfig lfu = new ExpirationAlgorithmConfig();
lfu.setMaxNodes(config.getMaxEntries());
@@ -113,14 +101,10 @@
}
EvictionRegionConfig erc = new EvictionRegionConfig(rootFqn, evictionConfig);
-
- if (config.getPolicy() == Policy.EXPIRATION) {
- erc.setEvictionActionPolicyClassName(RemoveOnEvictActionPolicy.class.getName());
- }
+ erc.setEvictionActionPolicyClassName(RemoveOnEvictActionPolicy.class.getName());
return erc;
}
-
public void destroy() {
this.destroyed = true;
}
Modified: trunk/engine/src/main/java/org/teiid/cache/Cache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/Cache.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/cache/Cache.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -22,11 +22,6 @@
package org.teiid.cache;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-
/**
* Abstraction over cache providers
*/
@@ -61,11 +56,12 @@
*
* @param key key with which the specified value is to be associated.
* @param value value to be associated with the specified key.
+ * @param ttl the time for this entry to live
* @return previous value associated with specified key, or <code>null</code> if there was no mapping for key.
* A <code>null</code> return can also indicate that the key previously associated <code>null</code> with the specified key,
* if the implementation supports null values.
*/
- V put(K key, V value);
+ V put(K key, V value, Long ttl);
/**
* Removes the value for this key from a Cache.
@@ -83,70 +79,12 @@
*/
int size();
-
- /**
- * Returns a {@link Set} containing the data in this Cache
- *
- * @return a {@link Set} containing the data in this Cache. If there is no data,
- * an empty {@link Set} is returned. The {@link Set} returned is always immutable.
- */
- Set<K> keySet();
-
/**
* Removes all the keys and their values from the Cache
*/
void clear();
/**
- * Listener to get the updates on this Cache
- * @param listener
- */
- void addListener(CacheListener listener);
-
- /**
- * Remove Listener to stop the updates on this Cache
- * @param listener
- */
- void removeListener();
-
- /**
- * Returns a {@link Collection} containing the data in this Cache
- *
- * @return a {@link Collection} containing the data in this Cache. If there is no data,
- * an empty {@link Collection} is returned.
- */
- Collection<V> values();
-
-
- /**
- * Add a child node to the current cache node
- * @param name - name of the child
- * @return Cache instance.
- */
- Cache addChild(String name);
-
- /**
- * Get the child cache node from the current node
- * @param name
- * @return null if not found
- */
- Cache getChild(String name);
-
- /**
- * Destroys the child from the current node; no-op if node not found
- * @param name
- * @return true if removed; false otherwise
- */
- boolean removeChild(String name);
-
-
- /**
- * Get child nodes under this cache node. If none found empty set is returned
- * @return
- */
- List<Cache> getChildren();
-
- /**
* Name of the cache node
* @return
*/
Modified: trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -28,9 +28,7 @@
public enum Policy {
LRU, // Least Recently Used
- FIFO, // First in First Out
- LFU, // Least frequently Used
- EXPIRATION; // expires after certain time.
+ EXPIRATION
}
private Policy policy;
Modified: trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -24,91 +24,186 @@
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.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
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;
+ public static final int DEFAULT_MAX_AGE = 1000 * 60 * 60 * 2;
- Map<K, V> map;
- Map<String, Cache> children = new HashMap();
- String name;
+ private static class ExpirationEntry<K, V> {
+ long expiration;
+ K key;
+ V value;
+
+ public ExpirationEntry(long expiration, K key, V value) {
+ this.expiration = expiration;
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof ExpirationEntry<?, ?>)) {
+ return false;
+ }
+ ExpirationEntry<K, V> other = (ExpirationEntry<K, V>)obj;
+ return this.key.equals(other.key);
+ }
+ }
+ protected LRUCache<K, ExpirationEntry<K, V>> map;
+ protected Map<String, Cache> children = new ConcurrentHashMap<String, Cache>();
+ protected String name;
+ protected long ttl;
+ protected LinkedHashSet<ExpirationEntry<K, V>> expirationQueue = new LinkedHashSet<ExpirationEntry<K, V>>();
+
public DefaultCache(String name) {
- this(name, DEFAULT_MAX_SIZE_TOTAL);
+ this(name, DEFAULT_MAX_SIZE_TOTAL, 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));
+ public DefaultCache(String name, int maxEntries, long ttl) {
+ this.map = new LRUCache<K, ExpirationEntry<K, V>>(maxEntries) {
+ @Override
+ protected boolean removeEldestEntry(java.util.Map.Entry<K, ExpirationEntry<K, V>> eldest) {
+ if (super.removeEldestEntry(eldest)) {
+ Iterator<ExpirationEntry<K, V>> iter = expirationQueue.iterator();
+ return validate(iter.next()) != null;
+ }
+ return false;
+ }
+ };
+
this.name = name;
+ this.ttl = ttl;
}
public void addListener(CacheListener listener) {
+ throw new UnsupportedOperationException();
}
public void clear() {
- map.clear();
+ synchronized (map) {
+ map.clear();
+ expirationQueue.clear();
+ }
}
public V get(K key) {
- return map.get(key);
+ synchronized (map) {
+ ExpirationEntry<K, V> result = map.get(key);
+ if (result != null) {
+ return validate(result);
+ }
+ return null;
+ }
}
+ private V validate(ExpirationEntry<K, V> result) {
+ if (result.expiration < System.currentTimeMillis()) {
+ remove(result.key);
+ return null;
+ }
+ return result.value;
+ }
+
public Set<K> keySet() {
- return map.keySet();
+ synchronized (map) {
+ return new HashSet<K>(map.keySet());
+ }
}
public V put(K key, V value) {
- return map.put(key, value);
+ return this.put(key, value, ttl);
}
+
+ public static long getExpirationTime(long defaultTtl, Long ttl) {
+ if (ttl == null) {
+ ttl = defaultTtl;
+ }
+ if (ttl < 0) {
+ return Long.MAX_VALUE;
+ }
+ return System.currentTimeMillis() + ttl;
+ }
+
+ public V put(K key, V value, Long timeToLive) {
+ synchronized (map) {
+ ExpirationEntry<K, V> entry = new ExpirationEntry<K, V>(getExpirationTime(ttl, timeToLive), key, value);
+ expirationQueue.add(entry);
+ ExpirationEntry<K, V> result = map.put(key, entry);
+ if (result != null) {
+ return result.value;
+ }
+ return null;
+ }
+ }
public V remove(K key) {
- return map.remove(key);
+ synchronized (map) {
+ ExpirationEntry<K, V> entry = new ExpirationEntry<K, V>(-1, key, null);
+ ExpirationEntry<K, V> result = map.put(key, entry);
+ if (result != null) {
+ expirationQueue.remove(entry);
+ return result.value;
+ }
+ return null;
+ }
}
public int size() {
- return map.size();
+ synchronized (map) {
+ return map.size();
+ }
}
public Collection<V> values() {
- return map.values();
+ synchronized (map) {
+ ArrayList<V> result = new ArrayList<V>(map.size());
+ for (ExpirationEntry<K, V> entry : new ArrayList<ExpirationEntry<K, V>>(map.values())) {
+ V value = validate(entry);
+ if (value != null) {
+ result.add(value);
+ }
+ }
+ return result;
+ }
}
- @Override
- public void removeListener() {
- }
-
- @Override
public Cache addChild(String name) {
- if (children.get(name) != null) {
- return children.get(name);
+ Cache c = children.get(name);
+ if (c != null) {
+ return c;
}
- Cache c = new DefaultCache(name);
+ c = new DefaultCache(name, map.getSpaceLimit(), ttl);
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());
+ public Collection<Cache> getChildren() {
+ return children.values();
}
- @Override
public boolean removeChild(String name) {
Object obj = children.remove(name);
return obj != null;
@@ -117,5 +212,6 @@
@Override
public String getName() {
return name;
- }
+ }
+
}
\ No newline at end of file
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-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -39,7 +39,6 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.Assertion;
import org.teiid.dqp.DQPPlugin;
-import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.query.analysis.AnalysisRecord;
@@ -109,7 +108,7 @@
TupleBatch batch = results.getBatch(row);
UUID uuid = java.util.UUID.randomUUID();
batch.preserveTypes();
- cache.put(uuid, batch);
+ cache.put(uuid, batch, this.hint != null?this.hint.getTtl():null);
this.cachedBatches.add(uuid);
}
return true;
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-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -648,7 +648,7 @@
}
//prepared plan cache
- prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory, Cache.Type.PREPAREDPLAN, new CacheConfiguration(Policy.LRU, 60, config.getPreparedPlanCacheMaxCount()));
+ prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory, Cache.Type.PREPAREDPLAN, new CacheConfiguration(Policy.LRU, 60*60*8, config.getPreparedPlanCacheMaxCount()));
prepPlanCache.setBufferManager(this.bufferManager);
//get buffer manager
@@ -657,7 +657,7 @@
this.processWorkerPool = new ThreadReuseExecutor(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
dataTierMgr = new TempTableDataManager(new DataTierManagerImpl(this,
- this.bufferService), this.bufferManager);
+ this.bufferService), this.bufferManager, this.processWorkerPool);
}
public void setBufferService(BufferService service) {
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-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -377,7 +377,7 @@
if (determinismLevel > FunctionMethod.SESSION_DETERMINISTIC) {
LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("RequestWorkItem.cache_nondeterministic", originalCommand)); //$NON-NLS-1$
}
- dqpCore.getRsCache().put(cid, determinismLevel, cr);
+ dqpCore.getRsCache().put(cid, determinismLevel, cr, originalCommand.getCacheHint() != null?originalCommand.getCacheHint().getTtl():null);
}
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-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -70,7 +70,7 @@
if(this.maxSize < 0){
this.maxSize = DEFAULT_MAX_SIZE_TOTAL;
}
- this.localCache = new DefaultCache<CacheID, T>("local", maxSize); //$NON-NLS-1$
+ this.localCache = new DefaultCache<CacheID, T>("local", maxSize, config.getMaxAgeInSeconds()*1000); //$NON-NLS-1$
if (type == Cache.Type.PREPAREDPLAN) {
this.distributedCache = localCache;
@@ -114,17 +114,18 @@
return cacheHit.get();
}
- /**
- * Create PreparedPlan for the given clientConn and SQl query
- */
public void put(CacheID id, int determinismLevel, T t){
+ this.put(id, determinismLevel, t, null);
+ }
+
+ public void put(CacheID id, int determinismLevel, T t, Long ttl){
if (!id.cachable) {
return;
}
if (determinismLevel >= FunctionMethod.SESSION_DETERMINISTIC) {
id.setSessionId(id.originalSessionId);
- this.localCache.put(id, t);
+ this.localCache.put(id, t, ttl);
}
else {
@@ -145,7 +146,7 @@
}
if (insert) {
- this.distributedCache.put(id, t);
+ this.distributedCache.put(id, t, ttl);
}
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -50,7 +50,7 @@
if (criteria instanceof CompareCriteria) {
CompareCriteria cc = (CompareCriteria)criteria;
if (cc.getOperator() == CompareCriteria.NE
- || !(cc.getRightExpression() instanceof Constant) || (cc.getOperator() != CompareCriteria.EQ && i > 0)) {
+ || !(cc.getRightExpression() instanceof Constant)) {
critIter.remove();
continue;
}
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -25,6 +25,9 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executor;
+import java.util.concurrent.FutureTask;
import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.api.exception.query.QueryMetadataException;
@@ -90,16 +93,28 @@
private ProcessorDataManager processorDataManager;
private BufferManager bufferManager;
+
+ private Executor executor;
+ public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager bufferManager) {
+ this(processorDataManager, bufferManager, new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ });
+ }
+
/**
* Constructor takes the "real" ProcessorDataManager that this object will be a proxy to,
* and will pass most calls through to transparently. Only when a request is registered for
* a temp group will this proxy do it's thing.
* @param processorDataManager the real ProcessorDataManager that this object is a proxy to
- */
- public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager bufferManager){
+ */
+ public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager bufferManager, Executor executor){
this.processorDataManager = processorDataManager;
this.bufferManager = bufferManager;
+ this.executor = executor;
}
public TupleSource registerRequest(
@@ -265,12 +280,12 @@
}
}
- private TupleSource registerQuery(CommandContext context,
+ private TupleSource registerQuery(final CommandContext context,
TempTableStore contextStore, Query query)
throws TeiidComponentException, QueryMetadataException,
TeiidProcessingException, ExpressionEvaluationException,
QueryProcessingException {
- GroupSymbol group = query.getFrom().getGroups().get(0);
+ final GroupSymbol group = query.getFrom().getGroups().get(0);
if (!group.isTempGroupSymbol()) {
return null;
}
@@ -278,11 +293,23 @@
boolean remapColumns = !tableName.equalsIgnoreCase(group.getName());
TempTable table = null;
if (group.isGlobalTable()) {
- TempTableStore globalStore = context.getGlobalTableStore();
- MatTableInfo info = globalStore.getMatTableInfo(tableName);
+ final TempTableStore globalStore = context.getGlobalTableStore();
+ final MatTableInfo info = globalStore.getMatTableInfo(tableName);
boolean load = info.shouldLoad();
if (load) {
- loadGlobalTable(context, group, tableName, globalStore, info);
+ if (!info.isValid()) {
+ //blocking load
+ loadGlobalTable(context, group, tableName, globalStore, info);
+ } else {
+ Callable<Integer> toCall = new Callable<Integer>() {
+ @Override
+ public Integer call() throws Exception {
+ return loadGlobalTable(context, group, tableName, globalStore, info);
+ }
+ };
+ FutureTask<Integer> task = new FutureTask<Integer>(toCall);
+ executor.execute(task);
+ }
}
table = globalStore.getOrCreateTempTable(tableName, query, bufferManager, false);
} else {
@@ -308,8 +335,7 @@
private int loadGlobalTable(CommandContext context,
GroupSymbol group, final String tableName,
TempTableStore globalStore, MatTableInfo info)
- throws QueryMetadataException, TeiidComponentException,
- TeiidProcessingException, ExpressionEvaluationException {
+ throws TeiidComponentException, TeiidProcessingException {
LogManager.logInfo(LogConstants.CTX_MATVIEWS, QueryExecPlugin.Util.getString("TempTableDataManager.loading", tableName)); //$NON-NLS-1$
QueryMetadataInterface metadata = context.getMetadata();
Create create = new Create();
@@ -344,10 +370,15 @@
//TODO: if this insert fails, it's unnecessary to do the undo processing
table.insert(ts, table.getColumns());
rowCount = table.getRowCount();
+ } catch (TeiidComponentException e) {
+ LogManager.logError(LogConstants.CTX_MATVIEWS, e, QueryExecPlugin.Util.getString("TempTableDataManager.failed_load", tableName)); //$NON-NLS-1$
+ throw e;
+ } catch (TeiidProcessingException e) {
+ LogManager.logError(LogConstants.CTX_MATVIEWS, e, QueryExecPlugin.Util.getString("TempTableDataManager.failed_load", tableName)); //$NON-NLS-1$
+ throw e;
} finally {
if (rowCount == -1) {
info.setState(MatState.FAILED_LOAD, null);
- LogManager.logInfo(LogConstants.CTX_MATVIEWS, QueryExecPlugin.Util.getString("TempTableDataManager.failed_load", tableName)); //$NON-NLS-1$
} else {
globalStore.swapTempTable(tableName, table);
info.setState(MatState.LOADED, true);
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -61,9 +61,8 @@
for (;;) {
switch (state) {
case NEEDS_LOADING:
- updateTime = System.currentTimeMillis();
case FAILED_LOAD:
- state = MatState.LOADING;
+ setState(MatState.LOADING);
return true;
case LOADING:
if (valid) {
@@ -77,7 +76,7 @@
continue;
case LOADED:
if (ttl >= 0 && System.currentTimeMillis() - updateTime - ttl > 0) {
- state = MatState.LOADING;
+ setState(MatState.LOADING);
return true;
}
return false;
@@ -90,11 +89,15 @@
if (valid != null) {
this.valid = valid;
}
- this.state = state;
- this.updateTime = System.currentTimeMillis();
+ setState(state);
notifyAll();
return oldState;
}
+
+ private void setState(MatState state) {
+ this.state = state;
+ this.updateTime = System.currentTimeMillis();
+ }
public synchronized void setTtl(long ttl) {
this.ttl = ttl;
Added: trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.cache;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestDefaultCache {
+
+ @Test public void testExpiration() throws InterruptedException {
+ DefaultCache<Integer, Integer> cache = new DefaultCache<Integer, Integer>("foo", 2, 50);
+ cache.put(1, 1);
+ Thread.sleep(60);
+ assertNull(cache.get(1));
+ cache.put(2, 2);
+ Thread.sleep(30);
+ cache.put(3, 3);
+ assertNotNull(cache.get(2));
+ Thread.sleep(40);
+ cache.put(4, 4);
+ //preferred to purge 2 instead of 3
+ assertNotNull(cache.get(3));
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/cache/TestDefaultCache.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -96,7 +96,7 @@
CachedResults results = new CachedResults();
results.setResults(tb);
results.setCommand(new Query());
- Cache cache = new DefaultCache("dummy", 250); //$NON-NLS-1$
+ Cache cache = new DefaultCache("dummy"); //$NON-NLS-1$
results.prepare(cache, fbs.getBufferManager());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java 2010-08-14 21:19:46 UTC (rev 2462)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java 2010-08-16 15:47:22 UTC (rev 2463)
@@ -56,6 +56,19 @@
assertFalse(rs.next());
}
+ @Test public void testCacheHintTtl() throws Exception {
+ Statement s = conn.createStatement();
+ s.execute("set showplan on");
+ ResultSet rs = s.executeQuery("/* cache(ttl:50) */ select 1");
+ assertTrue(rs.next());
+ s.execute("set noexec on");
+ rs = s.executeQuery("/* cache(ttl:50) */ select 1");
+ assertTrue(rs.next());
+ Thread.sleep(60);
+ rs = s.executeQuery("/* cache(ttl:50) */ select 1");
+ assertFalse(rs.next());
+ }
+
@Test public void testExecutionProperty() throws Exception {
Statement s = conn.createStatement();
s.execute("set showplan on");
14 years, 4 months
teiid SVN: r2462 - in trunk/documentation: caching-guide/src/main/docbook/en-US and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-08-14 17:19:46 -0400 (Sat, 14 Aug 2010)
New Revision: 2462
Added:
trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml
Removed:
trunk/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml
Modified:
trunk/documentation/caching-guide/pom.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
trunk/documentation/reference/src/main/docbook/en-US/content/architecture.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
Log:
TEIID-168 initial changes to the caching document. corrected the code table section mostly.
Modified: trunk/documentation/caching-guide/pom.xml
===================================================================
--- trunk/documentation/caching-guide/pom.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/caching-guide/pom.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -32,7 +32,7 @@
</dependency>
</dependencies>
<configuration>
- <sourceDocumentName>DataCaching.xml</sourceDocumentName>
+ <sourceDocumentName>main.xml</sourceDocumentName>
<imageResource>
<directory>${basedir}/src/main/docbook/en-US</directory>
<excludes>
@@ -48,11 +48,11 @@
<stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
<finalName>teiid_caching_guide.pdf</finalName>
</format>
- <!-- <format>
+ <format>
<formatName>html_single</formatName>
<stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
<finalName>index.html</finalName>
- </format> -->
+ </format>
<format>
<formatName>html</formatName>
<stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
Deleted: trunk/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -1,53 +0,0 @@
-<?xml version='1.0' encoding="UTF-8"?>
-<!--
-
- JBoss, Home of Professional Open Source.
- Copyright (C) 2008 Red Hat, Inc.
- Licensed to Red Hat, Inc. under one or more contributor
- license agreements. See the copyright.txt file in the
- distribution for a full listing of individual contributors.
-
- 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.
-
--->
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-
-<book>
- <bookinfo>
- <title>Teiid - Scalable Information Integration</title>
- <subtitle>Teiid Caching Guide</subtitle>
- <releaseinfo>&versionNumber;
- </releaseinfo>
- <productnumber>&versionNumber;
- </productnumber>
- <issuenum>1</issuenum>
- <copyright>
- <year>©rightYear;
- </year>
- <holder>©rightHolder;
- </holder>
- </copyright>
- <xi:include href="../../../../../docbook/en-US/legal_notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- </bookinfo>
- <toc />
- <xi:include href="content/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/resultset.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/codetable.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
-</book>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -4,153 +4,77 @@
]>
<chapter id="codetable">
<title>Code Table Caching</title>
- <para>MetaMatrix provides a means of caching small, frequently used
- tables of data. This is referred to as “code table caching” or
- “reference data caching”.</para>
- <para>Code table caching is done by using the lookup scalar function,
- provided as a standard function with MetaMatrix. The lookup function
- provides a way to get a value out of a table when a key value is
+ <para>Teiid provides a short cut to creating an internal materialized view table via the lookup function.</para>
+ <para>The lookup function provides a way to get a value out of a table when a key value is
provided. The function automatically caches all the values in the
referenced table for the specified key/value pairs. The cache is
- created the first time it is used in a particular MetaMatrix process.
+ created the first time it is used in a particular Teiid process.
Subsequent lookups against the same table using the same key and
value columns will use the cached information.</para>
<para>This caching solution is appropriate for integration of
- “reference data” with transactional or operational data. Reference
+ "reference data" with transactional or operational data. Reference
data are static data sets – typically small – which are used very
frequently in most enterprise applications. Examples are ISO country
codes, state codes, and different types of financial instrument
- identifiers. </para>
+ identifiers.</para>
<section>
- <title>Support Summary</title>
- <orderedlist>
- <listitem>
- <para>Caching of small, frequently accessed tables</para>
- </listitem>
- <listitem>
- <para>Administrative clearing of cached tables through command line
- utility</para>
- </listitem>
- </orderedlist>
- </section>
- <section>
<title>User Interaction</title>
<para>This caching mechanism is automatically invoked when the lookup
- scalar function is used. Each time this function is called with a
+ scalar function is used. The lookup function returns a scalar value, so it may be used anywhere an expression is expected. Each time this function is called with a
unique combination of referenced table, key element, and returned
- element (the first 3 arguments to the function), the MetaMatrix
+ element (the first 3 arguments to the function), the Teiid
System caches the entire contents of the table being accessed.
Subsequent lookup function uses with the same combination of
parameters uses the cached table data.</para>
- <para>Note that the use of the lookup function automatically performs
- caching; there is no option to use the lookup function and not
- perform caching. Once the values for a particular lookup are cached,
- they will be used until the cache is cleared through the Console.
- </para>
- <para>Specification:</para>
- <para>The following provides information on the use of the lookup
- function.</para>
- <informaltable frame="all">
- <tgroup cols="3">
- <thead>
- <row>
- <entry>
- <para>Function</para>
- </entry>
- <entry>
- <para>Definition</para>
- </entry>
- <entry>
- <para>Datatype Constraint</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>LOOKUP(codeGroup, returnElement, keyElement, keyValue)
- </para>
- </entry>
- <entry>
- <para>In the lookup group codeGroup, find the row where
- keyElement has the value keyValue and return the associated
- returnElement.</para>
- </entry>
- <entry>
- <para>codeGroup, returnElement, and keyElement must be string
- literals containing metadata identifiers, keyValue datatype must
- match datatype of the keyElement, return datatype matches that
- of returnElement</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <para />
- <para>See the MetaMatrix Query Support Booklet for more information on
- use of the lookup function.</para>
- <para>Examples (can be used wherever scalar literal can be in query):
- </para>
- <para>lookup(‘ISOCountryCodes, ‘CountryName’, ‘CountryCode’, ‘US’)
- </para>
- <para>lookup(‘StatePostalCodes, ‘StateDisplayName’, ‘PostalCode’,
- ‘63131’) </para>
- <para>lookup(‘EmpIDs’, ‘Name’, ‘ID’, ‘m204815’) </para>
+ <para>See the Reference for more information on use of the lookup function.</para>
+ <example>
+ <title>Country Code Lookup</title>
+ <programlisting>lookup(‘ISOCountryCodes, ‘CountryName’, ‘CountryCode’, ‘US’)</programlisting>
+ </example>
</section>
<section>
- <title>Cache Configuration</title>
- <para>Cached lookup groups might consume significant memory. You can
- limit the number and maximum size of these code groups by setting
- properties of the Query Service through the MetaMatrix Console.
- </para>
- <para>The following are the properties that can be set at the query
- service level to control reference data caching.</para>
- <para />
- </section>
- <section>
- <title>Cache Characteristics</title>
- <para>Cache Persistence Mechanism</para>
- <para>Reference tables are persisted in object caches local to
- individual Java processes (virtual machines or VMs). They are
- cached in the VM of the individual query services running on host
- machines. </para>
- <para>Cache Loading Policy</para>
- <para>When a user calls the lookup function for a unique combination
- of table, key element, and returned element, the MetaMatrix System
- caches all key-value pairs of that table for the specified elements.
- </para>
- <para>The MetaMatrix System uses this cached map for all queries, in
- all sessions, that later access this lookup group.</para>
- <para>Cache Operational Policy</para>
- <para>Cached tables are never proactively cleared. They can only be
- cleared through using the svcmgr utility script.</para>
- </section>
- <section>
- <title>Cache Administration</title>
- <para>The lookup cache can be cleared using the svcmgr utility script.
- To clear cached code tables, set expertmode on, and then pass in the
- clearCodeTableCaches argument.</para>
- </section>
- <section>
<title>Limitations</title>
<orderedlist>
<listitem>
- <para>Cached code tables are not tied to specific virtual databases.
- This may result in an error when the same model is used in
- multiple virtual databases while it has bindings to different
- sources of data. This may pose a security issue if a cached code
- table is loaded in the context of one user but then accessed by
- another user who should not have access to that data. [defect
- 11629]</para>
- </listitem>
- <listitem>
<para>The use of the lookup function automatically performs caching;
there is no option to use the lookup function and not perform
- caching. [defect 14445]</para>
+ caching.</para>
</listitem>
+ <listitem>
+ <para>No mechanism is provided to refresh code tables.</para>
+ </listitem>
</orderedlist>
- <para>Cached code tables are never proactively cleared by the Server.
- If a lot of code tables are loaded, or large code tables are loaded,
- the Server’s available memory could be exceeded.</para>
</section>
+ <section>
+ <title>Materialized View Alternative</title>
+ <para>The lookup function is a shortcut to create an internal materialized view. In many situations, it may be better to directly create the analogous materialized view rather than to use a code table.</para>
+ <itemizedlist>
+ <title>Reasons to use a materialized view:</title>
+ <listitem>
+ <para>More control of the possible return columns. Code tables will create a mat view for each key/value pair. If there are multiple return columns it would be better to have a single materialized view.</para>
+ </listitem>
+ <listitem>
+ <para>Proper materialized views have built-in system procedure/table support.</para>
+ </listitem>
+ <listitem>
+ <para>More control of the cache hint.</para>
+ </listitem>
+ <listitem>
+ <para>The ability to use option nocache.</para>
+ </listitem>
+ <listitem>
+ <para>Usage of a materialized view lookup as an uncorrelated subquery is no different than the use of the lookup function.</para>
+ </listitem>
+ </itemizedlist>
+ <orderedlist>
+ <title>Steps to create a materialized view:</title>
+ <listitem>
+ <para>Create a view selecting the appropriate columns from the desired table. In general, this view may have an arbitrarily complicated transformation query.</para>
+ <para>Designate the appropriate column(s) as the primary key.</para>
+ <para>Set the materailized property to true.</para>
+ <para>Add a cache hint to the transformation query. To mimic the behavior of the implicit internal materialized view created by the lookup function, use /*+ cache(pref_mem) */ to indicate that the table data pages should prefer to remain in memory.</para>
+ </listitem>
+ </orderedlist>
+ <para>Just as with the lookup function, the materialized view table will be created on first use and reused subsequently. See the <link linkend="matviews">Materialized View Chapter</link> for more on materialized views.</para>
+ </section>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -4,11 +4,11 @@
]>
<chapter id="matviews">
<title>Materialized Views</title>
- <para>MetaMatrix supports Materialized Views. These are Relational
+ <para>Teiid supports Materialized Views. These are Relational
virtual tables and views (‘virtual groups’) for which the
transformations are pre-computed and the results are stored in an
external database. When queries are issued against these virtual
- groups through the MetaMatrix Server, the cached results are used.
+ groups through the Teiid Server, the cached results are used.
This saves the cost of accessing all the underlying data sources and
re-computing the virtual group transforms each time a query is
executed against the group. </para>
@@ -16,8 +16,8 @@
change rapidly, or when it is acceptable to retrieve data that is
“stale” within some period of time, or when it is preferred for
end-user queries to access staged data rather than placing additional
- query load on operational sources. MetaMatrix provides a utility to
- refresh materialized tables. This utility uses the MetaMatrix batched
+ query load on operational sources. Teiid provides a utility to
+ refresh materialized tables. This utility uses the Teiid batched
update functionality.</para>
<section>
<title>Support Summary</title>
@@ -43,7 +43,7 @@
<title>User Interaction</title>
<para>When client applications issue queries against a Relational
table or view that has been defined as a materialized view, the
- MetaMatrix query engine automatically routes that query to obtain the
+ Teiid query engine automatically routes that query to obtain the
results from the cache database. </para>
<para>Individual queries may override the use of materialized views by
specifying OPTION NOCACHE on the query. This parameter must specify
@@ -94,8 +94,8 @@
then the Materialization physical cache model will not be created or
included in the VDB.</para>
<para>Virtual Database Deployment </para>
- <para>When deploying a virtual database (VDB) in the MetaMatrix
- Console, the MetaMatrix administrator must define connector bindings
+ <para>When deploying a virtual database (VDB) in the Teiid
+ Console, the Teiid administrator must define connector bindings
for all physical models in the VDB. This is true for the well-known
materialization cache model also. In the New VDB or New VDB Version
wizard, the materialization model will show up in the Connector
@@ -103,7 +103,7 @@
appropriate JDBC connector for the data source where the materialized
view cache will reside. </para>
<para>When deploying a VDB containing materialized views, the
- MetaMatrix administrator will be presented with the option to save
+ Teiid administrator will be presented with the option to save
administration scripts to the local file system. This is in the New
VDB, New VDB Version, and Import VDB wizards. The administrator
should save the scripts to a location where they can be accessed by a
@@ -155,7 +155,7 @@
</orderedlist>
<orderedlist>
<listitem>
- <para>Define username and password for connecting to MetaMatrix, to
+ <para>Define username and password for connecting to Teiid, to
issue insert commands against the virtual groups during loading and
reloading.</para>
</listitem>
@@ -190,10 +190,10 @@
<para>Cache Persistence Mechanism</para>
<para>Materialized views cache their data in an external database
system. This database may be the same as the database used as the
- MetaMatrix repository, or it may be a different one. In general it
- is recommended that the MetaMatrix repository not be used for
+ Teiid repository, or it may be a different one. In general it
+ is recommended that the Teiid repository not be used for
materialized view caching, as heavy use could impact the performance
- of other core functionality of the MetaMatrix Server. </para>
+ of other core functionality of the Teiid Server. </para>
<para>The following DBMS systems are supported for this purpose:
</para>
<orderedlist>
@@ -209,18 +209,18 @@
</orderedlist>
<para>Cache Operational Policy</para>
<para>Since the actual physical cache for materialized views is
- maintained external to the MetaMatrix system, there is no pre-defined
+ maintained external to the Teiid system, there is no pre-defined
policy for clearing and managing the cache. These policies will be
- defined and enforced by administrators of the MetaMatrix system.
+ defined and enforced by administrators of the Teiid system.
</para>
<para>Cache Administration</para>
<para>The cache used by materialized views is administered external to
- MetaMatrix. This provides a great deal of flexibility on how that
+ Teiid. This provides a great deal of flexibility on how that
cache is managed, refreshed, backed up, and otherwise administered
along with other enterprise sources.</para>
<para>Administrator Responsibilities</para>
<para>These are the responsibilities of administrators with respect to
- MetaMatrix’s materialized view data caching.</para>
+ Teiid’s materialized view data caching.</para>
<informaltable frame="all">
<tgroup cols="3">
<colspec colnum="1" colname="c1" />
@@ -238,7 +238,7 @@
<para>Required Rights for Cache Database</para>
</entry>
<entry>
- <para>Required Rights for MetaMatrix</para>
+ <para>Required Rights for Teiid</para>
</entry>
<entry>
<para>Scripts Used</para>
@@ -272,7 +272,7 @@
<para>Initially populate cache </para>
</entry>
<entry>
- <para>Cache database and MetaMatrix</para>
+ <para>Cache database and Teiid</para>
</entry>
<entry>
<para>Alter, Insert</para>
@@ -294,7 +294,7 @@
<para>Refresh cache </para>
</entry>
<entry>
- <para>Cache database and MetaMatrix</para>
+ <para>Cache database and Teiid</para>
</entry>
<entry>
<para>Alter, Insert </para>
@@ -318,14 +318,14 @@
<para>The refresh cache operation is recurring, basically at whatever
frequency is appropriate for maintaining the desired data “freshness”
for the VDB version. This operation can be scheduled to execute the
- MetaMatrix scripts, using standard scheduling mechanisms such as cron
+ Teiid scripts, using standard scheduling mechanisms such as cron
on UNIX or the Windows scheduler.</para>
<para>The truncate and swap scripts are used in the initial load. The
truncate is a no-op in this case, and the swap happens because data
is always loaded to the staging table, which must then be swapped
with the real cache table. </para>
- <para>MetaMatrix Administrative Scripts</para>
- <para>To perform the administrative operations, MetaMatrix provides a
+ <para>Teiid Administrative Scripts</para>
+ <para>To perform the administrative operations, Teiid provides a
set of 4 scripts. Here is a summary of the scripts. All the scripts
use a similar template for their file names:
VDBName_VDBVersion_Name.ddl).</para>
@@ -395,7 +395,7 @@
results into cache</para>
</entry>
<entry>
- <para>MetaMatrix</para>
+ <para>Teiid</para>
</entry>
<entry>
<para>Access user</para>
@@ -422,108 +422,5 @@
</tbody>
</tgroup>
</informaltable>
- <para />
- <para>In addition to these scripts, MetaMatrix provides a connection
- properties file with encrypted passwords.</para>
- <para>Materialized Database Creation</para>
- <para>The cache for materialized views is maintained in a separate
- database system. Therefore, tables must be defined in the database
- to hold the cached information for the materialized views in a VDB.
- Materialized views are scoped to a specific VDB version. Therefore,
- the cache tables should in general be segregated in the cache
- database by VDB and version. It is the responsibility of the
- MetaMatrix and database administrators to ensure that the database is
- defined appropriately for the VDB version, and to ensure that two
- users are created with the appropriate privileges:</para>
- <orderedlist>
- <listitem>
- <para>Script user – Used when executing Create/Truncate/Swap scripts
- [note used for Load scripts, since that executes directly against
- MetaMatrix with MetaMatrix user info]. Requires create/load/alter
- privileges against the materialized view tables in the database.
- </para>
- </listitem>
- <listitem>
- <para>Access user – Used in connector binding definition both when
- reading the cache for user queries, and when refreshing the cache
- using the Load script. Requires read and insert privileges against
- the materialized view tables in the database. </para>
- </listitem>
- </orderedlist>
- <para>MetaMatrix provides a DDL script to create all the materialized
- tables for a VDB. This script is DBMS-specific. When deploying a
- VDB, the type of the DBMS is determined from the connector binding
- used for the materialization physical model, and the appropriate
- script for that DBMS is extracted from the VDB and saved to the local
- file system. </para>
- <para>Script name: <VDBName>_<VDBVersion>_Create.ddl
- </para>
- <para>Example for “CustomerInfo” VDB, version 7:
- CustomerInfo_7_Create.ddl </para>
- <para>The create script is a standard DDL script that can be executed
- against the DBMS system using whatever mechanisms it supports. The
- script must be executed against a database schema/catalog with the
- appropriate privileges as specified in the MetaMatrix Console. </para>
- <para>Materialized Database Loading</para>
- <para>MetaMatrix provides a set of 3 scripts to initially populate and
- subsequently reload (“refresh”) all the materialized tables for a
- VDB. These scripts are DBMS-specific. They are extracted from the
- VDB when deploying that VDB, and saved by an administrator to the
- local file system. These scripts all assume that the cache tables
- have been created, using the “Create” script described above.</para>
- <para>These three scripts do the following for each materialized view:
- </para>
- <orderedlist>
- <listitem>
- <para>Truncate records in a temporary table (executed directly
- against DBMS)</para>
- </listitem>
- <listitem>
- <para>Load – execute query against virtual group, and insert into
- temporary table (executed against MetaMatrix)</para>
- </listitem>
- <listitem>
- <para>Swap temporary table with cache table (executed directly
- against DBMS)</para>
- </listitem>
- </orderedlist>
- <para>The second script uses the MetaMatrix batched inserts
- functionality. Therefore, the MetaMatrix Server must be running, and
- the VDB must be deployed and activated. The queries that are
- executed all use the “cache override” option, so that the
- transformations are executed. </para>
- <para>The first and third scripts execute DBMS-specific operations, to
- more efficiently update the cache records. These scripts are
- standard DDL scripts that can be executed against the DBMS system
- using whatever mechanisms it supports. The scripts must be executed
- against a database schema/catalog with the appropriate privileges as
- specified in the MetaMatrix Console. </para>
- <para>The three scripts can be executed together to perform initial
- loading and subsequent refresh. This can be done using the
- loadscript.cmd (.sh on UNIX) command script, located in the server
- materializedviews directory. This script can be used to schedule
- database loading activities. </para>
</section>
- <section>
- <title>Limitations</title>
- <orderedlist>
- <listitem>
- <para>Materialization works only with Relational tables and views.
- It does not work with Data Access virtual groups or procedures.
- </para>
- </listitem>
- <listitem>
- <para>A user cannot specify OPTION NOCACHE on virtual groups that
- are not at the top level (in the user query). The design does not
- currently support this.</para>
- </listitem>
- </orderedlist>
- </section>
- <section>
- <title>Outstanding Issues</title>
- <para>Specifying OPTION NOCACHE within a transformation query is the
- same as specifying it a user query – the identified virtual groups
- will always be re-computed in the context of the virtual group
- containing the transformation query with the override option.</para>
- </section>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -4,184 +4,14 @@
]>
<chapter id="overview">
<title>Overview</title>
- <para>Teiid provides three capabilities for caching
- data: materialized views, result set caching, and code table caching.
+ <para>Teiid provides several capabilities for caching
+ data including: materialized views, result set caching, and code table caching.
These can be used to significantly improve performance in many
situations. </para>
- <para>Following is a summary comparison of these three data caching
- options.</para>
- <informaltable frame="all">
- <tgroup cols="4">
- <tbody>
- <row>
- <entry>
- <para />
- </entry>
- <entry>
- <para>Materialized Views</para>
- </entry>
- <entry>
- <para>Result Set Caching</para>
- </entry>
- <entry>
- <para>Code Table Caching</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Best For</para>
- </entry>
- <entry>
- <para>Complex transformations</para>
- </entry>
- <entry>
- <para>Complex frequently issued user queries</para>
- </entry>
- <entry>
- <para>Key based lookups on small, frequently accessed tables</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Data Change Rate</para>
- </entry>
- <entry>
- <para>Static</para>
- </entry>
- <entry>
- <para>Static</para>
- </entry>
- <entry>
- <para>Static</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Data Size</para>
- </entry>
- <entry>
- <para>Any size</para>
- </entry>
- <entry>
- <para>Small-Medium</para>
- </entry>
- <entry>
- <para>Small</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Defined By</para>
- </entry>
- <entry>
- <para>External scripts</para>
- </entry>
- <entry>
- <para>Query execution</para>
- </entry>
- <entry>
- <para>Scalar function (lookup) execution</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Scope</para>
- </entry>
- <entry>
- <para>VDB</para>
- </entry>
- <entry>
- <para>VDB or session</para>
- </entry>
- <entry>
- <para>VDB within Query service</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Key</para>
- </entry>
- <entry>
- <para />
- </entry>
- <entry>
- <para>Based upon the user query</para>
- </entry>
- <entry>
- <para>VDB + table + key column + value column</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Removal Policy</para>
- </entry>
- <entry>
- <para>None (discretion of administrator)</para>
- </entry>
- <entry>
- <para>Least-recently used removed first</para>
- </entry>
- <entry>
- <para>None (discretion of administrator)</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Configuration</para>
- </entry>
- <entry>
- <para>Model properties</para>
- </entry>
- <entry>
- <para>DQP Configuration</para>
- </entry>
- <entry>
- <para>DQP Configuration</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Administration</para>
- </entry>
- <entry>
- <para>External to Teiid</para>
- </entry>
- <entry>
- <para></para>
- </entry>
- <entry>
- <para></para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Access Method</para>
- </entry>
- <entry>
- <para>Query against materialized view</para>
- </entry>
- <entry>
- <para>Query with caching enabled</para>
- </entry>
- <entry>
- <para>Query containing scalar “lookup” function</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>User Override?</para>
- </entry>
- <entry>
- <para>Yes</para>
- </entry>
- <entry>
- <para>Yes</para>
- </entry>
- <entry>
- <para>No – must explicitly specify whether to use</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
+
+ <section id="cache_hint">
+ <title>Cache Hint</title>
+ <para>Non-update user commands may be preceded with a cache hint, e.g. /*+ cache */ select ..., to inform the engine that the results of command should be cached. The scope of the result, either session or global, will be deteremined automatically from the determinism level of the source queries and functions executed.</para>
+ <para>ResultSet caching must be enabled for this hint to have an effect.</para>
+ </section>
</chapter>
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -4,11 +4,11 @@
]>
<chapter id="resultset">
<title>Result Set Caching</title>
- <para>MetaMatrix provides the capability to store the results of
- specific queries. MetaMatrix can be configured to store the results
+ <para>Teiid provides the capability to store the results of
+ specific queries. Teiid can be configured to store the results
for end-user queries, or to cache the results of atomic queries issued
to data sources in response to end-user queries, or both. When the
- exact same user query is submitted to the MetaMatrix Server, the
+ exact same user query is submitted to the Teiid Server, the
cached results will be returned. Similarly, if the exact same atomic
query is encountered while processing an end-user query, the cached
results will be used in processing that query, even if the end-user
@@ -62,8 +62,8 @@
</section>
<section>
<title>Cache Configuration</title>
- <para>Result set caching in the MetaMatrix Server is configured in the
- MetaMatrix Console. By default, result set caching is disabled.
+ <para>Result set caching in the Teiid Server is configured in the
+ Teiid Console. By default, result set caching is disabled.
When enabled, the default caching scope is restricted to a
particular VDB.</para>
<para>Result set caching can be enabled and configured in two places:
@@ -71,7 +71,7 @@
<orderedlist>
<listitem>
<para>End-user queries – In Configuration Deployment panel,
- QueryEngine PSC, QueryService properties (per MetaMatrix process)
+ QueryEngine PSC, QueryService properties (per Teiid process)
</para>
</listitem>
<listitem>
@@ -229,7 +229,7 @@
</listitem>
<listitem>
<para>Caches are not distributed; they are bound to a particular
- MetaMatrix process. So, if the same query is routed to two
+ Teiid process. So, if the same query is routed to two
different host machines, the query will be executed twice, and
cached independently on each machine. </para>
</listitem>
Copied: trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml (from rev 2450, trunk/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml)
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml (rev 0)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -0,0 +1,53 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!--
+
+ JBoss, Home of Professional Open Source.
+ Copyright (C) 2008 Red Hat, Inc.
+ Licensed to Red Hat, Inc. under one or more contributor
+ license agreements. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ 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.
+
+-->
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+
+<book>
+ <bookinfo>
+ <title>Teiid - Scalable Information Integration</title>
+ <subtitle>Teiid Caching Guide</subtitle>
+ <releaseinfo>&versionNumber;
+ </releaseinfo>
+ <productnumber>&versionNumber;
+ </productnumber>
+ <issuenum>1</issuenum>
+ <copyright>
+ <year>©rightYear;
+ </year>
+ <holder>©rightHolder;
+ </holder>
+ </copyright>
+ <xi:include href="../../../../../docbook/en-US/legal_notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ </bookinfo>
+ <toc />
+ <xi:include href="content/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <!-- <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> -->
+ <xi:include href="content/resultset.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/codetable.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+</book>
\ No newline at end of file
Property changes on: trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/architecture.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/architecture.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/architecture.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -23,9 +23,7 @@
<itemizedlist>
<listitem>
<para>Session – the Session service manages active
- session information. Active sessions are stored in a
- distributed cache and shared between Session services in each
- VM.
+ session information.
</para>
</listitem>
<listitem>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -1777,7 +1777,16 @@
<para>The Lookup function allows you to cache a key value pair table and access it through a scalar function. This caching
accelerates response time to queries that use the lookup tables, known
in business terminology as lookup tables or code tables.</para>
- <para>A StatePostalCodes table used to translate postal codes to
+ <para><synopsis>LOOKUP(codeTable, returnColumn, keyColumn, keyValue)</synopsis></para>
+ <para>In the lookup table codeTable, find the row where
+ keyColumn has the value keyValue and return the
+ associated returnColumn. codeTable must be a fully-qualified string
+ literal containing metadata identifiers, keyValue datatype
+ must match datatype of the keyColumn, return datatype
+ matches that of returnColumn. returnColumn and
+ keyColumn parameters should use their shortened names.
+ </para>
+ <para>For example, a StatePostalCodes table used to translate postal codes to
complete state names might represent an example of this type of
lookup table. One column, PostalCode, represents a key column.
Other tables refer to this two-letter code. A
@@ -1788,10 +1797,7 @@
<para>When you call this function for any combination of codeTable, returnColumn, and
keyColumn for the first time, the Teiid System caches the result.
The Teiid System uses this cache for all
- queries, in all sessions, that later access this lookup table. The
- codeTable requires use of the fully-qualified name, and the
- returnColumn and keyColumn parameters should use shortened column
- names.</para>
+ queries, in all sessions, that later access this lookup table.</para>
<para>The Teiid System unloads these cached lookup tables when you stop and restart
the Teiid System. Thus, you should not use this function for
data that is subject to updates. Instead, you can use it against
@@ -1799,49 +1805,11 @@
<note>
<itemizedlist>
<listitem>
- <para>The keyColumn is expected to contain unique key
+ <para>The keyColumn is expected to contain unique
values. If the column contains duplicate values, an exception will be thrown.</para>
</listitem>
</itemizedlist>
</note>
- <informaltable frame="all">
- <tgroup cols="3">
- <thead>
- <row>
- <entry>
- <para>Function</para>
- </entry>
- <entry>
- <para>Definition</para>
- </entry>
- <entry>
- <para>Datatype Constraint</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>LOOKUP(codeTable, returnColumn,
- keyColumn, keyValue)</para>
- </entry>
- <entry>
- <para>In the lookup table codeTable, find the row where
- keyColumn has the value keyValue and return the
- associated returnColumn</para>
- </entry>
- <entry>
- <para>codeTable must be a fully-qualified string
- literal containing metadata identifiers, keyValue datatype
- must match datatype of the keyColumn, return datatype
- matches that of returnColumn. returnColumn and
- keyColumn parameters should use their shortened names.
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
</section>
<section>
<title>System Functions</title>
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-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -560,11 +560,6 @@
</listitem>
</itemizedlist>
</section>
- <section id="cache_hint">
- <title>Cache Hint</title>
- <para>Non-update user commands may be preceded with a cache hint, e.g. /*+ cache */ select ..., to inform the engine that the results of command should be cached. The scope of the result, either session or global, will be deteremined automatically from the determinism level of the source queries and functions executed.</para>
- <para>ResultSet caching must be enabled for this hint to have an effect.</para>
- </section>
<section id="procedural_relational">
<title>Procedural Relational Command</title>
<para> Procedural relational commands use the syntax of a SELECT to
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-08-13 17:35:16 UTC (rev 2461)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-08-14 21:19:46 UTC (rev 2462)
@@ -137,7 +137,7 @@
<para><emphasis>metamatrix</emphasis> - for use with MetaMatrix 5.5.0 or later.</para>
</listitem>
<listitem>
-<para><emphasis>mysql</emphasis>/<emphasis>mysql5</emphasis> - for use with MySQL version 4.x and 5 or later respectively. <note>The MySQL Translators expect the database or session to be using ANSI mode. If the database is not using ANSI mode, an initialization query should be used on the pool to set ANSI mode: <programlisting>set SESSION sql_mode = 'ANSI'</programlisting></note></para>
+<para><emphasis>mysql</emphasis>/<emphasis>mysql5</emphasis> - for use with MySQL version 4.x and 5 or later respectively. <note><para>The MySQL Translators expect the database or session to be using ANSI mode. If the database is not using ANSI mode, an initialization query should be used on the pool to set ANSI mode: <programlisting>set SESSION sql_mode = 'ANSI'</programlisting></para></note></para>
</listitem>
<listitem>
<para><emphasis>oracle</emphasis> - for use with Oracle 9i or later. Sequences may be used with the Oracle translator.
14 years, 4 months
teiid SVN: r2461 - trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-08-13 13:35:16 -0400 (Fri, 13 Aug 2010)
New Revision: 2461
Modified:
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
Log:
TEIID-1207: adding source not required tag
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-08-13 15:42:17 UTC (rev 2460)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-08-13 17:35:16 UTC (rev 2461)
@@ -68,6 +68,11 @@
return YAHOO_MAX_SET_SIZE;
}
+ @Override
+ public boolean isSourceRequired() {
+ return false;
+ }
+
@Override
public void getMetadata(MetadataFactory metadataFactory, Object connection) throws TranslatorException {
Table t = metadataFactory.addTable("Stock"); //$NON-NLS-1$
14 years, 4 months
teiid SVN: r2460 - in trunk: connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-08-13 11:42:17 -0400 (Fri, 13 Aug 2010)
New Revision: 2460
Modified:
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/README.txt
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
Log:
TEIID-1207: adding metadata for dynamic vdb scenarios
Modified: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/README.txt
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/README.txt 2010-08-13 12:06:36 UTC (rev 2459)
+++ trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/README.txt 2010-08-13 15:42:17 UTC (rev 2460)
@@ -17,7 +17,7 @@
Use the simple client example run script, or another client, to execute a query, e.g.
-$./run.sh localhost 31000 dynamicportfolio "select * from product, (call MarketData.getTextFiles('*.txt')) f, TEXTTABLE(f.file COLUMNS symbol string, price bigdecimal HEADER) price where product.symbol=price.symbol"
+$./run.sh localhost 31000 dynamicportfolio "select * from product, (call MarketData.getTextFiles('*.txt')) f, TEXTTABLE(f.file COLUMNS symbol string, price bigdecimal HEADER) stock where product.symbol=stock.symbol"
This example will execute the query against both Derby and the text files. The
files returned from the getTextFiles procedure are passed to the TEXTTABLE table
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java 2010-08-13 12:06:36 UTC (rev 2459)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java 2010-08-13 15:42:17 UTC (rev 2460)
@@ -268,7 +268,7 @@
List output = new ArrayList(neededColumns.length);
for(int i=0; i<neededColumns.length; i++) {
- output.add(row.get(neededColumns[i]));
+ output.add(row.get(neededColumns[i]-1));
}
return output;
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-08-13 12:06:36 UTC (rev 2459)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-08-13 15:42:17 UTC (rev 2460)
@@ -22,17 +22,21 @@
package org.teiid.translator.yahoo;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.language.QueryExpression;
import org.teiid.language.Select;
+import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.Translator;
-import org.teiid.translator.TranslatorException;
+import org.teiid.metadata.Table;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
@Translator(name="yahoo")
public class YahooExecutionFactory extends ExecutionFactory<Object, Object> {
@@ -63,4 +67,20 @@
public int getMaxInCriteriaSize() {
return YAHOO_MAX_SET_SIZE;
}
+
+ @Override
+ public void getMetadata(MetadataFactory metadataFactory, Object connection) throws TranslatorException {
+ Table t = metadataFactory.addTable("Stock"); //$NON-NLS-1$
+ metadataFactory.addColumn("symbol", DataTypeManager.DefaultDataTypes.STRING, t); //$NON-NLS-1$
+ metadataFactory.addColumn("last", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ metadataFactory.addColumn("date", DataTypeManager.DefaultDataTypes.DATE, t); //$NON-NLS-1$
+ metadataFactory.addColumn("time", DataTypeManager.DefaultDataTypes.TIME, t); //$NON-NLS-1$
+ metadataFactory.addColumn("change", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ metadataFactory.addColumn("open", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ metadataFactory.addColumn("high", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ metadataFactory.addColumn("low", DataTypeManager.DefaultDataTypes.DOUBLE, t); //$NON-NLS-1$
+ metadataFactory.addColumn("volume", DataTypeManager.DefaultDataTypes.BIG_INTEGER, t); //$NON-NLS-1$
+ metadataFactory.addAccessPattern("needs_symbol", Arrays.asList("symbol"), t); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
14 years, 4 months
teiid SVN: r2459 - in trunk: test-integration/common/src/test/java/org/teiid/jdbc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-08-13 08:06:36 -0400 (Fri, 13 Aug 2010)
New Revision: 2459
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java
Log:
TEIID-1206 fix for npe
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-08-12 17:32:44 UTC (rev 2458)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-08-13 12:06:36 UTC (rev 2459)
@@ -355,7 +355,7 @@
}
processor = request.processor;
resultsBuffer = processor.createTupleBuffer();
- if (this.cid != null) {
+ if (this.cid != null && originalCommand.getCacheHint() != null) {
resultsBuffer.setPrefersMemory(originalCommand.getCacheHint().getPrefersMemory());
}
collector = new BatchCollector(processor, resultsBuffer) {
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java 2010-08-12 17:32:44 UTC (rev 2458)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java 2010-08-13 12:06:36 UTC (rev 2459)
@@ -44,7 +44,7 @@
conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCache() throws Exception {
+ @Test public void testCacheHint() throws Exception {
Statement s = conn.createStatement();
s.execute("set showplan on");
ResultSet rs = s.executeQuery("/* cache */ select 1");
@@ -56,4 +56,18 @@
assertFalse(rs.next());
}
+ @Test public void testExecutionProperty() throws Exception {
+ Statement s = conn.createStatement();
+ s.execute("set showplan on");
+ s.execute("set resultSetCacheMode true");
+ ResultSet rs = s.executeQuery("select 1");
+ assertTrue(rs.next());
+ s.execute("set noexec on");
+ rs = s.executeQuery("select 1");
+ assertTrue(rs.next());
+ s.execute("set resultSetCacheMode false");
+ rs = s.executeQuery("select 1");
+ assertFalse(rs.next());
+ }
+
}
14 years, 4 months