com.sun.labs.minion.indexer.dictionary
Class CachedDiskDictionary

java.lang.Object
  extended by com.sun.labs.minion.indexer.dictionary.DiskDictionary
      extended by com.sun.labs.minion.indexer.dictionary.CachedDiskDictionary
All Implemented Interfaces:
Dictionary, java.lang.Iterable<QueryEntry>
Direct Known Subclasses:
CachedTermStatsDictionary

public class CachedDiskDictionary
extends DiskDictionary


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.labs.minion.indexer.dictionary.DiskDictionary
DiskDictionary.DiskDictionaryIterator, DiskDictionary.HE, DiskDictionary.LightDiskDictionaryIterator, DiskDictionary.LookupState
 
Field Summary
static java.lang.String logTag
           
 
Fields inherited from class com.sun.labs.minion.indexer.dictionary.DiskDictionary
CHANNEL_FULL_POST, CHANNEL_PART_POST, decoder, dh, dictFile, entryClass, entryInfo, entryInfoOffsets, FILE_FULL_POST, FILE_PART_POST, idToPosn, nameCache, nameOffsets, names, nLoads, part, posnCache, postFiles, postIn, totalSize
 
Constructor Summary
CachedDiskDictionary(java.lang.Class entryClass, NameDecoder decoder, java.io.RandomAccessFile dictFile, java.io.RandomAccessFile[] postFiles)
          Creates a disk dictionary that we can use for querying.
CachedDiskDictionary(java.lang.Class entryClass, NameDecoder decoder, java.io.RandomAccessFile dictFile, java.io.RandomAccessFile[] postFiles, int postInType, int nameBufferSize, int offsetsBufferSize, int infoBufferSize, int infoOffsetsBufferSize, Partition part)
          Creates a disk dictionary that we can use for querying.
CachedDiskDictionary(java.lang.Class entryClass, NameDecoder decoder, java.io.RandomAccessFile dictFile, java.io.RandomAccessFile[] postFiles, int postInType, Partition part)
          Creates a disk dictionary that we can use for querying.
CachedDiskDictionary(java.lang.Class entryClass, NameDecoder decoder, java.io.RandomAccessFile dictFile, java.io.RandomAccessFile[] postFiles, Partition part)
          Creates a disk dictionary that we can use for querying.
 
Method Summary
 QueryEntry get(int id)
          Gets a entry from the dictionary, given the ID for the entry.
 QueryEntry get(java.lang.Object name)
          Gets a entry from the dictionary, given the name for the entry.
 DictionaryIterator iterator()
          Gets an iterator for this dictionary.
 DictionaryIterator iterator(int begin, int end)
          Gets an iterator for the dictionary that starts and stops at the given indices in the dictionary.
 
Methods inherited from class com.sun.labs.minion.indexer.dictionary.DiskDictionary
customSetup, find, findPos, findPos, get, get, getBufferedInputs, getBufferedInputs, getLookupState, getMatching, getMaxID, getPartition, getSpellingVariants, getStemMatches, getSubstring, iterator, iterator, literator, merge, merge, newEntry, newEntry, put, remapPostings, setCacheSize, setPartition, setUpBuffers, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logTag

public static final java.lang.String logTag
See Also:
Constant Field Values
Constructor Detail

CachedDiskDictionary

public CachedDiskDictionary(java.lang.Class entryClass,
                            NameDecoder decoder,
                            java.io.RandomAccessFile dictFile,
                            java.io.RandomAccessFile[] postFiles)
                     throws java.io.IOException
Creates a disk dictionary that we can use for querying.

Parameters:
entryClass - The class of the entries that the dictionary contains.
decoder - A decoder for the names in this dictionary.
dictFile - The file containing the dictionary.
postFiles - The files containing the postings associated with the entries in this dictionary.
Throws:
java.io.IOException - if there is any error opening the dictionary

CachedDiskDictionary

