diff options
Diffstat (limited to 'predicate-search/src/test/java/com/yahoo/search/predicate/index/IntervalPostingListTest.java')
-rw-r--r-- | predicate-search/src/test/java/com/yahoo/search/predicate/index/IntervalPostingListTest.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/predicate-search/src/test/java/com/yahoo/search/predicate/index/IntervalPostingListTest.java b/predicate-search/src/test/java/com/yahoo/search/predicate/index/IntervalPostingListTest.java new file mode 100644 index 00000000000..41f4ba55750 --- /dev/null +++ b/predicate-search/src/test/java/com/yahoo/search/predicate/index/IntervalPostingListTest.java @@ -0,0 +1,43 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.search.predicate.index; + +import com.yahoo.search.predicate.SubqueryBitmap; +import org.junit.Test; + +import java.util.Arrays; + +import static junit.framework.TestCase.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class IntervalPostingListTest { + @Test + public void requireThatPostingListCanIterate() { + PredicateIntervalStore.Builder builder = new PredicateIntervalStore.Builder(); + int ref1 = builder.insert(Arrays.asList(0x1ffff)); + int ref2 = builder.insert(Arrays.asList(0x1ffff)); + int ref3 = builder.insert(Arrays.asList(0x10001, 0x2ffff)); + IntervalPostingList postingList = new IntervalPostingList( + builder.build(), new int[]{2, 4, 6}, new int[] {ref1, ref2, ref3}, SubqueryBitmap.ALL_SUBQUERIES); + assertEquals(-1, postingList.getDocId()); + assertEquals(0, postingList.getInterval()); + assertEquals(0xffffffffffffffffL, postingList.getSubquery()); + + assertTrue(postingList.nextDocument(0)); + assertTrue(postingList.prepareIntervals()); + assertEquals(2, postingList.getDocId()); + assertEquals(0x1ffff, postingList.getInterval()); + assertFalse(postingList.nextInterval()); + + assertTrue(postingList.nextDocument(4)); + assertTrue(postingList.prepareIntervals()); + assertEquals(6, postingList.getDocId()); + assertEquals(0x10001, postingList.getInterval()); + assertTrue(postingList.nextInterval()); + assertEquals(0x2ffff, postingList.getInterval()); + assertFalse(postingList.nextInterval()); + + assertFalse(postingList.nextDocument(8)); + } + +} |