Event aggregation - fanhubgt/StreamEPS GitHub Wiki

Event Aggregation Functions

These are just test cases from the aggregation test package in the core sub-project. You can choose to run this main class.

Average

 This is an event average aggregation function for a stream on unbound data from an event processing network.
 Sample Code:
   public class AvgAggTest extends TestCase {
    
    public AvgAggTest(String testName) {
        super(testName);
    }
    public void testAvgAgg() {
        String[] value = {"23", "10", "5", "45", "23", "15", "6", "5", "5"};
        AvgAggregation aa = new AvgAggregation();
        AggregateValue av = new AggregateValue(0, 0);
        for (String v : value) {
            aa.process(av, Double.parseDouble(v));
        }
        assertEquals(15.222222222222221, aa.getValue());
    }
}

Distinct Concatenation

   This distinct concatenation aggregation function simply concatenates a string of values separated by a separator
   defined by you. The default separator used in this function is a comma (",").
 public class AggregationTest extends TestCase {

    public AggregationTest(String testName) {
        super(testName);
    }
    public void testDAggregation() {
        String[] value = {"23", "10", "5", "45", "23", "15", "6", "5", "5"};
        DistinctConcatAggregation aggregation = new DistinctConcatAggregation();
        StringAggregateSetValue agg = new StringAggregateSetValue();
        for (String v : value) {
            aggregation.process(agg, v);
        }
        assertEquals("[23,10,5,45,15,6]", aggregation.getValue());
    }
}