0

I am trying to use Esper.

My question is about polymorphism between events.

Example (pseudocode):

I use two classes GPSEvent and PositionEvent as eventtypes. They may look like:

class GPSEvent{
    double longitude
    double latitude
}

and

class PositionEvent extends GPSEvent{
    Date timeOfOccurence
}

If I use the Rule:

select * from GPSEvent.win:length_batch(5)

and following Events would be sent into the engine: GPSEvent g1, GPSEvent g2, GPSEvent g3, GPSEvent g4, PositionEvent p1

the rule would trigger.

My question is now how to prevent the triggering if subtype events are sent

or

how to trigger only if the eventtype is the supertype without any subtypes?

Are there any best practices without adding complexity to the rules oder use "overhead" inside of the eventtype classes?


Additional information:

I would like to route a PositionEvent into the engine out of a subscriber after detecting 5 GPSEvents

dehx
  • 1
  • 1

1 Answers1

0

I see three ways. You can add a flag to the class (no overhead as its a const, for example "getType() {return "P"}", this provides a property "type"). You can make a EPL UDF for custom checking. You can use "instanceof/typeof".

user650839
  • 2,594
  • 1
  • 13
  • 9