Examples of OneEventCollection


Examples of com.espertech.esper.collection.OneEventCollection

        if ((eventData == null) || (eventData.length == 0))
        {
            return null;
        }

        OneEventCollection filtered = null;
        for (EventBean event : eventData)
        {
            eventPerStream[0] = event;
            boolean pass = true;
            for (ExprEvaluator filter : filterList)
            {
                Boolean result = (Boolean) filter.evaluate(eventPerStream, isNewData, exprEvaluatorContext);
                if ((result != null) && (!result))
                {
                    pass = false;
                    break;
                }
            }

            if (pass)
            {
                if (filtered == null)
                {
                    filtered = new OneEventCollection();
                }
                filtered.add(event);
            }
        }

        if (filtered == null)
        {
            return null;
        }
        return filtered.toArray();
    }
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

    // Called based on schedule evaluation registered when a variable changes (new data is null).
    // Called when new data arrives.
    private void expire(EventBean[] newData, EventBean[] oldData) {

        OneEventCollection expired = null;
        if (oldData != null) {
            expired = new OneEventCollection();
            expired.add(oldData);
        }
        int expiredCount = 0;
        if (!window.isEmpty()) {
            TimestampEventPair newest = window.getLast();

            while (true) {
                TimestampEventPair first = window.getFirst();

                boolean pass = checkEvent(first, newest, expiredCount);
                if (!pass) {
                    if (expired == null) {
                         expired = new OneEventCollection();
                    }
                    EventBean removed = window.removeFirst().getEvent();
                    expired.add(removed);
                    if (aggregationService != null) {
                        removedEvents[0] = removed;
                        aggregationService.applyLeave(removedEvents, null, agentInstanceContext);
                    }
                    expiredCount++;
                }
                else {
                    break;
                }

                if (window.isEmpty()) {
                    if (aggregationService != null) {
                        aggregationService.clearResults(agentInstanceContext);
                    }
                    break;
                }
            }
        }

        // Check for any events that get pushed out of the window
        EventBean[] expiredArr = null;
        if (expired != null)
        {
            expiredArr = expired.toArray();
        }

        // update event buffer for access by expressions, if any
        if (viewUpdatedCollection != null)
        {
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

        return parent.getEventType();
    }

    public final void update(EventBean[] newData, EventBean[] oldData)
    {
        OneEventCollection postOldData = null;

        if (this.hasViews())
        {
            postOldData = new OneEventCollection();
        }

        if (newData != null)
        {
            for (int i = 0; i < newData.length; i++)
            {
                // Obtain unique value
                MultiKey<Object> key = getUniqueKey(newData[i]);

                // If there are no child views, just update the own collection
                if (!this.hasViews())
                {
                    mostRecentEvents.put(key, newData[i]);
                    continue;
                }

                // Post the last value as old data
                EventBean lastValue = mostRecentEvents.get(key);
                if (lastValue != null)
                {
                    postOldData.add(lastValue);
                }

                // Override with recent event
                mostRecentEvents.put(key, newData[i]);
            }
        }

        if (oldData != null)
        {
            for (int i = 0; i < oldData.length; i++)
            {
                // Obtain unique value
                MultiKey<Object> key = getUniqueKey(oldData[i]);

                // If the old event is the current unique event, remove and post as old data
                EventBean lastValue = mostRecentEvents.get(key);
                if (lastValue != oldData[i])
                {
                    continue;
                }

                postOldData.add(lastValue);
                mostRecentEvents.remove(key);
            }
        }


        // If there are child views, fireStatementStopped update method
        if (this.hasViews())
        {
            if (postOldData.isEmpty())
            {
                updateChildren(newData, null);
            }
            else
            {
                updateChildren(newData, postOldData.toArray());
            }
        }
    }
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

        };
    }

    @Override
    public void stopView() {
        OneEventCollection oldEvents = new OneEventCollection();
        for (Map.Entry<EventBean, EventBean> oldEvent : newToOldEventMap.entrySet()) {
            oldEvents.add(oldEvent.getValue());
        }
        if (!oldEvents.isEmpty()) {
            updateChildren(null, oldEvents.toArray());
        }
        newToOldEventMap.clear();
    }
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

        return parent.getEventType();
    }

    public final void update(EventBean[] newData, EventBean[] oldData)
    {
        OneEventCollection oldDataToPost = null;
        if (oldData != null)
        {
            for (EventBean anOldData : oldData)
            {
                boolean removed = events.remove(anOldData);
                if (removed)
                {
                    if (oldDataToPost == null)
                    {
                        oldDataToPost = new OneEventCollection();
                    }
                    oldDataToPost.add(anOldData);
                }
            }
        }

        // add data points to the timeWindow
        OneEventCollection newDataToPost = null;
        if ((!isClosed) && (newData != null))
        {
            for (EventBean aNewData : newData)
            {
                events.add(aNewData);
                if (newDataToPost == null)
                {
                    newDataToPost = new OneEventCollection();
                }
                newDataToPost.add(aNewData);
            }
        }

        // If there are child views, call update method
        if ((this.hasViews()) && ((newDataToPost != null) || (oldDataToPost != null)))
        {
            updateChildren((newDataToPost != null) ? newDataToPost.toArray() : null,
                           (oldDataToPost != null) ? oldDataToPost.toArray() : null);
        }
    }
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

        return parent.getEventType();
    }

    public final void update(EventBean[] newData, EventBean[] oldData)
    {
        OneEventCollection newDataToPost = null;
        OneEventCollection oldDataToPost = null;

        // add data points to the window as long as its not full, ignoring later events
        if (newData != null)
        {
            for (EventBean aNewData : newData)
            {
                if (indexedEvents.size() < size)
                {
                    if (newDataToPost == null)
                    {
                        newDataToPost = new OneEventCollection();
                    }
                    newDataToPost.add(aNewData);
                    indexedEvents.add(aNewData);
                }
            }
        }

        if (oldData != null)
        {
            for (EventBean anOldData : oldData)
            {
                boolean removed = indexedEvents.remove(anOldData);
                if (removed)
                {
                    if (oldDataToPost == null)
                    {
                        oldDataToPost = new OneEventCollection();
                    }
                    oldDataToPost.add(anOldData);
                }
            }
        }

        // If there are child views, call update method
        if ((this.hasViews()) && ((newDataToPost != null) || (oldDataToPost != null)))
        {
            updateChildren((newDataToPost != null) ? newDataToPost.toArray() : null,
                           (oldDataToPost != null) ? oldDataToPost.toArray() : null);
        }
    }
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

        this.parent = parent;
    }

    public void handleMatching(EventBean[] triggerEvents, EventBean[] matchingEvents)
    {
        OneEventCollection newData = new OneEventCollection();
        OneEventCollection oldData = null;
        EventBean[] eventsPerStream = new EventBean[2];

        if ((matchingEvents == null) || (matchingEvents.length == 0)){
            for (EventBean triggerEvent : triggerEvents) {
                eventsPerStream[1] = triggerEvent;
                for (NamedWindowOnMergeMatch action : parent.getNamedWindowOnMergeHelper().getUnmatched()) {
                    if (!action.isApplies(eventsPerStream, super.getExprEvaluatorContext())) {
                        continue;
                    }
                    action.apply(null, eventsPerStream, newData, oldData, super.getExprEvaluatorContext());
                    break// apply no other actions
                }
            }
        }
        else {

            // handle update/
            oldData = new OneEventCollection();

            for (EventBean triggerEvent : triggerEvents) {
                eventsPerStream[1] = triggerEvent;
                for (EventBean matchingEvent : matchingEvents) {
                    eventsPerStream[0] = matchingEvent;
                    for (NamedWindowOnMergeMatch action : parent.getNamedWindowOnMergeHelper().getMatched()) {
                        if (!action.isApplies(eventsPerStream, super.getExprEvaluatorContext())) {
                            continue;
                        }
                        action.apply(matchingEvent, eventsPerStream, newData, oldData, super.getExprEvaluatorContext());
                        break// apply no other actions
                    }
                }
            }
        }

        if (!newData.isEmpty() || (oldData != null && !oldData.isEmpty()))
        {
            if ((MetricReportingPath.isMetricsEnabled) && (parent.getCreateNamedWindowMetricHandle().isEnabled()) && !newData.isEmpty())
            {
                parent.getMetricReportingService().accountTime(parent.getCreateNamedWindowMetricHandle(), 0, 0, newData.toArray().length);
            }

            // Events to delete are indicated via old data
            // The on-merge listeners receive the events deleted, but only if there is interest
            if (parent.getStatementResultService().isMakeNatural()) {
                EventBean[] eventsPerStreamNaturalNew = newData.isEmpty() ? null : newData.toArray();
                EventBean[] eventsPerStreamNaturalOld = (oldData == null || oldData.isEmpty()) ? null : oldData.toArray();
                this.rootView.update(EventBeanUtility.denaturalize(eventsPerStreamNaturalNew), EventBeanUtility.denaturalize(eventsPerStreamNaturalOld));
                updateChildren(eventsPerStreamNaturalNew, eventsPerStreamNaturalOld);
            }
            else {
                EventBean[] eventsPerStreamNew = newData.isEmpty() ? null : newData.toArray();
                EventBean[] eventsPerStreamOld = (oldData == null || oldData.isEmpty()) ? null : oldData.toArray();
                this.rootView.update(eventsPerStreamNew, eventsPerStreamOld);
                if (parent.getStatementResultService().isMakeSynthetic()) {
                    updateChildren(eventsPerStreamNew, eventsPerStreamOld);
                }
            }
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

        if ((matchingEvents == null) || (matchingEvents.length == 0)){
            return;
        }
        EventBean[] eventsPerStream = new EventBean[2];

        OneEventCollection newData = new OneEventCollection();
        OneEventCollection oldData = new OneEventCollection();

        for (EventBean triggerEvent : triggerEvents) {
            eventsPerStream[1] = triggerEvent;
            for (EventBean matchingEvent : matchingEvents) {
                EventBean copy = parent.getUpdateHelper().update(matchingEvent, eventsPerStream, super.getExprEvaluatorContext());
                newData.add(copy);
                oldData.add(matchingEvent);
            }
        }

        if (!newData.isEmpty())
        {
            // Events to delete are indicated via old data
            this.rootView.update(newData.toArray(), oldData.toArray());

            // The on-delete listeners receive the events deleted, but only if there is interest
            if (parent.getStatementResultService().isMakeNatural() || parent.getStatementResultService().isMakeSynthetic()) {
                updateChildren(newData.toArray(), oldData.toArray());
            }
        }

        // Keep the last delete records
        lastResult = matchingEvents;
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

        setup(onTriggerDesc, triggeringEventType, triggeringStreamName, statementContext);
    }

    public void handleMatching(EventBean[] triggerEvents, EventBean[] matchingEvents)
    {
        OneEventCollection newData = new OneEventCollection();
        OneEventCollection oldData = null;
        EventBean[] eventsPerStream = new EventBean[2];

        if ((matchingEvents == null) || (matchingEvents.length == 0)){
            for (EventBean triggerEvent : triggerEvents) {
                eventsPerStream[1] = triggerEvent;
                for (NamedWindowOnMergeMatch action : unmatched) {
                    if (!action.isApplies(eventsPerStream, super.getExprEvaluatorContext())) {
                        continue;
                    }
                    action.apply(null, eventsPerStream, newData, oldData, super.getExprEvaluatorContext());
                    break// apply no other actions
                }
            }
        }
        else {

            // handle update/
            oldData = new OneEventCollection();

            for (EventBean triggerEvent : triggerEvents) {
                eventsPerStream[1] = triggerEvent;
                for (EventBean matchingEvent : matchingEvents) {
                    eventsPerStream[0] = matchingEvent;
                    for (NamedWindowOnMergeMatch action : matched) {
                        if (!action.isApplies(eventsPerStream, super.getExprEvaluatorContext())) {
                            continue;
                        }
                        action.apply(matchingEvent, eventsPerStream, newData, oldData, super.getExprEvaluatorContext());
                        break// apply no other actions
                    }
                }
            }
        }

        if (!newData.isEmpty() || (oldData != null && !oldData.isEmpty()))
        {
            if ((MetricReportingPath.isMetricsEnabled) && (createWindowStatementHandle.getMetricsHandle().isEnabled()) && !newData.isEmpty())
            {
                metricReportingService.accountTime(createWindowStatementHandle.getMetricsHandle(), 0, 0, newData.toArray().length);
            }

            // Events to delete are indicated via old data
            // The on-merge listeners receive the events deleted, but only if there is interest
            if (statementResultService.isMakeNatural()) {
                EventBean[] eventsPerStreamNaturalNew = newData.isEmpty() ? null : newData.toArray();
                EventBean[] eventsPerStreamNaturalOld = (oldData == null || oldData.isEmpty()) ? null : oldData.toArray();
                this.rootView.update(EventBeanUtility.denaturalize(eventsPerStreamNaturalNew), EventBeanUtility.denaturalize(eventsPerStreamNaturalOld));
                updateChildren(eventsPerStreamNaturalNew, eventsPerStreamNaturalOld);
            }
            else {
                EventBean[] eventsPerStreamNew = newData.isEmpty() ? null : newData.toArray();
                EventBean[] eventsPerStreamOld = (oldData == null || oldData.isEmpty()) ? null : oldData.toArray();
                this.rootView.update(eventsPerStreamNew, eventsPerStreamOld);
                if (statementResultService.isMakeSynthetic()) {
                    updateChildren(eventsPerStreamNew, eventsPerStreamOld);
                }
            }
View Full Code Here

Examples of com.espertech.esper.collection.OneEventCollection

        if ((matchingEvents == null) || (matchingEvents.length == 0)){
            return;
        }
        EventBean[] eventsPerStream = new EventBean[2];

        OneEventCollection newData = new OneEventCollection();
        OneEventCollection oldData = new OneEventCollection();

        for (EventBean triggerEvent : triggerEvents) {
            eventsPerStream[1] = triggerEvent;
            for (EventBean matchingEvent : matchingEvents) {
                EventBean copy = updateHelper.update(matchingEvent, eventsPerStream, super.getExprEvaluatorContext());
                newData.add(copy);
                oldData.add(matchingEvent);
            }
        }

        if (!newData.isEmpty())
        {
            // Events to delete are indicated via old data
            this.rootView.update(newData.toArray(), oldData.toArray());

            // The on-delete listeners receive the events deleted, but only if there is interest
            if (statementResultService.isMakeNatural() || statementResultService.isMakeSynthetic()) {
                updateChildren(newData.toArray(), oldData.toArray());
            }
        }

        // Keep the last delete records
        lastResult = matchingEvents;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.