org.terrier.structures.indexing.singlepass
Class FileRunIterator<K extends PostingInRun>

java.lang.Object
  extended by org.terrier.structures.indexing.singlepass.RunIterator
      extended by org.terrier.structures.indexing.singlepass.FileRunIterator<K>
Type Parameters:
K -
All Implemented Interfaces:
Closeable, Iterator<PostingInRun>

public class FileRunIterator<K extends PostingInRun>
extends RunIterator

Reads runs of flushed term posting lists by reading them from files.

Since:
2.2
Author:
Craig Macdonald

Field Summary
protected  int currentPosting
          Current Posting List number
protected  int maxSize
          max number of pointers any term in the run
protected  BitIn mbis
          Input stream for reading the run.
protected  int size
          Number of postings in this run
protected  DataInputStream stringDIS
          Input stream for reading the terms.
 
Fields inherited from class org.terrier.structures.indexing.singlepass.RunIterator
flushNo, numberOfFields, posting, postingClass
 
Constructor Summary
FileRunIterator(String filename, String termsFile, int runNo, Class<? extends PostingInRun> _postingInRunClass, int fieldCount)
          Load a new run from files.
 
Method Summary
 void close()
          Closes the run files being processed
 boolean hasNext()
          Are there more posting to process in this run?
 PostingInRun next()
          Move to the next posting in this run
 String readString()
          Reads the String identifying a term from the underlying stream.
 int readTermFrequency()
          Reads the term frequency for the current posting, and aligns the stream.
 
Methods inherited from class org.terrier.structures.indexing.singlepass.RunIterator
createPosting, current, getRunNo, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mbis

protected BitIn mbis
Input stream for reading the run.


stringDIS

protected DataInputStream stringDIS
Input stream for reading the terms.


size

protected int size
Number of postings in this run


currentPosting

protected int currentPosting
Current Posting List number


maxSize

protected int maxSize
max number of pointers any term in the run

Constructor Detail

FileRunIterator

public FileRunIterator(String filename,
                       String termsFile,
                       int runNo,
                       Class<? extends PostingInRun> _postingInRunClass,
                       int fieldCount)
                throws Exception
Load a new run from files.

Parameters:
filename - the filename of the file containing the posting lists
termsFile - the filename of the file containing the term names
runNo - the number of this run
_postingInRunClass - the class that all postings in this class have
Throws:
Exception
Method Detail

close

public void close()
Closes the run files being processed

Specified by:
close in interface Closeable
Overrides:
close in class RunIterator

hasNext

public boolean hasNext()
Are there more posting to process in this run?

Specified by:
hasNext in interface Iterator<PostingInRun>
Specified by:
hasNext in class RunIterator

next

public PostingInRun next()
Move to the next posting in this run

Specified by:
next in interface Iterator<PostingInRun>
Specified by:
next in class RunIterator

readTermFrequency

public int readTermFrequency()
                      throws IOException
Reads the term frequency for the current posting, and aligns the stream.

Returns:
the frequency read.
Throws:
IOException - if an I/O error occurs.

readString

public String readString()
                  throws IOException
Reads the String identifying a term from the underlying stream.

Returns:
the String with the term.
Throws:
IOException - if an I/O error occurs.


Terrier 3.6. Copyright © 2004-2011 University of Glasgow