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:
java.io.Closeable, java.util.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  java.io.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(java.lang.String filename, java.lang.String termsFile, int runNo, java.lang.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
 java.lang.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 java.io.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(java.lang.String filename,
                       java.lang.String termsFile,
                       int runNo,
                       java.lang.Class<? extends PostingInRun> _postingInRunClass,
                       int fieldCount)
                throws java.lang.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:
java.lang.Exception
Method Detail

close

public void close()
Closes the run files being processed

Specified by:
close in interface java.io.Closeable
Overrides:
close in class RunIterator

hasNext

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

Specified by:
hasNext in interface java.util.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 java.util.Iterator<PostingInRun>
Specified by:
next in class RunIterator

readTermFrequency

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

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

readString

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

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


Terrier 3.5. Copyright © 2004-2011 University of Glasgow