StarTreeRecordStoreCircularBufferImpl implements StarTreeRecordStore { @Override public void clear() { synchronized (sync) { buffer.clear(); while (buffer.position() < buffer.limit()) { for (DimensionSpec dimensionSpec : dimensionSpecs) { buffer.getInt(); } for (int i = 0; i < numTimeBuckets; i++) { buffer.getLong(); for (MetricSpec spec : metricSpecs) { buffer.putInt(0); } } } } } 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 testClear() throws Exception { recordStore.clear(); long sum = 0; for (StarTreeRecord record : recordStore) { for (Long timeWindow : record.getMetricTimeSeries().getTimeWindowSet()) { sum += record.getMetricTimeSeries().get(timeWindow, "M").intValue(); } } Assert.assertEquals(sum, 0); }