0

The issue that I have is using the clause 'partition by' in 'Match Recognize', the 'partition by' clause seems to support just 99 different events because when I have 100 or more different events it does not group correctly. to test this I have the following EPL query:

select * from TemperatureSensorEvent
match_recognize (
  partition by id
  measures A.id as a_id, A.temperature as a_temperature
  pattern (A)
  define 
    A as prev(A.id) is null
)

I am using this query basically to get the first event (first temperature) of each device, however testing with 10, 20, 50, ... 99 different devices it works fine but when I have more than 99, it seems that ESPER resets all the events send before the device with id=100, and if I send a event that is of the device with id=001, ESPER takes it as if it was the first event.

it seems that 'partition by' just supports 99 different events and if you add one more the EPL is reset or something like that. Is it a restriction that 'partition by' clause has?, how I can increase this threshold because I have more than 100 devices?.

ESPER version: 5.1.0

Thanks in advance

Demo Class:

public class EsperDemo
{
    public static void main(String[] args)
    {
         Configuration config = new Configuration();
         config.addEventType("TemperatureSensorEvent", TemperatureSensorEvent.class.getName());
         EPServiceProvider esperProvider = EPServiceProviderManager.getProvider("EsperDemoEngine", config);
         EPAdministrator administrator = esperProvider.getEPAdministrator();
         EPRuntime esperRuntime = esperProvider.getEPRuntime();

         // query to get the first event of each temperature sensor
         String query = "select * from TemperatureSensorEvent "
            + "match_recognize ( "
            + "       partition by id "
            + "       measures A.id as a_id, A.temperature as a_temperature "
            + "       after match skip to next row "
            + "       pattern (A) "
            + "       define "
            + "               A as prev(A.id) is null "
            + ")";

         TemperatureSubscriber temperatureSubscriber = new TemperatureSubscriber();

         EPStatement cepStatement = administrator.createEPL(query);
         cepStatement.setSubscriber(temperatureSubscriber);

         TemperatureSensorEvent temperature;
         Random random = new Random();

         int sensorsQuantity = 100;  // it works fine until 99 sensors
         for (int i = 1; i <= sensorsQuantity; i++) {
             temperature = new TemperatureSensorEvent(i, random.nextInt(20));
             System.out.println("Sending temperature: " + temperature.toString());
             esperRuntime.sendEvent(temperature);
         }
         temperature = new TemperatureSensorEvent(1, 64);
         System.out.println("Sending temperature: sensor with id=1 again: " + temperature.toString());
         esperRuntime.sendEvent(temperature);
     }
 }

0 Answers0