org.terrier.structures
Class DirectInvertedOutputStream

java.lang.Object
  extended by org.terrier.structures.DirectInvertedOutputStream
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
BlockDirectInvertedOutputStream, DirectInvertedDocidOnlyOuptutStream, FieldDirectInvertedOutputStream

public class DirectInvertedOutputStream
extends java.lang.Object
implements java.io.Closeable

Writes a block direct or block inverted index, when passed appropriate posting lists.

Since:
2.0
Author:
Craig Macdonald

Field Summary
protected static org.apache.log4j.Logger logger
          The logger used
protected  BitOut output
          what to write to
 
Constructor Summary
DirectInvertedOutputStream(BitOut out)
          Creates a new output stream, writing to the specified BitOut implementation.
DirectInvertedOutputStream(java.lang.String filename)
          Creates a new output stream, writing a BitOutputStream to the specified file.
 
Method Summary
 void close()
          close this object.
 byte getBitOffset()
          Deprecated.  
 BitOut getBitOut()
          Return the underlying BitOut implementation being used by the class
 long getByteOffset()
          Deprecated.  
 BitFilePosition getOffset()
          What is current offset?
 java.lang.Class<? extends IterablePosting> getPostingIteratorClass()
          Returns the IterablePosting class to use for reading structure written by this class
protected  BitIndexPointer writeNoFieldPostings(int[][] postings, int offset, int length, int firstId)
          Writes the given postings to the bit file.
protected  void writePostingNotDocid(Posting p)
          Hook method for writing out the remainder of the posting
 BitIndexPointer writePostings(int[][] postings, int firstId)
          Write out the specified postings.
 BitIndexPointer writePostings(int[][] postings, int startOffset, int Length, int firstId)
          Write out a range of the specified postings.
 BitIndexPointer writePostings(IterablePosting postings)
          Write out the specified postings.
 BitIndexPointer writePostings(IterablePosting postings, int previousId)
          Write out the specified postings, but allowing the delta for the first document to be adjusted
 BitIndexPointer writePostings(java.util.Iterator<Posting> iterator)
          Write out the specified postings.
 BitIndexPointer writePostings(java.util.Iterator<Posting> iterator, int previousId)
          Write out the specified postings, but allowing the delta for the first document to be adjusted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

output

protected BitOut output
what to write to


logger

protected static final org.apache.log4j.Logger logger
The logger used

Constructor Detail

DirectInvertedOutputStream

public DirectInvertedOutputStream(java.lang.String filename)
                           throws java.io.IOException
Creates a new output stream, writing a BitOutputStream to the specified file. The number of binary bits for fields must also be specified.

Parameters:
filename - Location of the file to write to
Throws:
java.io.IOException

DirectInvertedOutputStream

public DirectInvertedOutputStream(BitOut out)
Creates a new output stream, writing to the specified BitOut implementation. The number of binary bits for fields must also be specified.

Parameters:
out - BitOut implementation to write the file to
Method Detail

getPostingIteratorClass

public java.lang.Class<? extends IterablePosting> getPostingIteratorClass()
Returns the IterablePosting class to use for reading structure written by this class


writePostings

public BitIndexPointer writePostings(int[][] postings,
                                     int firstId)
                              throws java.io.IOException
Write out the specified postings. The delta for the first id must be specified.

Parameters:
postings - The postings to write out
firstId - the (delta) value of the first docid to write out.
Throws:
java.io.IOException

writePostings

public BitIndexPointer writePostings(java.util.Iterator<Posting> iterator)
                              throws java.io.IOException
Write out the specified postings.

Parameters:
iterator - an Iterator of Posting objects
Throws:
java.io.IOException

writePostings

public BitIndexPointer writePostings(java.util.Iterator<Posting> iterator,
                                     int previousId)
                              throws java.io.IOException
Write out the specified postings, but allowing the delta for the first document to be adjusted

Parameters:
iterator - an Iterator of Posting objects
previousId - id of the previous posting in this stream
Throws:
java.io.IOException

writePostings

public BitIndexPointer writePostings(IterablePosting postings,
                                     int previousId)
                              throws java.io.IOException
Write out the specified postings, but allowing the delta for the first document to be adjusted

Parameters:
postings - IterablePosting postings accessed through an IterablePosting object
previousId - id of the previous posting in this stream
Throws:
java.io.IOException

writePostings

public BitIndexPointer writePostings(IterablePosting postings)
                              throws java.io.IOException
Write out the specified postings.

Parameters:
postings - IterablePosting postings accessed through an IterablePosting object
Throws:
java.io.IOException

writePostingNotDocid

protected void writePostingNotDocid(Posting p)
                             throws java.io.IOException
Hook method for writing out the remainder of the posting

Throws:
java.io.IOException

writePostings

public BitIndexPointer writePostings(int[][] postings,
                                     int startOffset,
                                     int Length,
                                     int firstId)
                              throws java.io.IOException
Write out a range of the specified postings. The delta for the first id must be specified.

Parameters:
postings - The postings to write out
startOffset - The location of the first posting to write out.
Length - The number of postings to be written out.
firstId - the (delta) value of the first docid to write out.
Throws:
java.io.IOException

writeNoFieldPostings

protected BitIndexPointer writeNoFieldPostings(int[][] postings,
                                               int offset,
                                               int length,
                                               int firstId)
                                        throws java.io.IOException
Writes the given postings to the bit file. This method assumes that field information is not provided.

Parameters:
postings - the postings list to write.
firstId - the first identifier to write. This can be an id plus one, or the gap of the current id and the previous one.
offset - The location of the first posting to write out.
length - The number of postings to be written out.
Throws:
java.io.IOException - if an error occurs during writing to a file.

close

public void close()
close this object. suppresses any exception

Specified by:
close in interface java.io.Closeable

getOffset

public BitFilePosition getOffset()
What is current offset?


getByteOffset

public long getByteOffset()
Deprecated. 

Return the current offset in bytes in the written file


getBitOffset

public byte getBitOffset()
Deprecated. 

Return the current offset in bits in the written file


getBitOut

public BitOut getBitOut()
Return the underlying BitOut implementation being used by the class



Terrier 3.5. Copyright © 2004-2011 University of Glasgow