@Test public void sparsePrintTest() { TimeSeries timeSeries = new TimeSeries(); timeSeries.record(mBase); timeSeries.record(mBase + 8L * Constants.SECOND_NANO); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(outputStream); timeSeries.sparsePrint(printStream); StringBuilder sb = new StringBuilder(); sb.append( String.format("Time series starts at %d with width %d.%n", mBase, Constants.SECOND_NANO)); sb.append(String.format("%d %d%n", 0, 1)); sb.append(String.format("%d %d%n", 8, 1)); Assert.assertEquals(sb.toString(), outputStream.toString()); }
public void sparsePrint(PrintStream stream) { if (mSeries.isEmpty()) { return; } long start = mSeries.firstKey(); stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano); for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) { stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue()); } }
TimeSeries implements Serializable { public void sparsePrint(PrintStream stream) { if (mSeries.isEmpty()) { return; } long start = mSeries.firstKey(); stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano); for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) { stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue()); } } }
TimeSeries implements Serializable { public void sparsePrint(PrintStream stream) { if (mSeries.isEmpty()) { return; } long start = mSeries.firstKey(); stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano); for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) { stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue()); } } TimeSeries(long widthNano);  TimeSeries(); }
TimeSeries implements Serializable { public void sparsePrint(PrintStream stream) { if (mSeries.isEmpty()) { return; } long start = mSeries.firstKey(); stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano); for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) { stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue()); } } TimeSeries(long widthNano);  TimeSeries(); void record(long timeNano); void record(long timeNano, int numEvents); int get(long timeNano); long getWidthNano(); TreeMap<Long, Integer> getSeries(); void add(TimeSeries other); Summary getSummary(); @Override String toString(); void sparsePrint(PrintStream stream); void print(PrintStream stream); }
TimeSeries implements Serializable { public void sparsePrint(PrintStream stream) { if (mSeries.isEmpty()) { return; } long start = mSeries.firstKey(); stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano); for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) { stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue()); } } TimeSeries(long widthNano);  TimeSeries(); void record(long timeNano); void record(long timeNano, int numEvents); int get(long timeNano); long getWidthNano(); TreeMap<Long, Integer> getSeries(); void add(TimeSeries other); Summary getSummary(); @Override String toString(); void sparsePrint(PrintStream stream); void print(PrintStream stream);  }