Package org.terrier.structures.postings

Examples of org.terrier.structures.postings.IterablePosting


    assertNotNull(iiis);
    int ithTerm = -1;
    while(iiis.hasNext())
    {
      ithTerm++;
      final IterablePosting ip = iiis.getNextPostings();
      int count = 0;
      final int expected = iiis.getNumberOfCurrentPostings();
      while(ip.next() != IterablePosting.EOL)
      {
        //System.err.println("Got id " + ip.getId());
        assertTrue("Got too big a docid ("+ip.getId()+") from inverted index input stream for term at index " + ithTerm, ip.getId() < numDocs);
        count++;
        calculatedDocLengths.adjustOrPutValue(ip.getId(), ip.getFrequency(), ip.getFrequency());
      }
      assertEquals(expected, count);
    }
    assertEquals("Number of documents is unexpected,", documentLengths.length - countZero(documentLengths), calculatedDocLengths.size());
    long tokens = 0;
View Full Code Here


    int docid = 0;
    final PostingIndexInputStream piis = (PostingIndexInputStream) index.getIndexStructureInputStream("direct");
    assertNotNull("No direct index input stream found", piis);
    while(piis.hasNext())
    {
      IterablePosting ip = piis.next();
      int doclen = 0int docpointers = 0;   
      docid += piis.getEntriesSkipped();
      //System.err.println("getEntriesSkipped=" + piis.getEntriesSkipped());
      //System.err.println("docid=" + docid);
      while(ip.next() != IterablePosting.EOL)
      {
        //System.err.println("termid" +ip.getId() + " f=" + ip.getFrequency());
        termIds.add(ip.getId());
        tokens += ip.getFrequency();
        doclen += ip.getFrequency();
        pointers++; docpointers++;
        if (numberOfTerms > 0)
          assertTrue("Got too big a termid ("+ip.getId()+") from direct index input stream, numTerms=" + numberOfTerms, ip.getId() < maxTermId);
      }
      if (documentPointers.length > 0)
        assertEquals("Numebr of pointers for docid " + docid + " is incorrect", documentPointers[docid], docpointers);
      assertEquals("Document length for docid "+docid+" is incorrect", documentLengths[docid], doclen);
      docid++;
View Full Code Here

    public void checkIndex(BatchEndToEndTest test, Index index)
        throws Exception
    {     
      //no check correct type of all structures
      BitPostingIndexInputStream bpiis;
      IterablePosting ip;
      BitPostingIndex bpi;
     
      //check stream structures
      bpiis = (BitPostingIndexInputStream) index.getIndexStructureInputStream("direct");
      ip = bpiis.next();
View Full Code Here

    List<Posting> postings = new ArrayList<Posting>();
    postings.add(new BasicPostingImpl(1,1));
    List<BitIndexPointer> pointerList = new ArrayList<BitIndexPointer>();
    String filename = PostingTestUtils.writePostingsToFile(new Iterator[]{postings.iterator()}, pointerList);
    BitInputStream bitIn = new BitInputStream(filename);
    IterablePosting ip = new BasicIterablePosting(bitIn, postings.size(), null);
    PostingTestUtils.comparePostings(postings, ip);
  }
View Full Code Here

    postings.add(new BasicPostingImpl(10,1));
    postings.add(new BasicPostingImpl(100,1));
    List<BitIndexPointer> pointerList = new ArrayList<BitIndexPointer>();
    String filename = PostingTestUtils.writePostingsToFile(new Iterator[]{postings.iterator()}, pointerList);
    BitInputStream bitIn = new BitInputStream(filename);
    IterablePosting ip = new BasicIterablePosting(bitIn, postings.size(), null);
    PostingTestUtils.comparePostings(postings, ip);
  }
View Full Code Here

    structure.close();
   
    structure = new BitPostingIndexInputStream(filename, (byte)1, PostingTestUtils.makeSkippable(pointerList.iterator()), BasicIterablePosting.class, 0);
    structure.skip(1);
    assertTrue(structure.hasNext());
    IterablePosting ip = structure.next();
    PostingTestUtils.assertEqualsBitFilePosition(pointerList.get(1), structure.getPos());
    PostingTestUtils.comparePostings(postings2, ip);
    assertFalse(structure.hasNext());
    structure.close();
  }
View Full Code Here

    List<Posting> postings2 = new ArrayList<Posting>();
    postings2.add(new BasicPostingImpl(0,20));
    postings2.add(new BasicPostingImpl(8,1000));
    postings2.add(new BasicPostingImpl(10,1000));
   
    IterablePosting ip;
    final List<BitIndexPointer> pointerList = new ArrayList<BitIndexPointer>();
    final String filename = docids
      ? PostingTestUtils.writePostingsToFileDocidOnly(new Iterator[]{postings0.iterator(), postings1.iterator(), postings2.iterator()}, pointerList)
      : PostingTestUtils.writePostingsToFile(new Iterator[]{postings0.iterator(), postings1.iterator(), postings2.iterator()}, pointerList);
    final Class<? extends IterablePosting> postingIteratorClass = docids ? BasicIterablePostingDocidOnly.class : BasicIterablePosting.class;
View Full Code Here

    IntObjectWrapper<IterablePosting> iterWrapper = rr.createValue();
    for(int i=0;i<postings.length;i++)
    {
      assertTrue(rr.next(docid, iterWrapper));
      assertEquals(postings[i].length, iterWrapper.getInt());
      IterablePosting iter = iterWrapper.getObject();
      for(int j=0;j<postings[i].length;j++)
      {       
        assertEquals(postings[i][j], iter.next());
        assertEquals(postings[i][j], iter.getId());
      }
      assertEquals(IterablePosting.EOL, iter.next());
    }
    assertFalse(rr.next(docid, iterWrapper));   
  }
View Full Code Here

        //System.err.println("Split = " + splits[splitIndex]);
        rr = bpiif.getRecordReader(splits[splitIndex], jc, NULL_REPORTER);
        rr.next(docid, iterWrapper);
      }
      assertEquals(postings[i].length, iterWrapper.getInt());
      IterablePosting iter = iterWrapper.getObject();
      assertNotNull(iter);
      for(int j=0;j<postings[i].length;j++)
      { 
        assertEquals(postings[i][j], iter.next());
        //System.err.println("id in posting=" +iter.getId() );
        assertEquals(postings[i][j], iter.getId());
       
      }
      assertEquals(IterablePosting.EOL, iter.next());
    }
    assertFalse(rr.next(docid, iterWrapper));   
  }
View Full Code Here

TOP

Related Classes of org.terrier.structures.postings.IterablePosting

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.