public CachedDiskDictionary(java.lang.Class entryClass,
                            NameDecoder decoder,
                            java.io.RandomAccessFile dictFile,
                            java.io.RandomAccessFile[] postFiles,
                            Partition part)
                     throws java.io.IOException
Creates a disk dictionary that we can use for querying.

Parameters:
entryClass - The class of the entries that the dictionary contains.
decoder - A decoder for the names in this dictionary.
dictFile - The file containing the dictionary.
postFiles - The files containing the postings associated with the entries in this dictionary.
part - The partition with which this dictionary is associated.
Throws:
java.io.IOException - if there is any error opening the dictionary

CachedDiskDictionary

public CachedDiskDictionary(java.lang.Class entryClass,
                            NameDecoder decoder,
                            java.io.RandomAccessFile dictFile,
                            java.io.RandomAccessFile[] postFiles,
                            int postInType,
                            Partition part)
                     throws java.io.IOException
Creates a disk dictionary that we can use for querying.

Parameters:
entryClass - The class of the entries that the dictionary contains.
decoder - A decoder for the names in this dictionary.
dictFile - The file containing the dictionary.
postFiles - The files containing the postings associated with the entries in this dictionary.
postInType - The type of postings input to use.
part - The partition with which this dictionary is associated.
Throws:
java.io.IOException - if there is any error opening the dictionary

CachedDiskDictionary

public CachedDiskDictionary(java.lang.Class entryClass,
                            NameDecoder decoder,
                            java.io.RandomAccessFile dictFile,
                            java.io.RandomAccessFile[] postFiles,
                            int postInType,
                            int nameBufferSize,
                            int offsetsBufferSize,
                            int infoBufferSize,
                            int infoOffsetsBufferSize,
                            Partition part)
                     throws java.io.IOException
Creates a disk dictionary that we can use for querying.

Parameters:
nameBufferSize - the size of the buffer (in bytes) to use for the entry names
offsetsBufferSize - the size of the buffer (in bytes) to use for the entry name offsets
infoBufferSize - the size of the buffer (in bytes) to use for the entry information
infoOffsetsBufferSize - the size of the buffer (in bytes) to use for the entry information offsets
entryClass - The class of the entries that the dictionary contains.
decoder - A decoder for the names in this dictionary.
dictFile - The file containing the dictionary.
postFiles - The files containing the postings associated with the entries in this dictionary.
postInType - The type of postings input to use.
part - The partition with which this dictionary is associated.
Throws:
java.io.IOException - if there is any error opening the dictionary
Method Detail

get

public QueryEntry get(java.lang.Object name)
Gets a entry from the dictionary, given the name for the entry.

Specified by:
get in interface Dictionary
Overrides:
get in class DiskDictionary
Parameters:
name - The name of the entry to get.
Returns:
The entry associated with the name, or null if the name doesn't appear in the dictionary.

get

public QueryEntry get(int id)
Gets a entry from the dictionary, given the ID for the entry.

Overrides:
get in class DiskDictionary
Parameters:
id - the ID to find.
Returns:
The block, or null if the ID doesn't occur in our dictionary.

iterator

public DictionaryIterator iterator()
Description copied from class: DiskDictionary
Gets an iterator for this dictionary. Just gets an iterator for the block.

Specified by:
iterator in interface Dictionary
Specified by:
iterator in interface java.lang.Iterable<QueryEntry>
Overrides:
iterator in class DiskDictionary
Returns:
an iterator for the dictionary. The elements of the iterator implement the Map.Entry interface

iterator

public DictionaryIterator iterator(int begin,
                                   int end)
Gets an iterator for the dictionary that starts and stops at the given indices in the dictionary. This can be used when we want to process pieces of a dictionary in different threads.

Overrides:
iterator in class DiskDictionary
Parameters:
begin - the beginning index in the dictionary, counting from 0. If this value is less than zero it will be clamped to zero.
end - the ending index in the dictionary, counting from 0. If this value is greater than the number of entries in the dictionary, it will be limited to that number.
Returns:
an iterator for the dictionary. The elements of the iterator implement the Map.Entry interface