Apama 10.15.0 | Using Apama with Software AG Designer | Using the Data Player | Using the Data Player | Specifying Data Player playback queries
 
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 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 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. In the Configuration field, enter the name of the query and click Finish. The query will be added to the project. You can then edit the query in the Data Player editor.
2. Click the Add Query button (Plus icon). 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.
*Datasource — 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.
*Flush between events — Controls whether the correlator's queues are flushed between every event from the database or not. This is important for correct behavior in multi-threaded or multi-context applications. The recommended value is 2 (default), which flushes the correlator's queues twice, but may need to be higher if the application contains a long sequence of contexts that send events from one to the next. This will reduce the maximum speed that events can be processed, so for single-context applications, you may want to set this to 0 (or equivalently, leave blank).
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 icon 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 icon 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 icon 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 icon  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 icon  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.