| margaretha | a0d88f6 | 2018-09-03 18:03:52 +0200 | [diff] [blame] | 1 | package de.ids_mannheim.korap.collection; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | |
| 5 | import java.io.IOException; |
| 6 | import java.util.List; |
| 7 | |
| 8 | import org.apache.lucene.index.LeafReaderContext; |
| 9 | import org.apache.lucene.util.BitDocIdSet; |
| 10 | import org.apache.lucene.util.FixedBitSet; |
| 11 | import org.junit.Test; |
| 12 | |
| 13 | import de.ids_mannheim.korap.KrillCollection; |
| 14 | import de.ids_mannheim.korap.KrillIndex; |
| 15 | import de.ids_mannheim.korap.util.QueryException; |
| 16 | |
| 17 | public class TestDocBits { |
| 18 | |
| 19 | private KrillIndex ki; |
| 20 | |
| 21 | @Test |
| 22 | public void testRecreatedDocBitsLength () throws IOException, QueryException { |
| 23 | ki = new KrillIndex(); |
| 24 | ki.addDoc(TestKrillCollectionIndex.createDoc1()); |
| 25 | ki.addDoc(TestKrillCollectionIndex.createDoc2()); |
| 26 | ki.addDoc(TestKrillCollectionIndex.createDoc3()); |
| 27 | ki.commit(); |
| 28 | |
| 29 | KrillCollection kc = new KrillCollection(); |
| 30 | List<LeafReaderContext> leaves = this.ki.reader().leaves(); |
| 31 | for (LeafReaderContext context : leaves) { |
| 32 | FixedBitSet bitset = kc.bits(context); |
| 33 | DocBits docBits = new DocBits(bitset.getBits(), bitset.length()); |
| 34 | BitDocIdSet bitDocIdSet = docBits.createBitDocIdSet(); |
| 35 | assertEquals(bitset.length(), bitDocIdSet.bits().length()); |
| 36 | } |
| 37 | } |
| 38 | } |