All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.espertech.esper.epl.enummethod.eval.EnumEvalMostLeastFrequentScalar Maven / Gradle / Ivy

Go to download

Complex event processing and event series analysis component

There is a newer version: 7.1.0
Show newest version
package com.espertech.esper.epl.enummethod.eval;

import com.espertech.esper.client.EventBean;
import com.espertech.esper.epl.expression.ExprEvaluator;
import com.espertech.esper.epl.expression.ExprEvaluatorContext;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

public class EnumEvalMostLeastFrequentScalar extends EnumEvalBase implements EnumEval {

    private final boolean isMostFrequent;

    public EnumEvalMostLeastFrequentScalar(int streamCountIncoming, boolean isMostFrequent) {
        super(streamCountIncoming);
        this.isMostFrequent = isMostFrequent;
    }

    public Object evaluateEnumMethod(Collection target, boolean isNewData, ExprEvaluatorContext context) {
        Map items = new LinkedHashMap();

        for (Object next : target) {
            Integer existing = items.get(next);

            if (existing == null) {
                existing = 1;
            }
            else {
                existing++;
            }
            items.put(next, existing);
        }

        return EnumEvalMostLeastFrequentEvent.getResult(items, isMostFrequent);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy