Package org.terrier.structures.bit
Class DirectInvertedOutputStream
- java.lang.Object
-
- org.terrier.structures.AbstractPostingOutputStream
-
- org.terrier.structures.bit.DirectInvertedOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
BlockDirectInvertedOutputStream
,DirectInvertedDocidOnlyOuptutStream
,FieldDirectInvertedOutputStream
public class DirectInvertedOutputStream extends AbstractPostingOutputStream implements java.io.Closeable
Writes a block direct or block inverted index, when passed appropriate posting lists.- Since:
- 2.0
- Author:
- Craig Macdonald
-
-
Constructor Summary
Constructors Constructor Description DirectInvertedOutputStream(java.io.OutputStream os)
Creates a new output stream, writing a BitOutputStream to the specified file.DirectInvertedOutputStream(java.lang.String filename)
Creates a new output stream, writing a BitOutputStream to the specified file.DirectInvertedOutputStream(BitOut out)
Creates a new output stream, writing to the specified BitOut implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
close this object.byte
getBitOffset()
Deprecated.BitOut
getBitOut()
Return the underlying BitOut implementation being used by the classlong
getByteOffset()
Deprecated.int
getLastDocidWritten()
BitFilePosition
getOffset()
What is current offset?java.lang.Class<? extends IterablePosting>
getPostingIteratorClass()
Returns the IterablePosting class to use for reading structure written by this classprotected 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 postingBitIndexPointer
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(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 adjustedBitIndexPointer
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
-
-
-
Field Detail
-
output
protected BitOut output
what to write to
-
lastDocid
protected int lastDocid
-
logger
protected static final org.slf4j.Logger logger
The logger used
-
-
Constructor Detail
-
DirectInvertedOutputStream
public DirectInvertedOutputStream(java.io.OutputStream os) 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:
os
- stream to write to- Throws:
java.io.IOException
-
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- Specified by:
getPostingIteratorClass
in classAbstractPostingOutputStream
-
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 outfirstId
- 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.- Specified by:
writePostings
in classAbstractPostingOutputStream
- 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- Specified by:
writePostings
in classAbstractPostingOutputStream
- Parameters:
iterator
- an Iterator of Posting objectspreviousId
- 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- Specified by:
writePostings
in classAbstractPostingOutputStream
- Parameters:
postings
- IterablePosting postings accessed through an IterablePosting objectpreviousId
- 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.- Specified by:
writePostings
in classAbstractPostingOutputStream
- 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.- Specified by:
writePostings
in classAbstractPostingOutputStream
- Parameters:
postings
- The postings to write outstartOffset
- 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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classAbstractPostingOutputStream
-
getOffset
public BitFilePosition getOffset()
What is current offset?- Specified by:
getOffset
in classAbstractPostingOutputStream
-
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
-
getLastDocidWritten
public int getLastDocidWritten()
- Specified by:
getLastDocidWritten
in classAbstractPostingOutputStream
-
-