On Sun, Aug 10, 2014 at 10:13 PM, Dilini Muthumala <[email protected]> wrote:
> Hi,
>
> In org.wso2.siddhi.core.query.processor.window.LengthWindowProcessor [1],
>
> I'm trying to figure out why we don't emit a current event, when index <
> toFullQueueSize - 1. Please see my comment given in the source code
> below. Since an event is being added to the window, I feel that the event
> has to be emitted as a current event.
>
> Any ideas?
>
> @Override
> protected void processEvent(InListEvent listEvent) {
> acquireLock();
> try {
> int toFullQueueSize = (lengthToKeep - window.size());
> if (listEvent.getActiveEvents() > toFullQueueSize) {
> InEvent[] newEvents = new InEvent[toFullQueueSize];
> int index = 0;
> for (int i = 0; i < listEvent.getActiveEvents(); i++) {
> InEvent inEvent = (InEvent) listEvent.getEvent(i);
> if (index < toFullQueueSize - 1) {
> newEvents[index] = inEvent;
> window.put(new RemoveEvent(inEvent,
> Long.MAX_VALUE));
> index++;
>
> //why don't we emit a current event here?
>
> Here we are not emitting an event as we are emitting all the events at
once at index == toFullQueueSize - 1
Note this code only executes when listEvent.getActiveEvents() >
toFullQueueSize so it will always reach index == toFullQueueSize - 1
> } else if (index == toFullQueueSize - 1) {
> newEvents[index] = inEvent;
> window.put(new RemoveEvent(inEvent,
> Long.MAX_VALUE));
> index++;
> nextProcessor.process(new InListEvent(newEvents));
> //emitting a current event
>
Here we are not emitting one event, here we emit toFullQueueSize number of
events because we can batch them.
> } else {
> RemoveEvent removeEvent = (RemoveEvent)
> window.poll();
>
> removeEvent.setExpiryTime(System.currentTimeMillis());
> nextProcessor.process(removeEvent);
> window.put(new RemoveEvent(inEvent,
> Long.MAX_VALUE));
> nextProcessor.process(inEvent);
> //emitting a current event
> }
> }
> } else {
> for (int i = 0; i < listEvent.getActiveEvents(); i++) {
> window.put(new RemoveEvent(listEvent.getEvent(i),
> Long.MAX_VALUE));
> }
> nextProcessor.process(listEvent);
> }
> } finally {
> releaseLock();
> }
> }
>
> Thanks,
> Dilini
>
> [1]
> https://github.com/wso2-dev/siddhi/blob/master/modules/siddhi-core/src/main/java/org/wso2/siddhi/core/query/processor/window/LengthWindowProcessor.java
> --
> *Dilini Muthumala*
> Software Engineer,
> WSO2 Inc.
>
> *E-mail :* [email protected]
> *Mobile: *+94713 400 029
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
--
*S. Suhothayan*
Technical Lead & Team Lead of WSO2 Complex Event Processor
*WSO2 Inc. *http://wso2.com
* <http://wso2.com/>*
lean . enterprise . middleware
*cell: (+94) 779 756 757 | blog: http://suhothayan.blogspot.com/
<http://suhothayan.blogspot.com/>twitter: http://twitter.com/suhothayan
<http://twitter.com/suhothayan> | linked-in:
http://lk.linkedin.com/in/suhothayan <http://lk.linkedin.com/in/suhothayan>*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev