This section explains considerations when performing XTP collaboration, as well as how to use it, as follows:
This section explains the items to consider when using XTP collaboration for referencing external data in complex event processing, as follows:
Checking the necessity of XTP collaboration
Unlike when master data is used by the high-speed filter, XTP collaboration allows data that is being continually updated to be referenced (for the high-speed filter, if the CEP engine is running, updates to the data will not be reflected).
If the data to be referenced need not be continually updated, consider using master data in the high-speed filter.
Structure of the XTP cache
Data in the XTP cache to be referenced by complex event processing rules is managed as entries in Key-Value format. Refer to "5.4.10 XTP Cache" for information on the Key-Value format used for storing in the cache to be used by complex event processing rules.
Using an XTP cache
Use the Virtual Data Window feature to use an XTP cache with complex event processing. Refer to "5.4.6.2 Using an XTP Cache" for information on how to create a Virtual Data Window and how to use a cache via the created Virtual Data Window.
This section explains how to create a Virtual Data Window and how to use the created Virtual Data Window.
Creating a Virtual Data Window
Create a Virtual Data Window (hereafter, referred to as a "VDW") within complex event processing rules in order to reference an XTP cache from the rules.
Specifically, describe this as follows:
Syntax: If an event type ID is used
@VDW(cacheName="cacheName", keyProperty="keyPropertyName")
create window windowName.isxtp:vdw() as eventTypeID;
Syntax: If type information is specified directly
@VDW(cacheName="cacheName", keyProperty="keyPropertyName")
create window windowName.isxtp:vdw() as (propertyName type, propertyName type, ...);
Create a VDW using a combination of the "@VDW" annotation and a CREATE WINDOW statement.
To reference the cache entity, the cacheName and the keyPropertyName for referencing the data must be set. To set these, the "@VDW" annotation must be specified.
In cacheName, specify the name of the cache to be used.
In keyPropertyName, specify the property name for identifying the entry. If an event type ID is to be used, specify the property name of the specified event type. If type information is to be specified directly, any name can be specified. The type of the specified property must be a type that corresponds to the "Key" class in the cache.
In windowName, specify any name. The name specified here will be able to be used to reference from SELECT statements in other complex event processing rules.
In eventTypeID, specify the event specified in the CSV format event type definition. (An XML format event type definition cannot be specified.)
In propertyName type, the property name and type that corresponds to the "java.util.HashMap" key to be set in "Value" in the cache must be specified. The property name and its type specified in keyPropertyName must also be specified.
If the specified propertyName has not been set in "java.util.HashMap" to be set in "Value" in the cache, it will be treated as a null by the complex event processing rules.
Example
Description example for creating a Virtual Data Window (VDW)
This is an example of creating a VDW (MarketWindow) to reference an XTP cache (MARKET).
@VDW(cacheName="MARKET", keyProperty="code")
create window MarketWindow.isxtp:vdw() as (code string, high int, low int);
"code" is specified as a key property.
"code (string type)", "high (int type)", and "low (int type)" are defined as the properties.
Using a Virtual Data Window
Use a created Virtual Data Window in the same way as an ordinary window.
Example
Example of using a created Virtual Data Window (VDW)
This is an example of referencing a VDW (MarketWindow) in an event (TickerWindow) to obtain the data of the VDW events (cache entries) that meet the condition.
select M.code from MarketWindow as M, TickerWindow as T
where M.code = T.code and ( T.price > M.high or T.price < M.low);
Note
Notes on using a Virtual Data Window
The restrictions below apply to a WHERE clause that can be used when accessing the information stored in a Virtual Data Window.
These restrictions apply when records are to be identified from a cache.
If the records have already been identified, the rules can be described in the usual way and the following restrictions will not apply:
Only key properties specified using the "@VDW" annotation can be specified to identify records.
Only the "=" comparison operator can be used for key properties that can be specified to identify records.
Description example
After identifying records using "M.code = T.code", compare other items.
@VDW(cacheName="MARKET", keyProperty="code")
create window MarketWindow.isxtp:vdw() as (code string, high int, low int);
select M.code from MarketWindow as M, TicketWindow as T
where M.code = T.code and (T.price > M.high or T.price < M.low)
The table below shows valid and invalid description examples for the cache above.
No. | Description example | Valid? | Explanation |
---|---|---|---|
1 | select * from MarketWindow where code = '1111' | Yes | This is acceptable because the "=" operation is used for a key property. |
2 | select * from MarketWindow where high = 1000 | No | This is unacceptable because a WHERE clause is specified for other than a key property. |
3 | select * from MarketWindow where code > '1111' | No | This is unacceptable because a WHERE clause is only specified for a key property but is performing an operation other than "=". |