private long[] convertToArray(Map<String, Long> map, int size, boolean unitOffset) {
		long[] values = new long[size];
		// Some joda fields (e.g. days of month are unit offset)
		int arrayOffset = unitOffset ? -1 : 0;
		for (Map.Entry<String, Long> cursor : map.entrySet()) {
			int offset = Integer.parseInt(cursor.getKey()) + arrayOffset;
			values[offset] = cursor.getValue();
		}
		return values;
	}
Will convert a (possibly sparse) map whose keys are String versions of numbers between 0 and size, to an array.
spring-xd-analytics/src/main/java/org/springframework/xd/analytics/metrics/redis/RedisAggregateCounterRepository.java