org.terrier.structures.postings
Class BasicIterablePosting

java.lang.Object
  extended by org.terrier.structures.postings.BasicPostingImpl
      extended by org.terrier.structures.postings.BasicIterablePosting
All Implemented Interfaces:
java.io.Closeable, org.apache.hadoop.io.Writable, IterablePosting, Posting, WritablePosting
Direct Known Subclasses:
BasicIterablePostingDocidOnly, BlockFieldIterablePosting, BlockIterablePosting, FieldIterablePosting

public class BasicIterablePosting
extends BasicPostingImpl
implements IterablePosting

Basic inverted and direct index format: [gamma(first docid +1) unary (frequency)], [gamma(delta docid) unary(frequency)]

Since:
3.0

Field Summary
protected  BitIn bitFileReader
           
protected  DocumentIndex doi
           
protected  int numEntries
           
 
Fields inherited from class org.terrier.structures.postings.BasicPostingImpl
id, tf
 
Fields inherited from interface org.terrier.structures.postings.IterablePosting
EOL
 
Constructor Summary
protected BasicIterablePosting()
          Create a new posting iterator
  BasicIterablePosting(BitIn _bitFileReader, int _numEntries, DocumentIndex _doi)
          Create a new posting iterator
 
Method Summary
 WritablePosting asWritablePosting()
          Copies this posting to one free of an iterator.
 void close()
          
 boolean endOfPostings()
          Status method to see if this posting list iterator has been finished
 int getDocumentLength()
          Returns 0
 int next()
          Move this iterator to the next posting.
 int next(int target)
          Move this iterator to the posting with specified id, or next posting after that.
 
Methods inherited from class org.terrier.structures.postings.BasicPostingImpl
getFrequency, getId, readFields, setId, toString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.terrier.structures.postings.Posting
getFrequency, getId, setId
 

Field Detail

numEntries

protected int numEntries

bitFileReader

protected BitIn bitFileReader

doi

protected DocumentIndex doi
Constructor Detail

BasicIterablePosting

protected BasicIterablePosting()
Create a new posting iterator


BasicIterablePosting

public BasicIterablePosting(BitIn _bitFileReader,
                            int _numEntries,
                            DocumentIndex _doi)
                     throws java.io.IOException
Create a new posting iterator

Parameters:
_bitFileReader - BitIn to read the postings from
_numEntries - number of postings in the list
_doi - document index to use to satisfy getDocumentLength()
Throws:
java.io.IOException - thrown in an IO exception occurs
Method Detail

next

public int next()
         throws java.io.IOException
Move this iterator to the next posting.

Specified by:
next in interface IterablePosting
Returns:
id of next posting, or EOL if end of posting list
Throws:
java.io.IOException

next

public int next(int target)
         throws java.io.IOException
Move this iterator to the posting with specified id, or next posting after that. This is usually implemented internally by next(), but more efficient implementations can override this behaviour. This implementation of next(int) which uses next()

Specified by:
next in interface IterablePosting
Parameters:
target - id of the posting to find in this postingn list.
Returns:
id of the posting found, or EOL if end of posting list.
Throws:
java.io.IOException

endOfPostings

public boolean endOfPostings()
Status method to see if this posting list iterator has been finished

Specified by:
endOfPostings in interface IterablePosting
Returns:
true if next() or next(int) would return EOL or have returned EOL.

getDocumentLength

public int getDocumentLength()
Returns 0

Specified by:
getDocumentLength in interface Posting
Overrides:
getDocumentLength in class BasicPostingImpl
Returns:
length of the document of the current posting in tokens.

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

asWritablePosting

public WritablePosting asWritablePosting()
Copies this posting to one free of an iterator. Kind of like a clone.

Specified by:
asWritablePosting in interface Posting
Overrides:
asWritablePosting in class BasicPostingImpl
Returns:
an identical posting, but which can be maniulated free of this iterator


Terrier 3.5. Copyright © 2004-2011 University of Glasgow