Query partition example with one input
A key can be one event field. For example:
query ImprobableWithdrawalLocations {
inputs {
Withdrawal() key cardNumber within (600.0);
}
find (Withdrawal as w1 -> Withdrawal as w2)
where (w1.country != w2.country) {
getAccountInfo();
sendEmail();
}
}
In the previous code fragment, the key is the cardNumber field in the incoming Withdrawal event type. When a Withdrawal event arrives the correlator adds it to the window in the partition identified by the value of the Withdrawal event's cardNumber field. For each partition, each unique card number in this example, the correlator maintains the window and evaluates the pattern separately from every other partition.
Suppose that cardNumber is the first field in Withdrawal events. The following table shows what happens at runtime.
Incoming Event | Goes Into Window in Partition Identified by This Key Value | Window Contents |
Withdrawal (12345, 50.0, ...) | 12345 | Withdrawal (12345, 50.0, ...) |
Withdrawal (24601, 60.0, ...) | 24601 | Withdrawal (24601, 60.0, ...) |
Withdrawal (12345, 10.0, ...) | 12345 | Withdrawal (12345, 50.0, ...), Withdrawal (12345, 10.0, ...) |
In the execution of this query, there is no interaction between the Withdrawal events for account number 12345 and the Withdrawal event for account number 24601.