Specifying Data Player playback queries
You create and modify Data Player queries with the Data Player Query Editor. The information for the Data Player queries is stored in the project's dataplayer_queries.xml file.
To create or modify a Data Player query
1. In the Project Explorer view, expand the project and then expand the config folder. Double click on the dataplayer_queries.xml file to open the Data Player Query Editor. If the project is running, you will be able to make selections from the Datasource, Database, and Query drop-down lists. If the project is not running, most of the controls are disabled.
If the project is not running the Data Player Query Editor will report that it is offline; in this mode, you cannot select Data Sources or Databases and all the controls are disabled.
If you are creating a new Data Player query, you can also right-click on the name of the project and select New > Data Player Query from the pop-up menu. Use this method if you are working on an imported project that does not yet contain a dataplayer_queries.xml file.
2. Click the Add Query button (). The New Query dialog appears. 3. Provide a name for the new Data Player query and click OK.
4. In the General Settings section, specify the following properties for the Data Player query:
Description — Provide a description of the Data Player query.
Data Source — Select an available Data Source from the drop down list.
Database — Select an available Database from the drop down list.
Return Type — The choices are
Native or
Wrapped. When
Native is selected, each matching event will be sent as-is to the correlator. When
Wrapped is selected, each matching event will be “wrapped” in a container event. The container event will be named using the event name. Event wrapping allows events to be sent to the correlator without triggering application listeners. A separate user monitor can listen for wrapped events, modify the contained event, and reroute it such that application listeners can match on it.
For example, you want to map the event Tick from the namespace com.apama.demo via the adapter, and your definition of Tick is as follows:
event Tick{
string symbol;
integer qty;
float price;
}
In order to define the event return type as Wrapped - Return events in container event, you have to define an event in the default package such as the following:
event HistoricalTick{
integer queryId;
string serviceId;
float timestamp;
com.apama.demo.Tick tick;
}
The Tick event will then be wrapped in a HistoricalTick event.
5. In the Query section, the Use Query Template check box specifies whether you want to use a Data Player Query Template (checked) or a Raw Query (unchecked).
If you are using a Query Template:
a. Select a Data Player Query Template from the drop-down list. The choices are the canned Data Player queries supplied with the Apama installation: findAll, findEarliest, findLatest, and getCount. You can add your own Data Player Query Templates; see Creating Data Player query templates. b. If the Data Player Query Template uses replaceable parameters, they will be displayed in the Name and Value table in the Query section of the editor.
6. Double click a cell in the Value column and type the entry to use for the Data Player query, for example the name of a database table or column.
If you are using a Raw Query, in the Query String text area specify the statement to execute as follows:
For ODBC and JDBC data sources, use SQL syntax.
For an Apama Sim data source, use the following keywords (keywords are case insensitive):
TIME with =, <, >, >=, and <= comparators and the time. Use one or two TIME statements. If two TIME statements are used, only data that matches both statements will be returned.
INCLUDE plus the event type to retrieve.
EXCLUDE plus the event type to not retrieve.
Examples of this syntax are:
TIME=12345
TIME=12345;INCLUDE=(com.apama.something)
TIME=12345;INCLUDE=(com.apama.something);EXCLUDE=(com.apama.something.abc)
TIME>12345;TIME<20000
7. In the Event Type field, specify unmapped-sql when the database table contains an eventString column that contains Apama events with string value. However, if the database table contains individual columns that are mapped to event fields in the ADBC adapter, then specify the name of the specific event in the Event Type field.
The value that you specify in the Event Type field becomes the value for _ADBCType in the ADBC adapter.
Given the above example of the Tick event that has been mapped in the adapter, you would have to specify com.apama.demo.Tick as the event type.
8. In the Time Column field, specify the time column in your table. For example, if your table contains a TransactionTime column, then you could specify TransactionTime in the Time Column field. Ensure that the value in the time column is a float value that represents a number of seconds since the epoch.
9. In the Advanced Settings section, specify any Extra Parameters.
a. Right-click in the Name column and select Add from the pop up menu (or double click in the Name column).
b. Specify the Name of the extra parameter.
c. In the Value column, specify the value of the extra parameter.
10. Save the Data Player query.
When you save the Data Player query, the Data Player query name is added to the Data Player Control view's drop down query list.
The Query Editor tool bar contains the following buttons:
Configure Credentials — This displays the
Credential for selected data source dialog where you add a user name and password for the current Data Player query if they are required for accessing the data source and select the scope of the credentials from a drop-down list. You can specify if the credentials apply globally, to a specific data source, or to a specific Data Player query. Credentials entered here are shared by the Data Player Query Editor and the Data Player.
Clone Query — Select this if you want to make a copy of the current Data Player query. The
Clone Query dialog prompts you for the name of the copy. You can then edit the specifications for the Data Player query.
Add Query — Select this if you want to add a new Data Player query. The
New Query dialog prompts you for the name of the new Data Player query.
Rename Query — Select this if you want to rename the Data Player query. The
Rename Query dialog prompts for the new name of the Data Player query.
Delete Query — Select this if you want to delete the Data Player query. The
Delete Query dialog prompts you to confirm that this is what you want to do.