protected void testInverted(Index index) throws Exception { PostingIndexInputStream piis = (PostingIndexInputStream) index.getIndexStructureInputStream("inverted"); IterablePosting ip = null; BlockPosting bp = null; while(piis.hasNext()) { ip = piis.getNextPostings(); if (ip == null) continue; bp = (BlockPosting) ip; while(ip.next() != IterablePosting.EOL) { int tf = bp.getFrequency(); int[] blocks = bp.getPositions(); assertTrue("blocks.length="+blocks.length + " tf="+tf, blocks.length <= tf); assertTrue("blocks.length="+blocks.length + " tf="+tf + ", blocks longer than max "+ maxBlocks, blocks.length <= maxBlocks); } } piis.close(); } }
tt.start(); try{ while(iiis.hasNext()) IterablePosting ip = iiis.next(); org.terrier.structures.postings.FieldPosting fip = null; termId = ((LexiconEntry) iiis.getCurrentPointer()).getTermId(); final int numPostingsForTerm = iiis.getNumberOfCurrentPostings(); int docid = ip.next(firstDocid);
while((ip = directInputStream.getNextPostings()) != null) docid += directInputStream.getEntriesSkipped(); directInputStream.close();
while(piis.hasNext()) IterablePosting ip = piis.next(); int doclen = 0; int docpointers = 0; docid += piis.getEntriesSkipped(); if (D_DEBUG) System.err.println("getEntriesSkipped=" + piis.getEntriesSkipped()); if (D_DEBUG) System.err.println("docid=" + docid); docid++; piis.close(); CollectionStatistics cs = index.getCollectionStatistics(); assertEquals("Number of documents is incorrect", cs.getNumberOfDocuments(), docid);
@Override public void checkIndex(BatchEndToEndTest test, Index index) throws Exception { //no check correct type of all structures PostingIndexInputStream bpiis; IterablePosting ip; PostingIndex<Pointer> bpi; //check stream structures bpiis = (PostingIndexInputStream) index.getIndexStructureInputStream("direct"); ip = bpiis.next(); assertTrue(ip instanceof BlockPosting); bpiis.close(); bpiis = (PostingIndexInputStream) index.getIndexStructureInputStream("inverted"); ip = bpiis.next(); assertTrue(ip instanceof BlockPosting); bpiis.close(); //check random structures bpi = (PostingIndex<Pointer>) index.getInvertedIndex(); ip = bpi.getPostings(index.getLexicon().getLexiconEntry(0).getValue()); assertTrue(ip instanceof BlockPosting); bpi = (PostingIndex<Pointer>) index.getDirectIndex(); ip = bpi.getPostings(index.getDocumentIndex().getDocumentEntry(0)); assertTrue(ip instanceof BlockPosting); } }
assertNotNull(iiis); int ithTerm = -1; while(iiis.hasNext()) final IterablePosting ip = iiis.getNextPostings(); int count = 0; final int expected = iiis.getNumberOfCurrentPostings(); while(ip.next() != IterablePosting.EOL) iiis.close();
IterablePosting postings = piis.next();
@Test public void test_iterator() throws Exception { MemoryLexicon lexicon = new MemoryLexicon(); assertNotNull(lexicon); for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]); MemoryDocumentIndex docindex = new MemoryDocumentIndex(); assertNotNull(docindex); for (int i = 0; i < 10; i++) docindex.addDocument(i); MemoryInvertedIndex inverted = new MemoryInvertedIndex(lexicon,docindex); assertNotNull(inverted); for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) inverted.add(i, docids[j], docfreqs[j]); PostingIndexInputStream iter = inverted.iterator(); assertNotNull(iter); while (iter.hasNext()) { IterablePosting post = iter.getNextPostings(); assertNotNull(post); for (int j = 0; j < 10; j++) { assertEquals(docids[j], post.next()); assertEquals(docids[j], post.getId()); assertEquals(docfreqs[j], post.getFrequency()); } assertEquals(IterablePosting.EOL, post.next()); } }
offsetsTmpFile.writeInt(p.getDocF()); iiis.close(); firstDocid = firstDocid + countDocsThisIteration; } while(firstDocid < index.getCollectionStatistics().getNumberOfDocuments());
if (die.getDocumentLength() > 0) pointerDF = dfOutput.writePostings(dfInput1.next()); sourceDocid++; dfInput1.close(); metaInput1.close(); IndexUtil.close(docidInput1); if (die.getDocumentLength() > 0) final IterablePosting postings = dfInput2.next(); sourceDocid++; dfInput2.close(); IndexUtil.close(docidInput2); metaInput2.close();
MemoryFieldsIterablePosting postings = (MemoryFieldsIterablePosting) invIN.next();
tt.start(); try{ while(iiis.hasNext()) IterablePosting ip = iiis.next(); org.terrier.structures.postings.FieldPosting fip = null; org.terrier.structures.postings.BlockPosting bip = (org.terrier.structures.postings.BlockPosting) ip; fip = (org.terrier.structures.postings.FieldPosting) ip; termId = ((LexiconEntry) iiis.getCurrentPointer()).getTermId(); final int numPostingsForTerm = iiis.getNumberOfCurrentPostings(); int docid = ip.next(firstDocid);
while((ip = directInputStream.getNextPostings()) != null) docid += directInputStream.getEntriesSkipped(); int termid; FieldPosting fp = _useFieldInformation ? (FieldPosting) ip : null; directInputStream.close();