Developing Apama Applications > Developing Apama Applications in EPL > Defining Queries > Defining query input > Format of input definitions
Format of input definitions
In a query definition, you define one or more inputs in the inputs block. The format of the inputs block is as follows.
inputs {
event_type(event_filter)
key query_key [within_clause] [retain_clause] ;
 
[ event_type(event_filter)
key query_key [within_clause] [retain_clause] ; ]...
}
event_type
Name of the event type that you want to operate on. The event type must be parseable. See Type properties summary.
Event type names can come from the root namespace, a using declaration, or a local package as specified in a package declaration.
event_filter
Optionally filter which events of this type you want to be in the window. For example, you might define the window to contain only the events whose amount field is greater than 10. The rules for what you can specify for the event filter are the same as for what you can specify in an event template in EPL. See Event templates.
query_key
Specify one or more event fields. You can specify event fields of type boolean, decimal, float, integer, string or location.
The correlator uses the key to partition the events. Each partition is identified by a unique key value. One or two fields in a key is typical. Three fields in a key is unusual and rarely needed. More than three fields is discouraged.
When you define more than one input in a query
*The number, type, and order of the key fields in each input definition must be the same.
*If the names of the key fields are not the same in each input definition, you must specify aliases so that the names match. For details, see Partitioning queries.
retain_clause
Optionally specify retain followed by an EPL integer expression that indicates how many events to hold in the window. For example, if you specify retain 1, only the last event that arrived that is of the specified type and that has the key value(s) associated with that partition is in the window. You must specify a retain clause or a within clause or both.
While it is possible to retain any number of events, you must ensure that you define an input that allows a match with the event pattern specified in the corresponding find statement. For example, the following query never finds a match:
query Q {
inputs {
A() key k retain 3;
}
find A:a1 -> A:a2 -> A:a3 -> A:a4 {
print a1.toString()+ " - "+a4.toString();
}
}
within_clause
Optionally specify within followed by a float expression or time literal that specifies the length of time that an event remains in the window. You must specify a retain clause or a within clause or both. See Specifying event duration in windows.
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.