StarTreeRecordStoreCircularBufferImpl implements StarTreeRecordStore { @Override public Iterator<StarTreeRecord> iterator() { synchronized (sync) { List<StarTreeRecord> list = new LinkedList<StarTreeRecord>(); buffer.clear(); int[] currentDimensions = new int[dimensionSpecs.size()]; Number[] currentMetrics = new Number[metricSpecs.size()]; while (buffer.position() < buffer.limit()) { getDimensions(currentDimensions); DimensionKey dimensionKey = translateDimensions(currentDimensions); MetricTimeSeries timeSeries = new MetricTimeSeries(metricSchema); for (int i = 0; i < numTimeBuckets; i++) { long time = getMetrics(currentMetrics); for (int j = 0; j < metricSpecs.size(); j++) { timeSeries.increment(time, metricSpecs.get(j).getName(), currentMetrics[j]); } } list.add(new StarTreeRecordImpl(config, dimensionKey, timeSeries)); } return list.iterator(); } } StarTreeRecordStoreCircularBufferImpl(UUID nodeId,
                                               File file,
                                               StarTreeConfig config,
                                               Map<String, Map<String, Integer>> forwardIndex,
                                               int numTimeBuckets); @Override Long getMinTime(); @Override Long getMaxTime(); @Override Map<TimeRange, Integer> getTimeRangeCount(); @Override void update(StarTreeRecord record); @Override Iterator<StarTreeRecord> iterator(); @Override void clear(); @Override void open(); @Override void close(); @Override int getRecordCount(); @Override int getRecordCountEstimate(); @Override int getCardinality(String dimensionName); @Override String getMaxCardinalityDimension(); @Override String getMaxCardinalityDimension(Collection<String> blacklist); @Override Set<String> getDimensionValues(String dimensionName); @Override Number[] getMetricSums(StarTreeQuery query); @Override MetricTimeSeries getTimeSeries(StarTreeQuery query); static void fillBuffer(final OutputStream outputStream,
                                final StarTreeConfig config,
                                final Map<String, Map<String, Integer>> forwardIndex,
                                final Iterable<StarTreeRecord> records,
                                final int numTimeBuckets,
                                final boolean keepMetricValues); @Override Map<String, Map<String, Integer>> getForwardIndex();  }
@Test public void testIterator() throws Exception { long sum = 0; for (StarTreeRecord record : recordStore) { for (Long timeWindow : record.getMetricTimeSeries().getTimeWindowSet()) { sum += record.getMetricTimeSeries().get(timeWindow, "M").intValue(); } } Assert.assertEquals(sum, numRecords); }