Using Apama with Software AG Designer > Using Query Designer > Creating queries in Query Designer > Adding query inputs
Adding query inputs
To specify the event pattern that you want your query to find, you must first define the event types that your query processes. The input definitions identify the events that you want the query to operate on. Perform these tasks in the Inputs pane in the Design tab of the Query Designer.
To add a query input:
1. In the Inputs toolbar, click the plus sign to select an event type. The New Query Input dialog appears.
2. In the Choose Event Input, click the Choose button to select the event type you want to add in the Event Type Selection. Click OK.
3. In the Window tab:
*Event Window
1. In the Within field, optionally specify a float expression or time literal that specifies the duration of time that an event remains as a current event that the query operates on. The query operates on the events that have been received within the time specified.
For example, Within: 7 days implies that an event remains in the event window for 7 days.
2. In the Retain field, optionally specify an integer expression that specifies the number of events to be retained in the window.
For example, Retain: 100 implies that a maximum of 100 events can be retained in the event window. If the number of events exceed 100, the older events are replaced by new events.
Note: You must specify a value in either the Within field or in the Retain field or both.
*Partition
In the Key field, optionally you can select one or more fields to be the query key. A query key identifies one or more fields in the events being operated on. Each input definition for a given query must specify the same key. Apama uses the key to partition the incoming events. A partition contains a set of events that have the same key value. The query processes the set of events in a given partition independently of every other partition. All the input events must have the same key names. If an event field does not have the same name as an existing input event, alias the key to the same name as the existing input key.
For example, you can partition Withdrawal events according to their account numbers.
4. In the Filtering tab:
*Pre-Filtering (optional)
In the Filter field, optionally specify an expression that filters the events you want the query to process. In the filter expression, you can specify event fields of type boolean, decimal, float, integer, string or location.
For example, if you want to filter Withdrawal events whose amount field is greater than 10, type amount > 10.0.
If you want to refer to a parameter in a filter, then you must first add the parameter. See Adding query parameters.
*Discard repeating values (optional)
If there are multiple events with the same value for a field, the With unique functionality retains the latest value and discards the previous events with the same value.
*Select Do not discard repeating values if you want to retain events with repeating values.
*Select Discard repeating values ("with unique") if you want to remove events with repeating values.
For more information, see Matching only the latest event for a given field.
5. In the Timestamps (optional) tab:
Source Timestamps — time at which an event happened at the event source, that is available in the event. Use the Timestamps (optional) tab to configure the query to use Source Timestamps. The Timestamps (optional) tab controls whether the query runtime processes the events as they occur or whether the events contain some information about the time they occurred. This process of Timestamps tab requires you to specify the Wait, Time from, and Heartbeat fields.
To configure the query to use Source Timestamps:
*Select No Timestamps - Process events at arrival time to process the events as they arrive. You cannot specify the Wait, Time from, and Heartbeat fields if you select this option.
*Select Use Timestamps - Wait for delayed events to process the events according to the timestamps of the events.
Note: If events are delayed or re-ordered between the event source and the queries, then using the source timestamps where available yields more accurate results.
*Event definition settings — select this option if you want the query to use the Time from and Heartbeat settings provided by the event definition through annotations. If the annotation has a DefaultWait annotation, then the Wait field is initially set by copying the value from the DefaultWait annotation (if defined). But, you can still configure the Wait field.
Specify a float expression or a time literal in the Wait field that specifies the maximum delay for an event. For a query that uses source timestamps, you must specify the maximum time for the queries runtime to wait for an event before it can process. If the event does not define a TimeFrom annotation, use Custom settings.
*Custom settings — select this option if you have different queries using different settings or if there are no annotations. This ensures that not all queries are using the same Time from or Heartbeat. You can specify the Wait, Time from, and Heartbeat fields after selecting this option.
*Wait — specify a float expression or a time literal that specifies the maximum time for the queries runtime to wait for an event before it can process.
*Time from — select an action that returns source timestamps of the event to the query. The Time from drop-down lists actions that are legal and can be used time-from actions. The actions must not have any parameters and must return a float value.
*Heartbeat (optional)— select the check box Use heartbeat event (optional) if you wish to configure an heartbeat settings. Click Choose... to select the Heartbeat event type. Select the event type and click OK. The selected event type must have the same key fields and time-from actions as the input event type. The heartbeat events with timetamps signal that the communication from the source to the queries system is working correctly.
The heartbeat events can be used only if a query is using source timestamps.
For more information, see Using source timestamps of events.
6. Click OK to add this input definition to your query.
Query Designer displays the new input definition in a row in the Inputs section and the event type you specified appears in the Palette.
Repeat these steps for each event type you want your query to process. Apama recommends no more than four input definitions in a query. You cannot add the same event type as a query input more than once. The input event type must be unique.
For more information, see Defining query input.
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.