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?

                    } 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
                    } 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

Reply via email to