IntervalIndexImpl extends TimeIndexImpl<T, Interval, IntervalSet, IntervalMap<?>> { @Override public double getMaxTimestamp() { if (mainIndex) { Interval2IntTreeMap sortedMap = (Interval2IntTreeMap) timestampIndexStore.timeSortedMap; if (!sortedMap.isEmpty()) { return sortedMap.getHigh(); } } else { Interval2IntTreeMap sortedMap = (Interval2IntTreeMap) timestampIndexStore.timeSortedMap; if (!sortedMap.isEmpty()) { double max = Double.NEGATIVE_INFINITY; boolean found = false; for (Map.Entry<Interval, Integer> entry : sortedMap.entrySet()) { int index = entry.getValue(); if (index < timestamps.length) { TimeIndexEntry intervalEntry = timestamps[index]; if (intervalEntry != null) { found = true; max = Math.max(max, entry.getKey().getHigh()); } } } if (found) { return max; } } } return Double.POSITIVE_INFINITY; } IntervalIndexImpl(TimeIndexStore<T, Interval, IntervalSet, IntervalMap<?>> store, boolean main); @Override double getMinTimestamp(); @Override double getMaxTimestamp(); @Override ElementIterable get(double timestamp); @Override ElementIterable get(Interval interval);  }
@Test public void testGetMax() { Configuration config = new Configuration(); config.setTimeRepresentation(TimeRepresentation.INTERVAL); GraphModelImpl graphModel = new GraphModelImpl(config); TimeStore timeStore = graphModel.store.timeStore; IntervalIndexStore store = (IntervalIndexStore) timeStore.nodeIndexStore; Assert.assertEquals(store.mainIndex.getMaxTimestamp(), Double.POSITIVE_INFINITY); store.add(new Interval(1.0, 3.0)); Assert.assertEquals(store.mainIndex.getMaxTimestamp(), 3.0); store.add(new Interval(1.0, 2.0)); Assert.assertEquals(store.mainIndex.getMaxTimestamp(), 3.0); store.remove(new Interval(1.0, 3.0)); Assert.assertEquals(store.mainIndex.getMaxTimestamp(), 2.0); }
@Test public void testGetMaxWithInfinite() { Configuration config = new Configuration(); config.setTimeRepresentation(TimeRepresentation.INTERVAL); GraphModelImpl graphModel = new GraphModelImpl(config); TimeStore timeStore = graphModel.store.timeStore; IntervalIndexStore store = (IntervalIndexStore) timeStore.nodeIndexStore; store.add(new Interval(1.0, Double.POSITIVE_INFINITY)); Assert.assertEquals(store.mainIndex.getMaxTimestamp(), 1.0); store.add(new Interval(1.0, 2.0)); Assert.assertEquals(store.mainIndex.getMaxTimestamp(), 2.0); }