h1. {color:#000000}{*}Object Translator{*}{color} |
h1. {*}Object Translator{*} |
|
{color:#333333}The Object translator is a bridge for reading 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 {color}[OBJECTTABLE] function must be used to transform the java object into rows and columns. |
|
{color:#333333}The following are the translator types and their respective supported data source:{color} |
* _infinispan-cache_ \- supports Infinispan cache and using either Key searching (for non-annotated objects) or Hibernate/Lucene searching * _map-cache_ \- supports a local cache that is of type Map and using Key searching |
{color:#333333}{*}Execution Properties \- infinispan-cache{*}{color} || {color:#000000}Name{color} || {color:#000000}Description{color} || {color:#333333}Required{color} || {color:#000000}Default{color} || |
{*}Execution Properties \- infinispan-cache{*} || Name || Description || Required || Default || |
| {color:#333333}SupportsLuceneSearching{color} SupportsLuceneSearching | {color:#333333}Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache{color} | {color:#333333}N{color} N | {color:#333333}false{color} false | |
|
h3. {color:#000000}{*}Supported Capabilities{*}{color} |
h3. {*}Supported Capabilities{*} |
|
{color:#333333}The following are the connector capabilities when Key Searching is used:{color} |
* SELECT command * CompareCriteria - only EQ * InCriteria |
{color:#333333}The following are the connector capabilities when Hibernate/Lucene Searching is enabled:{color} |
* SELECT command * CompareCriteria - EQ, NE, LT, GT, etc. |
... |
* OrCriteria |
h3. {color:#000000}{*}Usage{*}{color} {*}Usage{*} |
|
{color:#333333}Retrieve objects from a cache and transform into rows and columns.{color} |
* The primary object returned by the cache should have a name in source of 'this'. All other columns will have their name in source (which defaults to the column name) interpreted as the path to the column value from the primary object. * All columns that are not the primary key nor covered by a lucene index should be marked as SEARCHABLE 'Unsearchable'. |
* Dynamic VDBs using metadata import will automatically determine a phsyical table for each root object and will have each top level member represented as a column. |
|
{color:#333333}The following is an example of a key search. 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. {color} |
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. |
{code:java} public class TeamObject { |
... |
} {code} |
{color:#333333}Notice the use of the {color}{color:#005e8f}\[{color}{color:#005e8f}OBJECTABLE{color}\|TEIID:OBJECTABLE\] function to parse the object from Team and transform into rows and column. This metadata could also be defined by using Teiid Designer. |
Note that by just using a dynamic vdb native import logic will provide you with a TeamObject physical table. An equivalent Team table is shown here for demonstration purposes. |
{code:xml} <vdb name="team" version="1"> |
<property name="UseConnectorMetadata" value="cached" /> |
<model name="Team" visible="false"> <source name="objsource" translator-name="infinispan1" connection-jndi-name="java:infinispan-jndi"/> |
... |
{code} |
h3. {color:#000000}{*}JCA Resource Adapter{*}{color} |
Notice the use of the [OBJECTABLE|TEIID:OBJECTABLE] function to parse the object from Team and transform into rows and column. This metadata could also be defined by using Teiid Designer. |
|
h3. {*}JCA Resource Adapter{*} |
{color:#333333}See the Infinispan resource adapter for this translator. It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName or RemoteServerList). {color} |
The Object translator is a bridge for reading 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 must be used to transform the java object into rows and columns.
The following are the translator types and their respective supported data source:
Execution Properties - infinispan-cache
Name | Description | Required | Default |
---|---|---|---|
SupportsLuceneSearching | Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache | N | false |
The following are the connector capabilities when Key Searching is used:
The following are the connector capabilities when Hibernate/Lucene Searching is enabled:
Retrieve objects from a cache and transform into rows and columns.
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 native import logic will provide you with a TeamObject physical table. An equivalent Team table is shown here for demonstration purposes.
<vdb name="team" version="1"> <property name="UseConnectorMetadata" value="cached" /> <model name="Team" visible="false"> <source name="objsource" translator-name="infinispan1" connection-jndi-name="java:infinispan-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> <translator name="infinispan1" type="infinispan-cache"> <property name="SupportsLuceneSearching" value="true"/> </translator> </vdb>
Notice the use of the OBJECTABLE function to parse the object from Team and transform into rows and column. This metadata could also be defined by using Teiid Designer.
See the Infinispan resource adapter for this translator. It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName or RemoteServerList).