BoundsPostingList extends MultiIntervalPostingList { @Override public int getInterval() { return currentInterval; } BoundsPostingList(PredicateIntervalStore store, int[] docIds, int[] dataRefs, long subquery, int valueDiff); @Override boolean nextInterval(); @Override int getInterval();  }
@Test public void requireThatPostingListChecksBounds() { PredicateIntervalStore.Builder builder = new PredicateIntervalStore.Builder(); List<Integer> docIds = new ArrayList<>(); List<Integer> dataRefs = new ArrayList<>(); for (int id = 1; id < 100; ++id) { List<IntervalWithBounds> boundsList = new ArrayList<>(); for (int i = 0; i <= id; ++i) { int bounds; if (id < 30) { bounds = 0x80000000 | i; } else if (id < 60) { bounds = 0x40000000 | i; } else { bounds = (i << 16) | (i + 10); } boundsList.add(new IntervalWithBounds((i + 1) << 16 | 0xffff, bounds)); } docIds.add(id); dataRefs.add(builder.insert(boundsList.stream().flatMap(IntervalWithBounds::stream).collect(toList()))); } PredicateIntervalStore store = builder.build(); BoundsPostingList postingList = new BoundsPostingList( store, Ints.toArray(docIds), Ints.toArray(dataRefs), 0xffffffffffffffffL, 5); assertEquals(-1, postingList.getDocId()); assertEquals(0, postingList.getInterval()); assertEquals(0xffffffffffffffffL, postingList.getSubquery()); checkNext(postingList, 0, 1, 2); checkNext(postingList, 1, 2, 3); checkNext(postingList, 10, 11, 6); checkNext(postingList, 20, 21, 6); checkNext(postingList, 30, 31, 26); checkNext(postingList, 50, 51, 46); checkNext(postingList, 60, 61, 6); postingList = new BoundsPostingList(store, Ints.toArray(docIds), Ints.toArray(dataRefs), 0xffffffffffffffffL, 40); checkNext(postingList, 0, 1, 2); checkNext(postingList, 20, 21, 22); checkNext(postingList, 30, 31, 0); checkNext(postingList, 32, 33, 0); checkNext(postingList, 33, 34, 0); checkNext(postingList, 40, 41, 1); checkNext(postingList, 50, 51, 11); checkNext(postingList, 60, 61, 10); }