@Override
    public void init(String attributeName, Attribute.Type attributeType) {
        Attribute set;
        Expression setInitialValue;

        // distinct-count is not supported for object types.
        if (attributeType.equals(Attribute.Type.FLOAT) || attributeType.equals(Attribute.Type.DOUBLE)
                || attributeType.equals(Attribute.Type.INT) || attributeType.equals(Attribute.Type.LONG)
                || attributeType.equals(Attribute.Type.STRING) || attributeType.equals(Attribute.Type.BOOL)) {
            set = new Attribute("AGG_SET_".concat(attributeName), Attribute.Type.OBJECT);
            setInitialValue = Expression.function("createSet", Expression.variable(attributeName));
        } else {
            throw new SiddhiAppRuntimeException(
                    "Distinct count aggregation cannot be executed on attribute type " + attributeType.toString());
        }

        this.baseAttributes = new Attribute[]{set};
        this.baseAttributesInitialValues = new Expression[]{setInitialValue};
    }
{@link IncrementalAttributeAggregator} to calculate count based on an event attribute.
modules/siddhi-core/src/main/java/io/siddhi/core/query/selector/attribute/aggregator/incremental/DistinctCountIncrementalAttributeAggregator.java