IntervalIndexImpl extends TimeIndexImpl<T, Interval, IntervalSet, IntervalMap<?>> { @Override public ElementIterable get(double timestamp) { checkDouble(timestamp); readLock(); ObjectSet<Element> elements = new ObjectOpenHashSet<Element>(); Interval2IntTreeMap sortedMap = (Interval2IntTreeMap) timestampIndexStore.timeSortedMap; if (!sortedMap.isEmpty()) { for (Integer index : sortedMap.values(timestamp)) { if (index < timestamps.length) { TimeIndexEntry ts = timestamps[index]; if (ts != null) { elements.addAll(ts.elementSet); } } } } if (!elements.isEmpty()) { return new ElementIterableImpl(new ElementIteratorImpl(elements.iterator())); } readUnlock(); return ElementIterable.EMPTY; } 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 testGetElements() { Configuration config = new Configuration(); config.setTimeRepresentation(TimeRepresentation.INTERVAL); GraphModelImpl graphModel = new GraphModelImpl(config); TimeStore timeStore = graphModel.store.timeStore; IntervalIndexStore store = (IntervalIndexStore) timeStore.nodeIndexStore; Interval i1 = new Interval(1.0, 5.0); Interval i2 = new Interval(-1.0, 1.0); Interval i3 = new Interval(4.0, 8.0); store.add(i1); store.add(i2); store.add(i3); NodeImpl n0 = new NodeImpl(0); NodeImpl n1 = new NodeImpl(1); NodeImpl n2 = new NodeImpl(2); NodeImpl n3 = new NodeImpl(3); store.add(i1, n0); store.add(i1, n1); store.add(i2, n2); store.add(i3, n3); ObjectSet r1 = new ObjectOpenHashSet(getArrayFromIterable(store.mainIndex.get(new Interval(2.0, 3.0)))); Assert.assertTrue(r1.contains(n0)); Assert.assertTrue(r1.contains(n1)); Assert.assertEquals(r1.size(), 2); ObjectSet r2 = new ObjectOpenHashSet(getArrayFromIterable(store.mainIndex.get(new Interval(-1, 3.0)))); Assert.assertTrue(r2.contains(n0)); Assert.assertTrue(r2.contains(n1)); Assert.assertTrue(r2.contains(n2)); Assert.assertEquals(r2.size(), 3); ObjectSet r4 = new ObjectOpenHashSet(getArrayFromIterable(store.mainIndex.get(new Interval(-1.0, -1.0)))); Assert.assertTrue(r4.contains(n2)); Assert.assertEquals(r4.size(), 1); ObjectSet r5 = new ObjectOpenHashSet(getArrayFromIterable(store.mainIndex.get(new Interval(-12.0, 10)))); Assert.assertTrue(r5.contains(n2)); Assert.assertTrue(r5.contains(n1)); Assert.assertTrue(r5.contains(n0)); Assert.assertTrue(r5.contains(n3)); Assert.assertEquals(r5.size(), 4); }