RegularTimeSeriesIndex extends AbstractTimeSeriesIndex { @Override public int getPointCount() { return pointCount; } RegularTimeSeriesIndex(long startTime, long endTime, long spacing); static RegularTimeSeriesIndex create(Instant start, Instant end, Duration spacing); static RegularTimeSeriesIndex create(Interval interval, Duration spacing); static RegularTimeSeriesIndex parseJson(JsonParser parser); long getStartTime(); long getEndTime(); long getSpacing(); @Override int getPointCount(); @Override long getTimeAt(int point); @Override int hashCode(); @Override boolean equals(Object obj); @Override String getType(); @Override void writeJson(JsonGenerator generator); @Override Iterator<Instant> iterator(); @Override Stream<Instant> stream(); @Override String toString(); static final String TYPE; }
@Test public void testPointCountSimple() { assertEquals(2, new RegularTimeSeriesIndex(0, 10, 10).getPointCount()); }
@Test public void testPointCountRounded() { assertEquals(3, new RegularTimeSeriesIndex(0, 19, 10).getPointCount()); assertEquals(3, new RegularTimeSeriesIndex(0, 20, 10).getPointCount()); assertEquals(3, new RegularTimeSeriesIndex(0, 21, 10).getPointCount()); long millisInYear = 365L * 86400 * 1000; assertEquals(10, new RegularTimeSeriesIndex( Instant.parse("2000-01-01T00:00:00Z").toEpochMilli(), Instant.parse("2009-01-01T00:00:00Z").toEpochMilli(), millisInYear).getPointCount()); }
@Test public void testPointCountHuge() { assertEquals(30 * 365 * 24 * 120 + 1, new RegularTimeSeriesIndex(0, 30L * 365 * 24 * 60 * 60 * 1000 + 0 * 30 * 1000, 30 * 1000).getPointCount()); assertEquals(30 * 365 * 24 * 120 + 2, new RegularTimeSeriesIndex(0, 30L * 365 * 24 * 60 * 60 * 1000 + 1 * 30 * 1000, 30 * 1000).getPointCount()); assertEquals(30 * 365 * 24 * 120 + 3, new RegularTimeSeriesIndex(0, 30L * 365 * 24 * 60 * 60 * 1000 + 2 * 30 * 1000, 30 * 1000).getPointCount()); }