Pwachira (1) [Avatar] Offline
#1
On pg 349 there is a comment #3 stating "adds new amount to total sum". this is repeated in the explanation following the code.
To me , especially after reading esper documentation, it seems the addition has already taken place at this point. My understanding is that esper does the addition when a 2nd event is received since the widow length is 2.
What happens at the event listener is not the addition but simply the assignment of the sum that's already calculated to the private variable sumAmount.

I'm I mistaken?
Also what does newEvents[0] represent? The newest event or the newest query results?

Public class EventLengthWindowTest {
Private int sumAmount;

Public void testEventLengthWindow(){
configuration ...

EPStatement epstatement = epservice.get......
.createEPL.....
epStatement.addListener.......... // this is where the comment about

// addition is found



}

}
tijs.rademakers (494) [Avatar] Offline
#2
Re: Chapter 14 esper pg 349: code description ; calculation of sum of window
Hi,

Right, Esper has already calculated the sum and on that line of code, only the sumAmount variable is filled with that value. newEvents represent the new events that have occurred. So newEvents[0] is the first event out of the new events and in this example we expect that there's only one event.

Best regards,

Tijs