|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.di.mg4j.index.AbstractBitStreamIndexWriter
it.unimi.di.mg4j.index.BitStreamIndexWriter
public class BitStreamIndexWriter
Writes a bitstream-based interleaved index.
Indices written by this class are somewhat classical. Each inverted list contains the frequency, followed by gap-encoded pointers optionally interleaved with counts and gap-encoded positions. The compression technique used for each component can be chosen using a compression flag.
Interleaved indices of this kind are essentially unusable, as all information in each posting list must be entirely read (no skipping is possible). One
possible exception is disjunctive queries which use all the information in the index (e.g., with proximity scoring).
Another possible usage is to test the compression power of different codes, as essentially all classical compression
techniques are available. But, most importantly, the Scan
tool
generates interleaved indices as batches (albeit not using this class).
These are the files that form an interleaved index:
QuasiSuccinctIndex
) in δ code.
Field Summary | |
---|---|
protected int |
b
The parameter b for Golomb coding of pointers. |
protected static int |
BEFORE_COUNT
This value of state can be assumed only in indices that contain counts; it
means that we are positioned just before the count for the current document record. |
protected static int |
BEFORE_DOCUMENT_RECORD
This value of state means that we are ready to call newDocumentRecord() . |
protected static int |
BEFORE_FREQUENCY
This value of state means that we are positioned at the start of an inverted list,
and we should call writeFrequency(int) . |
protected static int |
BEFORE_INVERTED_LIST
This value of state means that we should call newInvertedList() . |
protected static int |
BEFORE_PAYLOAD
This value of state can be assumed only in indices that contain payloads; it
means that we are positioned just before the payload for the current document record. |
protected static int |
BEFORE_POINTER
This value of state means that we just started a new document record, and we
should call writeDocumentPointer(OutputBitStream, int) . |
protected static int |
BEFORE_POSITIONS
This value of state can be assumed only in indices that contain document positions;
it means that we are positioned just before the position list of the current document record. |
protected int |
currentDocument
The current document pointer. |
protected static int |
FIRST_UNUSED_STATE
This is the first unused state. |
protected int |
frequency
The number of document records that the current inverted list will contain. |
protected int |
lastDocument
The last document pointer in the current list. |
protected long |
lastInvertedListPos
The position (in bytes) where the last inverted list started. |
protected int |
log2b
The parameter log2b for Golomb coding of pointers; it is the most significant bit of b . |
int |
maxCount
The maximum number of positions in a document record so far. |
protected OutputBitStream |
obs
The underlying OutputBitStream . |
protected int |
state
The current state of the writer. |
protected int |
writtenDocuments
The number of document records already written for the current inverted list. |
Fields inherited from class it.unimi.di.mg4j.index.AbstractBitStreamIndexWriter |
---|
bitsForCounts, bitsForFrequencies, bitsForPayloads, bitsForPointers, bitsForPositions, countCoding, currentTerm, flags, frequencyCoding, hasCounts, hasPayloads, hasPositions, numberOfDocuments, numberOfOccurrences, numberOfPostings, pointerCoding, positionCoding |
Constructor Summary | |
---|---|
BitStreamIndexWriter(IOFactory ioFactory,
CharSequence basename,
int numberOfDocuments,
boolean writeOffsets,
Map<CompressionFlags.Component,CompressionFlags.Coding> flags)
Creates a new index writer with the specified basename. |
Method Summary | |
---|---|
void |
close()
Closes this index writer, completing the index creation process and releasing all resources. |
OutputBitStream |
newDocumentRecord()
Starts a new document record. |
long |
newInvertedList()
Starts a new inverted list. |
Properties |
properties()
Returns properties of the index generated by this index writer. |
void |
writeDocumentPointer(OutputBitStream out,
int pointer)
Writes a document pointer. |
void |
writeDocumentPositions(OutputBitStream out,
int[] position,
int offset,
int count,
int docSize)
Writes the positions of the occurrences of the current term in the current document to the given OutputBitStream . |
void |
writeFrequency(int frequency)
Writes the frequency. |
void |
writePayload(OutputBitStream out,
Payload payload)
Writes the payload for the current document. |
void |
writePositionCount(OutputBitStream out,
int count)
Writes the count of the occurrences of the current term in the current document to the given OutputBitStream . |
long |
writtenBits()
Returns the overall number of bits written onto the underlying stream(s). |
Methods inherited from class it.unimi.di.mg4j.index.AbstractBitStreamIndexWriter |
---|
printStats |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int BEFORE_INVERTED_LIST
state
means that we should call newInvertedList()
.
protected static final int BEFORE_FREQUENCY
state
means that we are positioned at the start of an inverted list,
and we should call writeFrequency(int)
.
protected static final int BEFORE_DOCUMENT_RECORD
state
means that we are ready to call newDocumentRecord()
.
protected static final int BEFORE_POINTER
state
means that we just started a new document record, and we
should call writeDocumentPointer(OutputBitStream, int)
.
protected static final int BEFORE_PAYLOAD
state
can be assumed only in indices that contain payloads; it
means that we are positioned just before the payload for the current document record.
protected static final int BEFORE_COUNT
state
can be assumed only in indices that contain counts; it
means that we are positioned just before the count for the current document record.
protected static final int BEFORE_POSITIONS
state
can be assumed only in indices that contain document positions;
it means that we are positioned just before the position list of the current document record.
protected static final int FIRST_UNUSED_STATE
protected OutputBitStream obs
OutputBitStream
.
protected int state
protected int frequency
protected int writtenDocuments
protected int currentDocument
protected int lastDocument
protected long lastInvertedListPos
public int maxCount
protected int b
b
for Golomb coding of pointers.
protected int log2b
log2b
for Golomb coding of pointers; it is the most significant bit of b
.
Constructor Detail |
---|
public BitStreamIndexWriter(IOFactory ioFactory, CharSequence basename, int numberOfDocuments, boolean writeOffsets, Map<CompressionFlags.Component,CompressionFlags.Coding> flags) throws IOException
writeOffsets
, also an offset file will be produced (stemmed with .offsets).
When close()
will be called, the property file will also be produced (stemmed with .properties),
or enriched if it already exists.
ioFactory
- the factory that will be used to perform I/O.basename
- the basename.numberOfDocuments
- the number of documents in the collection to be indexed.writeOffsets
- if true
, the offset file will also be produced.flags
- a flag map setting the coding techniques to be used (see CompressionFlags
).
IOException
Method Detail |
---|
public long newInvertedList() throws IOException
IndexWriter
IOException
public void writeFrequency(int frequency) throws IOException
IndexWriter
frequency
- the (positive) number of document records that this inverted list will contain.
IOException
public OutputBitStream newDocumentRecord() throws IOException
IndexWriter
This method must be called exactly exactly f times, where f is the frequency specified with
IndexWriter.writeFrequency(int)
.
null
,
if IndexWriter.writeDocumentPointer(OutputBitStream, int)
ignores its first argument.
IOException
public void writeDocumentPointer(OutputBitStream out, int pointer) throws IOException
IndexWriter
This method must be called immediately after IndexWriter.newDocumentRecord()
.
out
- the output bit stream where the pointer will be written.pointer
- the document pointer.
IOException
public void writePayload(OutputBitStream out, Payload payload) throws IOException
IndexWriter
This method must be called immediately after IndexWriter.writeDocumentPointer(OutputBitStream, int)
.
out
- the output bit stream where the payload will be written.payload
- the payload.
IOException
public void close() throws IOException
IndexWriter
IOException
public void writePositionCount(OutputBitStream out, int count) throws IOException
IndexWriter
OutputBitStream
.
out
- the output stream where the occurrences should be written.count
- the count.
IOException
public void writeDocumentPositions(OutputBitStream out, int[] position, int offset, int count, int docSize) throws IOException
IndexWriter
OutputBitStream
.
out
- the output stream where the occurrences should be written.position
- the position vector (a sequence of strictly increasing natural numbers).offset
- the first valid entry in position
.count
- the number of valid entries in position
starting from offset
.docSize
- the size of the current document (only for Golomb and interpolative coding; you can safely pass -1 otherwise).
IOException
public long writtenBits()
IndexWriter
public Properties properties()
IndexWriter
This method should only be called after IndexWriter.close()
.
It returns a new property object
containing values for (whenever appropriate)
Index.PropertyKeys.DOCUMENTS
, Index.PropertyKeys.TERMS
,
Index.PropertyKeys.POSTINGS
, Index.PropertyKeys.MAXCOUNT
,
Index.PropertyKeys.INDEXCLASS
, Index.PropertyKeys.CODING
, Index.PropertyKeys.PAYLOADCLASS
,
BitStreamIndex.PropertyKeys.SKIPQUANTUM
, and BitStreamIndex.PropertyKeys.SKIPHEIGHT
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |