it.unimi.dsi.mg4j.index
Class SkipIndex

java.lang.Object
  extended byit.unimi.dsi.mg4j.index.Index
      extended byit.unimi.dsi.mg4j.index.SkipIndex
All Implemented Interfaces:
CompressionFlags

public class SkipIndex
extends Index

An abstract representation of an index with skips.

An instance of this class stores, besides the data contained in an Index, data related to skipping (quantum, height, etc.).

Since:
0.9
Author:
Paolo Boldi, Sebastiano Vigna

Field Summary
 int height
          The parameter h (the maximum height of a skip tower).
 int quantum
          The quantum.
 
Fields inherited from class it.unimi.dsi.mg4j.index.Index
basename, countCoding, emptyDocumentIterator, frequencyCoding, hasCounts, hasPositions, indexFile, isCaseSensitive, maxDocPos, numberOfDocuments, numberOfTerms, offsets, pointerCoding, positionCoding, properties, singletonSet, sizes, termMap
 
Fields inherited from interface it.unimi.dsi.mg4j.index.CompressionFlags
ARITH, CODING_NAME, COUNTS_DEFAULT, COUNTS_DELTA, COUNTS_GAMMA, COUNTS_SHIFT, DELTA, FREQUENCIES_DEFAULT, FREQUENCIES_DELTA, FREQUENCIES_GAMMA, FREQUENCIES_SHIFT, GAMMA, GOLOMB, INTERP, NIBBLE, NO_COUNTS, NO_POSITIONS, NONE, POINTERS_DEFAULT, POINTERS_DELTA, POINTERS_GAMMA, POINTERS_GOLOMB, POINTERS_SHIFT, POSITIONS_ARITH, POSITIONS_DEFAULT, POSITIONS_DELTA, POSITIONS_GAMMA, POSITIONS_GOLOMB, POSITIONS_INTERP, POSITIONS_SHIFT, POSITIONS_SKEWED_GOLOMB, SKEWED_GOLOMB, UNARY, ZETA
 
Constructor Summary
protected SkipIndex(CharSequence basename, TermMap termMap, boolean loadOffsets, ProgressMeter pm)
          Creates a new skip index using the given basename.
  SkipIndex(String basename, File indexFile, Properties properties, int numberOfDocuments, int numberOfTerms, int maxDocPos, boolean isCaseSensitive, long flags, TermMap termMap, LongList offsets, IntList sizes, int quantum, int height)
          Creates a new skip index using the given data.
 
Method Summary
 IndexReader getReader()
          Creates and returns a new IndexReader based on this index.
 IndexReader getReader(int bufferSize)
          Creates and returns a new IndexReader based on this index.
 
Methods inherited from class it.unimi.dsi.mg4j.index.Index
getInstance, getInstance, getInstance, getInstance, loadTermMap, main, readOffsets, readSizes, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

height

public final int height
The parameter h (the maximum height of a skip tower).


quantum

public final int quantum
The quantum.

Constructor Detail

SkipIndex

protected SkipIndex(CharSequence basename,
                    TermMap termMap,
                    boolean loadOffsets,
                    ProgressMeter pm)
             throws IOException
Creates a new skip index using the given basename.

Parameters:
basename - the basename of the index.
termMap - the term list for this index, or null if there is no term list.
loadOffsets - offsets are loaded only if this parameter is true.
pm - an optional progress meter. If null, no progress information will be displayed.

SkipIndex

public SkipIndex(String basename,
                 File indexFile,
                 Properties properties,
                 int numberOfDocuments,
                 int numberOfTerms,
                 int maxDocPos,
                 boolean isCaseSensitive,
                 long flags,
                 TermMap termMap,
                 LongList offsets,
                 IntList sizes,
                 int quantum,
                 int height)
          throws IOException
Creates a new skip index using the given data.

This constructor provides an index that is initialised exactly to the provided data. It is mainly useful for debugging and testing purposes, in the case you are creating an index file (for instance, as a memory-based bit stream) but you have no property file to use with Index.getInstance(CharSequence).

It is usually safe to provide null for basename, indexFile and properties, but the responsibility for data consistence is up to the caller.

Parameters:
basename - the basename of this index, or null.
indexFile - the file containing this index, or null.
properties - the properties of this index, or null.
numberOfDocuments - the number of documents in this index.
numberOfTerms - the number of terms in this index.
maxDocPos - the maximum length of an occurrence list, or -1 if it is not known.
flags - a bit mask setting the coding techniques to be used (see CompressionFlags).
termMap - the term list for this index, or null if there is no term list.
offsets - the offset list; may be null if you do not plan using IndexReader.position(int).
sizes - the size list; may be null if your code does not require it.
quantum - the quantum to be used if this index has skips (0 means that this index has no skips).
height - the height (meaningless if quantum is zero).
Method Detail

getReader

public IndexReader getReader()
                      throws IOException
Creates and returns a new IndexReader based on this index. After that, you can use the reader to read this index.

Overrides:
getReader in class Index
Returns:
a new SkipIndexReader to read this index.
Throws:
IOException

getReader

public IndexReader getReader(int bufferSize)
                      throws IOException
Creates and returns a new IndexReader based on this index. After that, you can use the reader to read this index.

Overrides:
getReader in class Index
Parameters:
bufferSize - the size of the buffer to be used when opening the InputBitStream underlying the SkipIndexReader that is going to be returned.
Returns:
a new SkipIndexReader to read this index.
Throws:
IOException