h1. {*}Object Translator{*} |
The Object translator, known by the name of _map-cache_, is a bridge for reading and writing java objects from external sources (i.e., Infinispan Cache or Map cache) and delivering them to the engine for processing. And to assist in providing that bridge, the [OBJECTTABLE] function can be used to transform complex java objects into rows and columns. |
|
The following are the translator types supported by the Object Translator: * _infinispan-cache_ * _map-cache_ |
h2. {*}Search Capabilities{*} |
|
h2. {*}_map-cache_{*} |
Supports a local cache that is of type Map and it uses _key_ searching on the map to find objects. |
... |
* CompareCriteria - only EQ * InCriteria |
* Insert, Update and Delete |
|
Currently only supports read only. |
|
h2. {*}_infinispan-cache_{*} Supports Infinispan/JDG cache and has the options for using either DSL searching (JDG 6.3+), Hibernate/Lucene searching, or Key searching (when no indexing is used). See the [jdg-local-cache|https://docs.jboss.org/author/display/teiidexamples/JBoss+Data+Grid+%28JDG%29+running+in+Library+Mode+as+a+Data+Source+Example] quick start for an example. Note, this assumes you will be installing JDG into the same server installation, running in library mode. h3. Installation The *infinispan-cache* translator is not configured, out-of-the-box, in the standalone-teiid.xml configuration. To configure the translator, run the [add-infinispan-cache-translator.cli | https://github.com/teiid/teiid/blob/master/build/kits/jboss-as7/docs/teiid/datasources/infinispan/add-infinispan-cache-translator.cli] script. This script can also be found in the teiid-jboss-dist.zip kit, under docs/teiid/datasources/infinispan. h3. Execution Properties || Name || Description || Required || Default || | SupportsLuceneSearching | Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache | No | false | | SupportsDSLSearching | Setting to true assumes your are using JDG v6.3 or better and your cache has indexing enabled | No | false | | SupportsIsNullCriteria | Setting to true assumes [https://issues.jboss.org/browse/TEIID-3573] has been resolved | No | false | | SupportsCompareCriteriaOrdered | Setting to true assumes [https://issues.jboss.org/browse/TEIID-3627] has been resolved | No | false | | SupportsNotCriteria | Setting to true assumes [https://issues.jboss.org/browse/TEIID-3573] has been resolved | No | false | h3. Supported Capabilities The following are the connector capabilities when Key Searching is used: * SELECT command * CompareCriteria - only EQ * InCriteria The following are the connector capabilities when Hibernate/Lucene Searching is enabled: * SELECT command * CompareCriteria - EQ, NE, LT, GT, etc. * And/Or Criteria * In Criteria * Like Criterai * Or Criteria * INSERT, UPDATE, DELETE |
h2. Usage |
... |
<vdb name="team" version="1"> <model name="Team" visible="false"> |
<source name="objsource" translator-name="infinispan1" connection-jndi-name="java:infinispan-jndi"/> |
<source name="objsource" translator-name="map-cache" connection-jndi-name="java:cache-jndi"/> |
<metadata type="DDL"><![CDATA[ |
... |
</model> |
<translator name="infinispan1" type="infinispan-cache"> <property name="SupportsLuceneSearching" value="true"/> </translator> |
</vdb> {code} |
... |
h3. {*}JCA Resource Adapter{*} |
See the Infinispan Datasources resource adapter for this translator. It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName or RemoteServerList). |
The Object translator, known by the name of map-cache, is a bridge for reading and writing java objects from external sources (i.e., Map cache) and delivering them to the engine for processing. And to assist in providing that bridge, the OBJECTTABLE function can be used to transform complex java objects into rows and columns.
Supports a local cache that is of type Map and it uses key searching on the map to find objects.
The following are the connector capabilities when Key Searching is used:
The following is an example of a key search and a view that associated player names with their team. It uses a dynamic vdb to define the physical source and views using DDL. It uses a TeamObject class, shown below, with a teamName field that is used as its cache key and a String list of players.
public class TeamObject { private String teamName; private List<String> players = new ArrayList<String>(); public String getTeamName() { return teamName; } public void setTeamName(String teamName) { this.teamName = teamName; } public List<String> getPlayers() { return players; } }
Note that by just using a dynamic vdb, the native import logic will provide you with a TeamObject physical table that can be queried. An equivalent Team table is shown here for demonstration purposes.
<vdb name="team" version="1"> <model name="Team" visible="false"> <source name="objsource" translator-name="map-cache" connection-jndi-name="java:cache-jndi"/> <metadata type="DDL"><![CDATA[ CREATE FOREIGN TABLE Team ( TeamObject Object OPTIONS (NAMEINSOURCE 'this', SEARCHABLE 'Unsearchable'), teamName varchar(255) PRIMARY KEY) OPTIONS (NAMEINSOURCE 'teams'); ]]> </metadata> </model> <model name="TeamView" type="VIRTUAL"> <metadata type="DDL"><![CDATA[ CREATE VIEW Players ( TeamName varchar(255) PRIMARY KEY, PlayerName varchar(255) ) AS SELECT t.TeamName, y.Name FROM Team as T, OBJECTTABLE('m.players' PASSING T.TeamObject as m COLUMNS Name string 'teiid_row') as y; ]]> </metadata> </model> </vdb>
Notice the use of the OBJECTABLE function to parse the object from Team and transform into rows and column. This is only for demonstration purposes, and is not required in order to parse the object into rows and columns.
This metadata could also be defined by using the Teiid Designer Teiid Connection Importer.