@Override
    public Object processAdd(Object data, AggregatorState state) {
        Set inputSet = (Set) data;
        for (Object o : inputSet) {
            state.set.add(o);
            if (state.counter != null) {
                Integer currentCount = state.counter.get(o);
                if (currentCount == null) {
                    state.counter.put(o, 1);
                } else {
                    state.counter.put(o, currentCount + 1);
                }
            }
        }
        // Creating a new set object as the returned set reference is kept until the aggregated values are
        // inserted into the store
        Set returnSet = new HashSet();
        returnSet.addAll(state.set);
        return returnSet;
    }
The initialization method for FunctionExecutor

@param attributeExpressionExecutors are the executors of each attributes in the function
@param processingMode               query processing mode
@param outputExpectsExpiredEvents   is expired events sent as output
@param configReader                 this hold the {@link CountAttributeAggregatorExecutor} configuration reader.
@param siddhiQueryContext           Siddhi query runtime context
modules/siddhi-core/src/main/java/io/siddhi/core/query/selector/attribute/aggregator/UnionSetAttributeAggregatorExecutor.java