# The Java Embedded Aggregator Class DistinctCount Aggregate

DistinctCountAggregate implements the "distinct count" aggregation.

### For an overview see page Java Aggregator Class

### Class Definition

        public static class DistinctCountAggregate implements Aggregate
        {
            public void initialize(Object val)
            {
                accumulate(val);
            }

            public void accumulate(Object val)
            {
                set.add(val);
            }

            public Object result()
            {
                return new Long(set.size());
            }

            public void merge(Aggregate other)
            {
                set.addAll(((DistinctCountAggregate)other).set);
            }

            Set set = new HashSet();
        }