0

Hello I'm desperate trying to find a way in ESPER - CEP to output the events that have the max value. Here's a good example to illustrate my problem:

| value | category | date |

| 12.2 | A | yyyy-MM-dd HH:mm:ss |

| 13.3 | A | yyyy-MM-dd HH:mm:ss |

I want the following output:


| value | category | date |

| 13.3 | A | yyyy-MM-dd HH:mm:ss |

Very basic in SQL : select max(value), category date from tab group by category

Now in Esper, i have tried many things: output every, output last, contexts.. But couldn't find a solution :/ It either outputs nothing or outputs all the lines. With "output first every", it only ouputs the first line, regardless of the max() comparison.

Is there someone who has an idea of how to proceed to obtain the max(value) and group by a parameter from a stream?

Thanks for your help :)

Steve
  • 9,270
  • 5
  • 47
  • 61
  • So why is this tagged "drools"...??? – laune Nov 06 '14 at 15:43
  • Works for me. You can try in out in the online tool. Here is what you need to cut and paste into the tool at http://esper-epl-tryout.appspot.com/epltryout/index.html: – user3613754 Nov 06 '14 at 15:57
  • ====== Left Side ==== create schema StockTick(symbol string, price double); @Name('Out') select max(price) from StockTick group by symbol output last every 5 seconds; ===================== – user650839 Nov 06 '14 at 16:02
  • ====== Right Side === StockTick={symbol='GE', price=20.5} StockTick={symbol='GE', price=11.5} StockTick={symbol='GE', price=19.5} t=t.plus(5 seconds) ===================== – user650839 Nov 06 '14 at 16:03
  • I think what you are confused with is the question of when to trigger output? Esper is a streaming engine and without "output every" will output for each input. You can trigger output, for example, by sending an artificial trigger event indicating that all events were sent, or you could use the iterate API. – user650839 Nov 06 '14 at 16:03
  • wow it's exactly what i am looking for !!! what's the best way to do the "t=t.plus(5 seconds)" in java ? writing output every last 5 seconds doesn't output anything. do you have a short example ? – benjamin steiner Nov 07 '14 at 01:21
  • @user650839 i'm really close to end my problem ;) just need a little bit more guidance :) – benjamin steiner Nov 07 '14 at 11:42

1 Answers1

0

Doc link for controlling time keeping: http://esper.codehaus.org/esper-5.1.0/doc/reference/en-US/html_single/index.html#api-controlling-time

user650839
  • 2,594
  • 1
  • 13
  • 9
  • thanks a lot :) I look forward to testing that method ! – benjamin steiner Nov 08 '14 at 07:49
  • i tried @user650839 :/ But doesn't seem to work. what i have is the internalTimberEnabled set to "false". Now what I do is A) create statement "select * from tab output every 5 sec" B) statement.addListener C) sendEvent(new CurrentimeEvent(0); D) send 10 the events E) sendEvent(new CurrentimeEvent(5000) --> this only outputs only the first event and not the 9 remaining events... – benjamin steiner Nov 10 '14 at 15:13