summaryrefslogtreecommitdiffstats
path: root/predicate-search/src/test/java/com/yahoo/search/predicate/index/ZstarCompressedPostingListTest.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /predicate-search/src/test/java/com/yahoo/search/predicate/index/ZstarCompressedPostingListTest.java
Publish
Diffstat (limited to 'predicate-search/src/test/java/com/yahoo/search/predicate/index/ZstarCompressedPostingListTest.java')
-rw-r--r--predicate-search/src/test/java/com/yahoo/search/predicate/index/ZstarCompressedPostingListTest.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/predicate-search/src/test/java/com/yahoo/search/predicate/index/ZstarCompressedPostingListTest.java b/predicate-search/src/test/java/com/yahoo/search/predicate/index/ZstarCompressedPostingListTest.java
new file mode 100644
index 00000000000..3eb389757e3
--- /dev/null
+++ b/predicate-search/src/test/java/com/yahoo/search/predicate/index/ZstarCompressedPostingListTest.java
@@ -0,0 +1,62 @@
+// 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 org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
+ */
+public class ZstarCompressedPostingListTest {
+ @Test
+ public void requireThatPostingListCanIterate() {
+ PredicateIntervalStore.Builder builder = new PredicateIntervalStore.Builder();
+ int ref1 = builder.insert(Arrays.asList(0x10000));
+ int ref2 = builder.insert(Arrays.asList(0x10000, 0x0ffff));
+ int ref3 = builder.insert(Arrays.asList(0x10000, 0x00003, 0x40003, 0x60005));
+ ZstarCompressedPostingList postingList = new ZstarCompressedPostingList(
+ builder.build(), new int[]{2, 4, 6}, new int[]{ref1, ref2, ref3});
+ assertEquals(-1, postingList.getDocId());
+ assertEquals(0, postingList.getInterval());
+ assertEquals(0xffffffffffffffffL, postingList.getSubquery());
+
+ assertTrue(postingList.nextDocument(0));
+ assertTrue(postingList.prepareIntervals());
+ assertEquals(2, postingList.getDocId());
+ assertEquals(0x10000, postingList.getInterval());
+ assertTrue(postingList.nextInterval());
+ assertEquals(0x20001, postingList.getInterval());
+ assertFalse(postingList.nextInterval());
+
+ assertTrue(postingList.nextDocument(2));
+ assertTrue(postingList.prepareIntervals());
+ assertEquals(4, postingList.getDocId());
+ assertEquals(0x00010000, postingList.getInterval());
+ assertTrue(postingList.nextInterval());
+ assertEquals(0xffff0001, postingList.getInterval());
+ assertFalse(postingList.nextInterval());
+
+ assertTrue(postingList.nextDocument(4));
+ assertTrue(postingList.prepareIntervals());
+ assertEquals(6, postingList.getDocId());
+ assertEquals(0x10000, postingList.getInterval());
+ assertTrue(postingList.nextInterval());
+ assertEquals(0x30001, postingList.getInterval());
+ assertTrue(postingList.nextInterval());
+ assertEquals(0x40003, postingList.getInterval());
+ assertTrue(postingList.nextInterval());
+ assertEquals(0x50004, postingList.getInterval());
+ assertTrue(postingList.nextInterval());
+ assertEquals(0x60005, postingList.getInterval());
+ assertTrue(postingList.nextInterval());
+ assertEquals(0x70006, postingList.getInterval());
+ assertFalse(postingList.nextInterval());
+
+ assertFalse(postingList.nextDocument(6));
+ }
+}