@Override
    protected StateFactory<AggregatorState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                                 ProcessingMode processingMode,
                                                 boolean outputExpectsExpiredEvents, ConfigReader configReader,
                                                 SiddhiQueryContext siddhiQueryContext) {
        if (attributeExpressionExecutors.length != 1) {
            throw new OperationNotSupportedException("Sum aggregator has to have exactly 1 parameter, currently " +
                    attributeExpressionExecutors.length
                    + " parameters provided");
        }
        Attribute.Type type = attributeExpressionExecutors[0].getReturnType();
        switch (type) {
            case INT:
            case LONG:
                returnType = Attribute.Type.LONG;
                break;
            case FLOAT:
            case DOUBLE:
                returnType = Attribute.Type.DOUBLE;
                break;
            default:
                throw new OperationNotSupportedException("Sum not supported for " + returnType);
        }
        return new StateFactory<AggregatorState>() {
            @Override
            public AggregatorState createNewState() {
                switch (type) {
                    case FLOAT:
                        return new AggregatorStateFloat();
                    case INT:
                        return new AggregatorStateInt();
                    case LONG:
                        return new AggregatorStateLong();
                    case DOUBLE:
                        return new AggregatorStateDouble();
                    default:
                        throw new OperationNotSupportedException("Sum not supported for " + returnType);
                }
            }
        };


    }
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 SumAttributeAggregatorExecutor} configuration reader.
@param siddhiQueryContext           Siddhi query runtime context
modules/siddhi-core/src/main/java/io/siddhi/core/query/selector/attribute/aggregator/SumAttributeAggregatorExecutor.java