public AggregateCount getCounts(Interval interval, AggregateCountResolution resolution) {
		DateTime start = interval.getStart();
		DateTime end = interval.getEnd();
		Chronology c = interval.getChronology();

		long[] counts;
		if (resolution == AggregateCountResolution.minute) {
			List<long[]> days = accumulateDayCounts(minuteCountsByDay, start, end, 60 * 24);

			counts = MetricUtils.concatArrays(days, interval.getStart().getMinuteOfDay(),
					interval.toPeriod().toStandardMinutes().getMinutes() + 1);
		}
		else if (resolution == AggregateCountResolution.hour) {
			List<long[]> days = accumulateDayCounts(hourCountsByDay, start, end, 24);

			counts = MetricUtils.concatArrays(days, interval.getStart().getHourOfDay(),
					interval.toPeriod().toStandardHours().getHours() + 1);
		}
		else if (resolution == AggregateCountResolution.day) {
			DateTime startDay = new DateTime(c.dayOfYear().roundFloor(start.getMillis()));
			DateTime endDay = new DateTime(c.dayOfYear().roundFloor(end.plusDays(1).getMillis()));
			int nDays = Days.daysBetween(startDay, endDay).getDays();
			DateTime cursor = new DateTime(c.year().roundFloor(interval.getStartMillis()));
			List<long[]> yearDays = new ArrayList<long[]>();
			DateTime endYear = new DateTime(c.year().roundCeiling(end.getMillis()));

			while (cursor.isBefore(endYear)) {
				long[] dayCounts = dayCountsByYear.get(cursor.getYear());
				if (dayCounts == null) {
					// Querying where we have no data
					dayCounts = new long[daysInYear(cursor.getYear())];
				}
				yearDays.add(dayCounts);
				cursor = cursor.plusYears(1);
			}

			counts = MetricUtils.concatArrays(yearDays, startDay.getDayOfYear() - 1, nDays);

		}
		else if (resolution == AggregateCountResolution.month) {
			DateTime startMonth = new DateTime(c.monthOfYear().roundFloor(interval.getStartMillis()));
			DateTime endMonth = new DateTime(c.monthOfYear().roundFloor(end.plusMonths(1).getMillis()));
			int nMonths = Months.monthsBetween(startMonth, endMonth).getMonths();
			DateTime cursor = new DateTime(c.year().roundFloor(interval.getStartMillis()));
			List<long[]> yearMonths = new ArrayList<long[]>();
			DateTime endYear = new DateTime(c.year().roundCeiling(end.getMillis()));

			while (cursor.isBefore(endYear)) {
				long[] monthCounts = monthCountsByYear.get(cursor.getYear());
				if (monthCounts == null) {
					monthCounts = new long[12];
				}
				yearMonths.add(monthCounts);
				cursor = cursor.plusYears(1);
			}

			counts = MetricUtils.concatArrays(yearMonths, startMonth.getMonthOfYear() - 1 , nMonths);
		}
		else if (resolution == AggregateCountResolution.year) {
			DateTime startYear = new DateTime(interval.getStart().getYear(), 1, 1, 0, 0);
			DateTime endYear   =  new DateTime(end.getYear() + 1, 1, 1, 0, 0);
			int nYears = Years.yearsBetween(startYear, endYear).getYears();
			counts = new long[nYears];

			for (int i = 0; i < nYears; i++) {
				long[] monthCounts = monthCountsByYear.get(startYear.plusYears(i).getYear());
				counts[i] = MetricUtils.sum(monthCounts);
			}

		}
		else {
			throw new IllegalStateException("Shouldn't happen. Unhandled resolution: " + resolution);
		}
		return new AggregateCount(getName(), interval, counts, resolution);
	}
A counter that tracks integral values but also remembers how its value was distributed over time.

<p>
This core class only holds data structures. Depending on backing stores, logic for computing totals may be
implemented in a specialization of this class or at the repository level.
</p>

@author Luke Taylor
@author Eric Bottard
spring-xd-analytics/src/main/java/org/springframework/xd/analytics/metrics/memory/InMemoryAggregateCounter.java