|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.galagosearch.core.index.IndexReader
public class IndexReader
This implements the core functionality for all inverted list readers. It can also be used as a read-only TreeMap for disk-based data structures. In Galago, it is used both to store index data and to store documents.
An index is a mapping from String to byte[]. If compression is turned on, the value must be small enough that it fits in memory. If compression is off, values are streamed directly from disk so there is no size restriction. Indexes support iteration over all keys, or direct lookup of a single key. The structure is optimized to support fast random lookup on disks.
Data is stored in blocks, typically 32K each. Each block has a prefix-compressed set of keys at the beginning, followed by a block of value data. IndexWriter/IndexReader can GZip compress that value data, or it can be stored uncompressed. For inverted list data it's best to use your own compression, but for text data the GZip compression is a good choice.
Typically this class is extended by composition instead of inheritance.
| Nested Class Summary | |
|---|---|
class |
IndexReader.Iterator
|
| Constructor Summary | |
|---|---|
IndexReader(java.io.File pathname)
Identical to the other constructor, except this
one takes a File object instead of a string as the parameter. |
|
IndexReader(java.lang.String pathname)
Opens an index found in the at pathname. |
|
| Method Summary | |
|---|---|
org.galagosearch.tupleflow.DataStream |
blockStream(IndexReader.Iterator iter)
This convenience method returns a DataStream for the region of the inverted file pointed to by the iterator. |
org.galagosearch.tupleflow.DataStream |
blockStream(long len)
Like the other blockStream variant, but this one uses the current file location as the starting offset. |
org.galagosearch.tupleflow.DataStream |
blockStream(long offset,
long length)
This convenience method returns a DataStream for a region of an inverted file. |
void |
close()
Closes all files associated with the IndexReader. |
java.io.RandomAccessFile |
getInput()
Returns the file object for the inverted file. |
IndexReader.Iterator |
getIterator()
Returns an iterator pointing to the very first key in the index. |
IndexReader.Iterator |
getIterator(java.lang.String key)
Returns an iterator pointing at a specific key. |
org.galagosearch.tupleflow.Parameters |
getManifest()
Returns a Parameters object that contains metadata about the contents of the index. |
org.galagosearch.tupleflow.DataStream |
getValueStream(java.lang.String key)
Gets the value stored in the index associated with this key. |
java.lang.String |
getValueString(java.lang.String key)
Gets the value stored in the index associated with this key. |
VocabularyReader |
getVocabulary()
Returns the vocabulary structure for this IndexReader. |
static boolean |
isIndexFile(java.lang.String pathname)
Returns true if the file specified by this pathname was probably written by IndexWriter. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IndexReader(java.lang.String pathname)
throws java.io.FileNotFoundException,
java.io.IOException
pathname - Filename of the index to open.
java.io.FileNotFoundException
java.io.IOException
public IndexReader(java.io.File pathname)
throws java.io.FileNotFoundException,
java.io.IOException
other constructor, except this
one takes a File object instead of a string as the parameter.
pathname -
java.io.FileNotFoundException
java.io.IOException| Method Detail |
|---|
public static boolean isIndexFile(java.lang.String pathname)
throws java.io.FileNotFoundException,
java.io.IOException
pathname -
java.io.FileNotFoundException
java.io.IOExceptionpublic VocabularyReader getVocabulary()
public IndexReader.Iterator getIterator()
throws java.io.IOException
java.io.IOException
public IndexReader.Iterator getIterator(java.lang.String key)
throws java.io.IOException
java.io.IOException
public java.lang.String getValueString(java.lang.String key)
throws java.io.IOException
key -
java.io.IOException
public org.galagosearch.tupleflow.DataStream getValueStream(java.lang.String key)
throws java.io.IOException
key -
java.io.IOExceptionpublic org.galagosearch.tupleflow.Parameters getManifest()
public org.galagosearch.tupleflow.DataStream blockStream(long len)
throws java.io.IOException
java.io.IOException
public org.galagosearch.tupleflow.DataStream blockStream(long offset,
long length)
throws java.io.IOException
java.io.IOException
public org.galagosearch.tupleflow.DataStream blockStream(IndexReader.Iterator iter)
throws java.io.IOException
java.io.IOExceptionpublic java.io.RandomAccessFile getInput()
public void close()
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||