Package org.terrier.structures.bit
Class BitPostingIndexInputStream
- java.lang.Object
-
- org.terrier.structures.bit.BitPostingIndexInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.util.Iterator<IterablePosting>
,PostingIndexInputStream
,Skipable
public class BitPostingIndexInputStream extends java.lang.Object implements PostingIndexInputStream, Skipable
Input stream for a bit posting index.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
currentEntryCount
protected byte
currentFile
protected BitIndexPointer
currentPointer
protected DocumentIndex
doi
protected int
entriesSkipped
protected int
fieldCount
protected BitIn
file
The gamma compressed file containing the terms.protected byte
fileCount
protected IndexOnDisk
index
protected static org.slf4j.Logger
logger
protected java.util.Iterator<? extends BitIndexPointer>
pointerList
the lexicon input stream providing the offsetsprotected java.lang.reflect.Constructor<? extends IterablePosting>
postingConstructor
protected java.lang.Class<? extends IterablePosting>
postingIteratorClass
protected java.lang.String
structureName
-
Constructor Summary
Constructors Constructor Description BitPostingIndexInputStream(IndexOnDisk _index, java.lang.String _structureName, java.util.Iterator<? extends BitIndexPointer> _pointerList, java.lang.Class<? extends IterablePosting> _postingIteratorClass)
Constructs an instance of BitPostingIndexInputStream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BitIndexPointer
_next()
void
close()
Pointer
getCurrentPointer()
Returns the pointer associated with the current postings being accessedprotected DocumentIndex
getDocumentIndex(BitIndexPointer pointer)
int
getEntriesSkipped()
Returns the number of entries that were skipped during a call to the next().static java.lang.String
getFilename(java.lang.String path, java.lang.String prefix, java.lang.String structureName, byte fileCount, byte fileId)
Return filenamestatic java.lang.String
getFilename(IndexOnDisk _index, java.lang.String structureName, byte fileCount, byte fileId)
Returns filenameIterablePosting
getNextPostings()
Return the next IterablePosting object, or null if none defined.int
getNumberOfCurrentPostings()
Returns the number of postings in the current IterablePosting objectBitFilePosition
getPos()
Get the file positionboolean
hasNext()
protected IterablePosting
loadPostingIterator(BitIndexPointer pointer)
IterablePosting
next()
void
print()
Print a list of the postings to standard outvoid
remove()
Not supportedvoid
skip(int numEntries)
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
pointerList
protected final java.util.Iterator<? extends BitIndexPointer> pointerList
the lexicon input stream providing the offsets
-
file
protected BitIn file
The gamma compressed file containing the terms.
-
postingIteratorClass
protected java.lang.Class<? extends IterablePosting> postingIteratorClass
-
postingConstructor
protected java.lang.reflect.Constructor<? extends IterablePosting> postingConstructor
-
currentEntryCount
protected int currentEntryCount
-
currentPointer
protected BitIndexPointer currentPointer
-
fieldCount
protected int fieldCount
-
entriesSkipped
protected int entriesSkipped
-
fileCount
protected byte fileCount
-
currentFile
protected byte currentFile
-
index
protected IndexOnDisk index
-
doi
protected DocumentIndex doi
-
structureName
protected java.lang.String structureName
-
-
Constructor Detail
-
BitPostingIndexInputStream
public BitPostingIndexInputStream(IndexOnDisk _index, java.lang.String _structureName, java.util.Iterator<? extends BitIndexPointer> _pointerList, java.lang.Class<? extends IterablePosting> _postingIteratorClass) throws java.io.IOException
Constructs an instance of BitPostingIndexInputStream.- Parameters:
_index
-_structureName
-_pointerList
-_postingIteratorClass
-- Throws:
java.io.IOException
-
-
Method Detail
-
getFilename
public static java.lang.String getFilename(java.lang.String path, java.lang.String prefix, java.lang.String structureName, byte fileCount, byte fileId)
Return filename- Parameters:
path
-prefix
-structureName
-fileCount
-fileId
-- Returns:
- filename
-
getFilename
public static java.lang.String getFilename(IndexOnDisk _index, java.lang.String structureName, byte fileCount, byte fileId)
Returns filename- Parameters:
_index
-structureName
-fileCount
-fileId
-- Returns:
- filename
-
getPos
public BitFilePosition getPos()
Get the file position
-
skip
public void skip(int numEntries) throws java.io.IOException
-
getNumberOfCurrentPostings
public int getNumberOfCurrentPostings()
Returns the number of postings in the current IterablePosting object- Specified by:
getNumberOfCurrentPostings
in interfacePostingIndexInputStream
-
getNextPostings
public IterablePosting getNextPostings() throws java.io.IOException
Return the next IterablePosting object, or null if none defined. Use this method instead of hasNext() and next().- Specified by:
getNextPostings
in interfacePostingIndexInputStream
- Returns:
- IterablePosting postings for next object
- Throws:
java.io.IOException
- if an I/O problem occurs.
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<IterablePosting>
-
_next
protected BitIndexPointer _next()
-
next
public IterablePosting next()
- Specified by:
next
in interfacejava.util.Iterator<IterablePosting>
-
getEntriesSkipped
public int getEntriesSkipped()
Returns the number of entries that were skipped during a call to the next().- Specified by:
getEntriesSkipped
in interfacePostingIndexInputStream
- Returns:
- int the number of entries skipped.
-
loadPostingIterator
protected IterablePosting loadPostingIterator(BitIndexPointer pointer) throws java.io.IOException
- Throws:
java.io.IOException
-
getDocumentIndex
protected DocumentIndex getDocumentIndex(BitIndexPointer pointer)
-
print
public void print()
Print a list of the postings to standard out- Specified by:
print
in interfacePostingIndexInputStream
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
remove
public void remove()
Not supported- Specified by:
remove
in interfacejava.util.Iterator<IterablePosting>
-
getCurrentPointer
public Pointer getCurrentPointer()
Returns the pointer associated with the current postings being accessed- Specified by:
getCurrentPointer
in interfacePostingIndexInputStream
-
-