esper.codehaus.org and espertech.comDocumentation
EPL date-time methods work on date-time values to perform common tasks such as comparing times and time periods, adding or subtracting time periods, setting or rounding calendar fields and querying fields.
Date-time methods operate on:
Any expression or event property that returns either a long-type millisecond value, a java.util.Calendar
or java.util.Date
including subclasses. Consider the built-in single-row function current_timestamp
for use with date-time methods.
Any event for which the event type declares a start timestamp property name and optionally also an end timestamp property name. Date-time methods operate on events by means of the stream-alias.method-name syntax.
The below table summarizes the built-in date-time methods available:
Table 12.1. Date-Time Methods
Method | Result |
---|---|
after(event or timestamp) |
Returns true if an event happens after another event, or a timestamp is after another timestamp. |
before(event or timestamp) |
Returns true if an event happens before another event, or a timestamp is before another timestamp. |
between(timestamp, timestamp, boolean, boolean) |
Returns true if a timestamp is between two timestamps. |
coincides(event or timestamp) |
Returns true if an event and another event happen at the same time, or two timestamps are the same value. |
during(event or timestamp) |
Returns true if an event happens during the occurrence of another event, or when a timestamps falls within the occurrence of an event. |
finishes(event or timestamp) |
Returns true if an event starts after another event starts and the event ends at the same time as the other event. |
finishedBy(event or timestamp) |
Returns true if an event starts before another event starts and ends at the same time as the other event. |
format() |
Formats the date-time returning a string. |
get(field) |
Returns the value of the given date-time value field. |
getMillisOfSecond() getSecondOfMinute() getMinuteOfHour() getHourOfDay() getDayOfWeek() getDayOfMonth() getDayOfYear() getWeekyear() getMonthOfYear() getYear() getEra() |
Returns the value of the given date-time value field. |
includes(event or timestamp) |
Returns true if the parameter event happens during the occurrence of the event, or when a timestamps falls within the occurrence of an event. |
meets(event or timestamp) |
Returns true if the event's end time is the same as another event's start time. |
metBy(event or timestamp) |
Returns true if the event's start time is the same as another event's end time. |
minus(duration-millis) |
Returns a date-time with the specified duration in long-type milliseconds taken away. |
minus(time-period) |
Returns a date-time with the specified duration in time-period syntax taken away. |
overlaps(event or timestamp) |
Returns true if the event starts before another event starts and finishes after the other event starts, but before the other event finishes (events have an overlapping period of time). |
overlappedBy(event or timestamp) |
Returns true if the parameter event starts before the input event starts and the parameter event finishes after the input event starts, but before the input event finishes (events have an overlapping period of time). |
plus(duration-millis) |
Returns a date-time with the specified duration in long-type milliseconds added. |
plus(time-period) |
Returns a date-time with the specified duration in time-period syntax added. |
roundCeiling(field) |
Returns a date-time rounded to the highest whole unit of the date-time field. |
roundFloor(field) |
Returns a date-time rounded to the lowest whole unit of the date-time field. |
roundHalf(field) |
Returns a date-time rounded to the nearest whole unit of the date-time field. |
set(field, value) |
Returns a date-time with the specified field set to the value returned by a value expression. |
starts(event or timestamp) |
Returns true if an event and another event start at the same time and the event's end happens before the other event's end. |
startedBy(event or timestamp) |
Returns true if an event and another event start at the same time and the other event's end happens before the input event's end. |
withDate(year,month,day) |
Returns a date-time with the specified date, retaining the time fields. |
withMax(field) |
Returns a date-time with the field set to the maximum value for the field. |
withMin(field) |
Returns a date-time with the field set to the minimum value for the field. |
withTime(hour,minute,sec,msec) |
Returns a date-time with the specified time, retaining the date fields. |
toCalendar() |
Returns the |
toDate() |
Returns the |
toMillisec() |
Returns the long-type milliseconds value for this date-time value. |
The syntax for date-time methods is the same syntax as for any chained invocation:
input_val.datetime_method_name( [method_parameter [, method_parameter [,...]]]) .[ datetime_method_name(...) [...]]
Following the input_val input value is the .
(dot) operator and the datetime_method_name date-time method name. It follows in parenthesis a comma-separated list of method parameter expressions. Additional date-time methods can be chained thereafter.
The input value can be any expression or event property that returns a value of type long or java.util.Calendar
or java.util.Date
. If the input value is null, the expression result is also null.
The input value can also be an event. In this case the event type of the event must have the start timestamp property name defined and optionally also the end timestamp property name.
The following example EPL statement employs the withTime
date-time method. This example returns the current engine time with the time-part set to 1 am:
select current_timestamp.withTime(1, 0, 0, 0) as time1am from MyEvent
As date-time methods can be chained, this EPL is equivalent:
select current_timestamp.set('hour', 1).set('min', 0).set('sec', 0).set('msec', 0) as time1am from MyEvent
The statement above outputs in field time1am
a long-type millisecond-value reflecting 1am on the same date as engine time. Since the input value is provided by the built-in current_timestamp
function which returns current engine date as a long-type millisecond value the output is also a long-type millisecond value.
You may apply a date-time method to an event property.
Assume that the RFIDEvent
event type has a Date
-type property by name timeTaken
. The following query rounds each time-taken value down to the nearest minute and outputs a Date
-type value in column timeTakenRounded
:
select timeTaken.roundFloor('min') as timeTakenRounded from RFIDEvent
You may apply a date-time method to events. This example assumes that the RFIDEvent and WifiEvent event types both have a timestamp property defined. The EPL compares the timestamps of the RFIDEvent and the WifiEvent:
select rfid.after(wifi) as isAfter from RFIDEvent.std:lastevent() rfid, WifiEvent.std:lastevent() wifi
For comparing date-time values and considering event duration (event start and end timestamps) we recommend any of the interval algebra methods. You may also compare millisecond values using the between
or in
ranges and inverted ranges or relational operators (> , <, >=, <=)
.
From a performance perspective, the date-time method evaluation ensures that for each unique chain of date-time methods only a single calendar objects is copied or created when necessary.
The between
date-time method compares the input date-time value to the two date-time values passed in and returns true if the input value falls between the two parameter values.
The synopsis is:
input_val.between(range_start, range_end [, include_start, include_end])
The method takes either 2 or 4 parameters. The first two parameters range_start and range_end are expressions or properties that yield either a long-typed, Date-typed or Calendar-typed range start and end value.
The next two parameters include_start and include_end are optional. If not specified, the range start value and range end value are included in the range i.e. specify a closed range where both endpoints are included. If specified, the expressions must return a boolean-value indicating whether to include the range start value and range end value in the range.
The example below outputs true when the time-taken property value of the RFID event falls between the time-start property value and the time-end property value (closed range includes endpoints):
select timeTaken.between(timeStart, timeEnd) from RFIDEvent
The example below performs the same test as above but does not include endpoints (open range includes neither endpoint):
select timeTaken.between(timeStart, timeEnd, false, false) from RFIDEvent
If the range end value is less then the range start value, the algorithm reverses the range start and end value.
If the input date-time value or any of the parameter values evaluate to null the method returns a null result value.
The format
date-time method formats the date-time returning a string.
The method takes no parameters. It returns the date-time value formatted using the default locale format obtained from new SimpleDateFormat()
.
The example below outputs the time-taken property value of the RFID event:
select timeTaken.format() as timeTakenStr from RFIDEvent
The get
date-time method returns the value of the given date-time value field.
The method takes a single string-constant field name as parameter. Please see Section 5.2.1, “Specifying Time Periods” for a list of recognized keywords (not case-sensitive).
The method returns the numeric value of the field within the date-time value. The value returned adheres to Calendar
-class semantics: For example, the value for month
starts at zero and has a maximum of 11.
The example below outputs the month value of the time-taken property value of the RFID event:
select timeTaken.get('month') as timeTakenMonth from RFIDEvent
The following list of getter-methods are available: getMillisOfSecond()
, getSecondOfMinute()
, getMinuteOfHour()
, getHourOfDay()
, getDayOfWeek()
, getDayOfMonth()
, getDayOfYear()
, getWeekYear()
, getMonthOfYear()
, getYear()
and getEra()
.
All get-methods take no parameter and return the numeric value of the field within the date-time value. The value returned adheres to Calendar
-class semantics: For example, the value for month
starts at zero and has a maximum of 11.
The example below outputs the month value of the time-taken property value of the RFID event:
select timeTaken.getMonthOfYear() as timeTakenMonth from RFIDEvent
The minus
date-time method returns a date-time with the specified duration taken away.
The method has two versions: The first version takes the duration as a long-type millisecond value. The second version takes the duration as a time-period expression, see Section 5.2.1, “Specifying Time Periods”.
The example below demonstrates the time-period parameter to subtract two minutes from the time-taken property value of the RFID event:
select timeTaken.minus(2 minutes) as timeTakenMinus2Min from RFIDEvent
The next example is equivalent but passes a millisecond-value instead:
select timeTaken.minus(2*60*1000) as timeTakenMinus2Min from RFIDEvent
The plus
date-time method returns a date-time with the specified duration added.
The method has two versions: The first version takes the duration as a long-type millisecond value. The second version takes the duration as a time-period expression, see Section 5.2.1, “Specifying Time Periods”.
The next example adds two minutes to the time-taken property value of the RFID event:
select timeTaken.plus(2 minutes) as timeTakenPlus2Min from RFIDEvent
The next example is equivalent but passes a millisecond-value instead:
select timeTaken.plus(2*60*1000) as timeTakenPlus2Min from RFIDEvent
The roundCeiling
date-time method rounds to the highest whole unit of the date-time field.
The method takes a single string-constant field name as parameter. Please see Section 5.2.1, “Specifying Time Periods” for a list of recognized keywords (not case-sensitive).
The next example rounds-to-ceiling the minutes of the time-taken property value of the RFID event:
select timeTaken.roundCeiling('min') as timeTakenRounded from RFIDEvent
If the input time is 2002-05-30 09:01:23.050
, for example, the output is 2002-05-30 09:02:00.000
(example timestamps are in format yyyy-MM-dd HH:mm:ss.SSS
).
The roundFloor
date-time method rounds to the lowest whole unit of the date-time field.
The method takes a single string-constant field name as parameter. Please see Section 5.2.1, “Specifying Time Periods” for a list of recognized keywords (not case-sensitive).
The next example rounds-to-floor the minutes of the time-taken property value of the RFID event:
select timeTaken.roundFloor('min') as timeTakenRounded from RFIDEvent
If the input time is 2002-05-30 09:01:23.050
, for example, the output is 2002-05-30 09:01:00.000
(example timestamps are in format yyyy-MM-dd HH:mm:ss.SSS
).
The roundFloor
date-time method rounds to the nearest whole unit of the date-time field.
The method takes a single string-constant field name as parameter. Please see Section 5.2.1, “Specifying Time Periods” for a list of recognized keywords (not case-sensitive).
The next example rounds the minutes of the time-taken property value of the RFID event:
select timeTaken.roundHalf('min') as timeTakenRounded from RFIDEvent
The following table provides a few examples of the rounding (example timestamps are in format yyyy-MM-dd HH:mm:ss.SSS
):
Table 12.2. RoundHalf Examples
Input | Output |
---|---|
2002-05-30 09:01:23.050 | 2002-05-30 09:01:00.000 |
2002-05-30 09:01:29.999 | 2002-05-30 09:01:00.000 |
2002-05-30 09:01:30.000 | 2002-05-30 09:02:00.000 |
The set
date-time method returns a date-time with the specified field set to the value returned by an expression.
The method takes a string-constant field name and an expression returning an integer-value as parameters. Please see Section 5.2.1, “Specifying Time Periods” for a list of recognized keywords (not case-sensitive).
The method returns the new date-time value with the field set to the provided value. Note that value adheres to Calendar
-class semantics: For example, the value for month
starts at zero and has a maximum of 11.
The example below outputs the time-taken with the value for month set to April:
select timeTaken.set('month', 3) as timeTakenMonth from RFIDEvent
The withDate
date-time method returns a date-time with the specified date, retaining the time fields.
The method takes three expressions as parameters: An expression for year, month and day.
The method returns the new date-time value with the date fields set to the provided values. For expressions returning null the method ignores the field for which null is returned. Note the Calendar
-class semantics: For example, the value for month
starts at zero and has a maximum of 11.
The example below outputs the time-taken with the date set to May 30, 2002:
select timeTaken.withDate(2002, 4, 30) as timeTakenDated from RFIDEvent
The withMax
date-time method returns a date-time with the field set to the maximum value for the field.
The method takes a string-constant field name as parameter. Please see Section 5.2.1, “Specifying Time Periods” for a list of recognized keywords (not case-sensitive).
The method returns the new date-time value with the specific date field set to the maximum value.
The example below outputs the time-taken property value with the second-part as 59 seconds:
select timeTaken.withMax('sec') as timeTakenMaxSec from RFIDEvent
The withMin
date-time method returns a date-time with the field set to the minimum value for the field.
The method takes a string-constant field name as parameter. Please see Section 5.2.1, “Specifying Time Periods” for a list of recognized keywords (not case-sensitive).
The method returns the new date-time value with the specific date field set to the minimum value.
The example below outputs the time-taken property value with the second-part as 0 seconds:
select timeTaken.withMin('sec') as timeTakenMaxSec from RFIDEvent
The withTime
date-time method returns a date-time with the specified time, retaining the date fields.
The method takes four expressions as parameters: An expression for hour, minute, second and millisecond.
The method returns the new date-time value with the time fields set to the provided values. For expressions returning null the method ignores the field for which null is returned.
The example below outputs the time-taken with the time set to 9am:
select timeTaken.withTime(9, 0, 0, 0) as timeTakenDated from RFIDEvent
The toCalendar
date-time method returns the Calendar
object for this date-time value.
The method takes no parameters.
The example below outputs the time-taken as a Calendar
object:
select timeTaken.toCalendar() as timeTakenCal from RFIDEvent
The toDate
date-time method returns the Date
object for this date-time value.
The method takes no parameters.
The example below outputs the time-taken as a Date
object:
select timeTaken.toDate() as timeTakenDate from RFIDEvent
Interval algebra methods compare start and end timestamps of events or timestamps in general.
When the expression input is only a timestamp value, such as a long-type value or a Date
or Calendar
object, the start and end timestamp represented by that value are the same timestamp value.
When expression input is an event stream alias, the engine determine the event type for the stream. If the event type declares a start timestamp property name, the engine uses that start timestamp property to determine the start timestamp for the event. If the event type also declares an end timestamp property name, the engine uses that end timestamp property to determine the end timestamp for the event (i.e. an event with duration). If an end timestamp property name is not declared, the start and end timestamp for each event is the same value and the event is considered to have zero duration (i.e. a point-in-time event).
Interval algebra methods all return Boolean
-type value. When the input value start timestamp is null, or the end timestamp (if declared for the event type) is null or any of the start timestamp and end timestamp (if declared for the event type) values of the first parameter is null, the result value is null.
The examples in this section simply use A
and B
as event type names. The alias a
is used to represent A
-type events and respectively the alias b
represents B
-type events.
The create-schema
for types A
and B
is shown next. The two types are declared the same. The example declares the property providing start timestamp values as startts
and the property providing end timestamp values as endts
:
create schema A as (startts long, endts long) starttimestamp 'startts' endtimestamp 'endts'
create schema B as (startts long, endts long) starttimestamp 'startts' endtimestamp 'endts'
The sample EPL below joins the last A and the last B event. It detects A-B event combinations for which, when comparing timestamps, the last A event that occurs before the last B event. The example employs the before
method:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.before(b)
For simplicity, the examples in this section refer to A
and the alias a
as the input event. The examples refer to B
and the alias b
as the parameter event.
The first parameter of each interval algebra methods is the event or timestamp to compare to.
All remaining parameters to interval algebra methods are intervals and can be any of the following:
A constant, an event property or more generally any expression returning a numeric value that is the number of seconds. For example, in the expression a.before(b, 2)
the parameter 2 is interpreted to mean 2 seconds. The expression a.before(b, myIntervalProperty)
is interpreted to mean myIntervalProperty
seconds.
A time period expression as described in Section 12.4.11, “Includes”. For example: a.before(b, 1 hour 2 minutes)
.
When an interval parameter is provided and is null, the method result value is null.
The engine analyzes interval algebra methods as well as the between
date-time method in the where-clause and builds a query plan for execution of joins and subqueries. The query plan can include hash and btree index lookups using the start and end timestamps as computed by expressions or provided by events as applicable. Consider turning on query plan logging to obtain information on the query plan used.
The query planning is generally most effective when no additional thresholds or ranges are provided to interval algebra methods, as the query planner may not consider an interval algebra method that it cannot plan.
The query planner may also not optimally plan the query execution if events or expressions return different types of date representation. Query planning works best if all date representations use the same long, Date or Calendar types.
Date-time method that change date or time fields, such as withTime
, withDate
, set
or round
methods set the end timestamp to the start timestamp.
For example, in the following expression the parameter to the after
method has a zero duration, and not the end timestamp that the event B endts
property provides.
a.after(b.withTime(9, 0, 0, 0))
The after
date-time method returns true if an event happens after another event, or a timestamp is after another timestamp.
The method compares the input value's start timestamp (a.startTimestamp) to the first parameter's end timestamp (b.endTimestamp) to determine whether A happens after B.
If used with one parameter, for example in a.after(b)
, the method returns true if A starts after B ends.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.after(b) // Above matches when: // a.startTimestamp - b.endTimestamp > 0
If providing two parameters, for example in a.after(b, 5 sec)
, the method returns true if A starts at least 5 seconds after B ends.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.after(b, 5 sec) // Above matches when: // a.startTimestamp - b.endTimestamp >= 5 seconds
If providing three parameters, for example in a.after(b, 5 sec, 10 sec)
, the method returns true if A starts at least 5 seconds but no more then 10 seconds after B ends.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.after(b, 5 sec, 10 sec) // Above matches when: // 5 seconds <= a.startTimestamp - b.endTimestamp <= 10 seconds
Negative values for the range are allowed. For example in a.after(b, -5 sec, -10 sec)
, the method returns true if A starts at least 5 seconds but no more then 10 seconds before B ends.
If the range low endpoint is greater than the range high endpoint, the engine automatically reverses them. Thus a.after(b, 10 sec, 5 sec)
is the same semantics as a.after(b, 5 sec, 10 sec)
.
The before
date-time method returns true if an event happens before another event, or a timestamp is before another timestamp.
The method compares the input value's end timestamp (a.endTimestamp) and the first parameter's start timestamp (b.startTimestamp) to determine whether A happens before B.
If used with one parameter, for example in a.before(b)
, the method returns true if A ends before B starts.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.before(b) // Above matches when: // b.startTimestamp - a.endTimestamp > 0
If providing two parameters, for example in a.before(b, 5 sec)
, the method returns true if A ends at least 5 seconds before B starts.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.before(b, 5 sec) // Above matches when: // b.startTimestamp - a.endTimestamp >= 5 seconds
If providing three parameters, for example in a.before(b, 5 sec, 10 sec)
, the method returns true if A ends at least 5 seconds but no more then 10 seconds before B starts.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.before(b, 5 sec, 10 sec) // Above matches when: // 5 seconds <= b.startTimestamp - a.endTimestamp <= 10 seconds
Negative values for the range are allowed. For example in a.before(b, -5 sec, -10 sec)
, the method returns true if A starts at least 5 seconds but no more then 10 seconds after B starts.
If the range low endpoint is greater than the range high endpoint, the engine automatically reverses them. Thus a.before(b, 10 sec, 5 sec)
is the same semantics as a.before(b, 5 sec, 10 sec)
.
The coincides
date-time method returns true if an event and another event happen at the same time, or two timestamps are the same value.
The method compares the input value's start and end timestamp with the first parameter's start and end timestamp and determines if they equal.
If used with one parameter, for example in a.coincides(b)
, the method returns true if the start timestamp of A and B are the same and the end timestamps of A and B are also the same.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.coincides(b) // Above matches when: // a.startTimestamp = b.startTimestamp and a.endTimestamp = b.endTimestamp
If providing two parameters, for example in a.coincides(b, 5 sec)
, the method returns true if the difference between the start timestamps of A and B is equal to or less then 5 seconds and the difference between the end timestamps of A and B is also equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.coincides(b, 5 sec) // Above matches when: // abs(a.startTimestamp - b.startTimestamp) <= 5 sec and // abs(a.endTimestamp - b.endTimestamp) <= 5 sec
If providing three parameters, for example in a.coincides(b, 5 sec, 10 sec)
, the method returns true if the difference between the start timestamps of A and B is equal to or less then 5 seconds and the difference between the end timestamps of A and B is equal to or less then 10 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.coincides(b, 5 sec, 10 sec) // Above matches when: // abs(a.startTimestamp - b.startTimestamp) <= 5 seconds and // abs(a.endTimestamp - b.endTimestamp) <= 10 seconds
A negative value for interval parameters is not allowed. If your interval parameter is itself an expression that returns a negative value the engine logs a warning message and returns null.
The during
date-time method returns true if an event happens during the occurrence of another event, or when a timestamps falls within the occurrence of an event..
The method determines whether the input value's start and end timestamp are during the first parameter's start and end timestamp. The symmetrical opposite is Section 12.4.11, “Includes”.
If used with one parameter, for example in a.during(b)
, the method returns true if the start timestamp of A is after the start timestamp of B and the end timestamp of A is before the end timestamp of B.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.during(b) // Above matches when: // b.startTimestamp < a.startTimestamp <= a.endTimestamp < b.endTimestamp
If providing two parameters, for example in a.during(b, 5 sec)
, the method returns true if the difference between the start timestamps of A and B is equal to or less then 5 seconds and the difference between the end timestamps of A and B is also equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.during(b, 5 sec) // Above matches when: // 0 < a.startTimestamp - b.startTimestamp <= 5 sec and // 0 < a.endTimestamp - b.endTimestamp <= 5 sec
If providing three parameters, for example in a.during(b, 5 sec, 10 sec)
, the method returns true if the difference between the start timestamps of A and B and the difference between the end timestamps of A and B is between 5 and 10 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.during(b, 5 sec, 10 sec) // Above matches when: // 5 seconds <= a.startTimestamp - b.startTimestamp <= 10 seconds and // 5 seconds <= a.endTimestamp - b.endTimestamp <= 10 seconds
If providing five parameters, for example in a.during(b, 5 sec, 10 sec, 20 sec, 30 sec)
, the method returns true if the difference between the start timestamps of A and B is between 5 seconds and 10 seconds and the difference between the end timestamps of A and B is between 20 seconds and 30 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.during(b, 5 sec, 10 sec, 20 sec, 30 sec) // Above matches when: // 5 seconds <= a.startTimestamp - b.startTimestamp <= 10 seconds and // 20 seconds < a.endTimestamp - b.endTimestamp <= 30 seconds
The finishes
date-time method returns true if an event starts after another event starts and the event ends at the same time as the other event.
The method determines whether the input value's start timestamp is after the first parameter's start timestamp and the end timestamp of the input value and the first parameter are the same. The symmetrical opposite is Section 12.4.10, “Finished By”.
If used with one parameter, for example in a.finishes(b)
, the method returns true if the start timestamp of A is after the start timestamp of B and the end timestamp of A and B are the same.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.finishes(b) // Above matches when: // b.startTimestamp < a.startTimestamp and a.endTimestamp = b.endTimestamp
If providing two parameters, for example in a.finishes(b, 5 sec)
, the method returns true if the start timestamp of A is after the start timestamp of B and the difference between the end timestamps of A and B is equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.finishes(b, 5 sec) // Above matches when: // b.startTimestamp < a.startTimestamp and // abs(a.endTimestamp - b.endTimestamp ) <= 5 seconds
A negative value for interval parameters is not allowed. If your interval parameter is itself an expression that returns a negative value the engine logs a warning message and returns null.
The finishedBy
date-time method returns true if an event starts before another event starts and the event ends at the same time as the other event.
The method determines whether the input value's start timestamp happens before the first parameter's start timestamp and the end timestamp of the input value and the first parameter are the same. The symmetrical opposite is Section 12.4.9, “Finishes”.
If used with one parameter, for example in a.finishedBy(b)
, the method returns true if the start timestamp of A is before the start timestamp of B and the end timestamp of A and B are the same.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.finishedBy(b) // Above matches when: // a.startTimestamp < b.startTimestamp and a.endTimestamp = b.endTimestamp
If providing two parameters, for example in a.finishedBy(b, 5 sec)
, the method returns true if the start timestamp of A is before the start timestamp of B and the difference between the end timestamps of A and B is equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.finishedBy(b, 5 sec) // Above matches when: // a.startTimestamp < b.startTimestamp and // abs(a.endTimestamp - b.endTimestamp ) <= 5 seconds
The includes
date-time method returns true if the parameter event happens during the occurrence of the input event, or when a timestamps falls within the occurrence of an event.
The method determines whether the first parameter's start and end timestamp are during the input value's start and end timestamp. The symmetrical opposite is Section 12.4.8, “During”.
If used with one parameter, for example in a.includes(b)
, the method returns true if the start timestamp of B is after the start timestamp of A and the end timestamp of B is before the end timestamp of A.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.includes(b) // Above matches when: // a.startTimestamp < b.startTimestamp <= b.endTimestamp < a.endTimestamp
If providing two parameters, for example in a.includes(b, 5 sec)
, the method returns true if the difference between the start timestamps of A and B is equal to or less then 5 seconds and the difference between the end timestamps of A and B is also equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.includes(b, 5 sec) // Above matches when: // 0 < b.startTimestamp - a.startTimestamp <= 5 sec and // 0 < a.endTimestamp - b.endTimestamp <= 5 sec
If providing three parameters, for example in a.includes(b, 5 sec, 10 sec)
, the method returns true if the difference between the start timestamps of A and B and the difference between the end timestamps of A and B is between 5 and 10 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.includes(b, 5 sec, 10 sec) // Above matches when: // 5 seconds <= a.startTimestamp - b.startTimestamp <= 10 seconds and // 5 seconds <= a.endTimestamp - b.endTimestamp <= 10 seconds
If providing five parameters, for example in a.includes(b, 5 sec, 10 sec, 20 sec, 30 sec)
, the method returns true if the difference between the start timestamps of A and B is between 5 seconds and 10 seconds and the difference between the end timestamps of A and B is between 20 seconds and 30 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.includes(b, 5 sec, 10 sec, 20 sec, 30 sec) // Above matches when: // 5 seconds <= a.startTimestamp - b.startTimestamp <= 10 seconds and // 20 seconds <= a.endTimestamp - b.endTimestamp <= 30 seconds
The meets
date-time method returns true if the event's end time is the same as another event's start time.
The method compares the input value's end timestamp and the first parameter's start timestamp and determines whether they equal.
If used with one parameter, for example in a.meets(b)
, the method returns true if the end timestamp of A is the same as the start timestamp of B.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.meets(b) // Above matches when: // a.endTimestamp = b.startTimestamp
If providing two parameters, for example in a.meets(b, 5 sec)
, the method returns true if the difference between the end timestamp of A and the start timestamp of B is equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.meets(b, 5 sec) // Above matches when: // abs(b.startTimestamp - a.endTimestamp) <= 5 seconds
A negative value for the interval parameter is not allowed. If your interval parameter is itself an expression that returns a negative value the engine logs a warning message and returns null.
The metBy
date-time method returns true if the event's start time is the same as another event's end time.
The method compares the input value's start timestamp and the first parameter's end timestamp and determines whether they equal.
If used with one parameter, for example in a.metBy(b)
, the method returns true if the start timestamp of A is the same as the end timestamp of B.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.metBy(b) // Above matches when: // a.startTimestamp = b.endTimestamp
If providing two parameters, for example in a.metBy(b, 5 sec)
, the method returns true if the difference between the end timestamps of B and the start timestamp of A is equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.metBy(b, 5 sec) // Above matches when: // abs(a.startTimestamp - b.endTimestamp) <= 5 seconds
A negative value for the interval parameter is not allowed. If your interval parameter is itself an expression that returns a negative value the engine logs a warning message and returns null.
The overlaps
date-time method returns true if the event starts before another event starts and finishes after the other event starts, but before the other event finishes (events have an overlapping period of time).
The method determines whether the input value's start and end timestamp indicate an overlap with the first parameter's start and end timestamp, such that A starts before B starts and A ends after B started but before B ends.
If used with one parameter, for example in a.overlaps(b)
, the method returns true if the start timestamp of A is before the start timestamp of B and the end timestamp of A and is before the end timestamp of B.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.overlaps(b) // Above matches when: // a.startTimestamp < b.startTimestamp < a.endTimestamp < b.endTimestamp
If providing two parameters, for example in a.overlaps(b, 5 sec)
, the method returns true if, in addition, the difference between the end timestamp of A and the start timestamp of B is equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.overlaps(b, 5 sec) // Above matches when: // a.startTimestamp < b.startTimestamp < a.endTimestamp < b.endTimestamp and // 0 <= a.endTimestamp - b.startTimestamp <= 5 seconds
If providing three parameters, for example in a.overlaps(b, 5 sec, 10 sec)
, the method returns true if, in addition, the difference between the end timestamp of A and the start timestamp of B is between 5 and 10 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.overlaps(b, 5 sec, 10 sec) // Above matches when: // a.startTimestamp < b.startTimestamp < a.endTimestamp < b.endTimestamp and // 5 seconds <= a.endTimestamp - b.startTimestamp <= 10 seconds
The overlappedBy
date-time method returns true if the parameter event starts before the input event starts and the parameter event finishes after the input event starts, but before the input event finishes (events have an overlapping period of time).
The method determines whether the input value's start and end timestamp indicate an overlap with the first parameter's start and end timestamp, such that B starts before A starts and B ends after A started but before A ends.
If used with one parameter, for example in a.overlappedBy(b)
, the method returns true if the start timestamp of B is before the start timestamp of A and the end timestamp of B and is before the end timestamp of A.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.overlappedBy(b) // Above matches when: // b.startTimestamp < a.startTimestamp < b.endTimestamp < a.endTimestamp
If providing two parameters, for example in a.overlappedBy(b, 5 sec)
, the method returns true if, in addition, the difference between the end timestamp of B and the start timestamp of A is equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.overlappedBy(b, 5 sec) // Above matches when: // b.startTimestamp < a.startTimestamp < b.endTimestamp < a.endTimestamp and // 0 <= b.endTimestamp - a.startTimestamp <= 5 seconds
If providing three parameters, for example in a.overlappedBy(b, 5 sec, 10 sec)
, the method returns true if, in addition, the difference between the end timestamp of B and the start timestamp of A is between 5 and 10 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.overlappedBy(b, 5 sec, 10 sec) // Above matches when: // b.startTimestamp < a.startTimestamp < b.endTimestamp < a.endTimestamp and // 5 seconds <= b.endTimestamp - a.startTimestamp <= 10 seconds
The starts
date-time method returns true if an event and another event start at the same time and the event's end happens before the other event's end.
The method determines whether the start timestamps of the input value and the first parameter are the same and the end timestamp of the input value is before the end timestamp of the first parameter.
If used with one parameter, for example in a.starts(b)
, the method returns true if the start timestamp of A and B are the same and the end timestamp of A is before the end timestamp of B.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.starts(b) // Above matches when: // a.startTimestamp = b.startTimestamp and a.endTimestamp < b.endTimestamp
If providing two parameters, for example in a.starts(b, 5 sec)
, the method returns true if the difference between the start timestamps of A and B is between is equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.starts(b, 5 sec) // Above matches when: // abs(a.startTimestamp - b.startTimestamp) <= 5 seconds and // a.endTimestamp < b.endTimestamp
A negative value for the interval parameter is not allowed. If your interval parameter is itself an expression that returns a negative value the engine logs a warning message and returns null.
The startedBy
date-time method returns true if an event and another event start at the same time and the other event's end happens before the input event's end.
The method determines whether the start timestamp of the input value and the first parameter are the same and the end timestamp of the first parameter is before the end timestamp of the input value.
If used with one parameter, for example in a.startedBy(b)
, the method returns true if the start timestamp of A and B are the same and the end timestamp of B is before the end timestamp of A.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.startedBy(b) // Above matches when: // a.startTimestamp = b.startTimestamp and b.endTimestamp < a.endTimestamp
If providing two parameters, for example in a.startedBy(b, 5 sec)
, the method returns true if the difference between the start timestamps of A and B is between is equal to or less then 5 seconds.
Sample EPL:
select * from A.std:lastevent() as a, B.std:lastevent() as b where a.startedBy(b, 5 sec) // Above matches when: // abs(a.startTimestamp - b.startTimestamp) <= 5 seconds and // b.endTimestamp < a.endTimestamp
A negative value for the interval parameter is not allowed. If your interval parameter is itself an expression that returns a negative value the engine logs a warning message and returns null.