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

java.lang.Object
  extended by com.sun.labs.minion.indexer.dictionary.DictionaryHeader

public class DictionaryHeader
extends java.lang.Object

A class that contains the header information for a dictionary.


Field Summary
protected static int BAD_MAGIC
           
protected  int entryInfoOffsetsBytes
          The number of bytes used to encode the offsets for the term information.
protected  long entryInfoOffsetsPos
          The position of the entry info offsets buffer.
protected  int entryInfoOffsetsSize
          The size of the entry info offsets buffer.
protected  long entryInfoPos
          The position of the entry info buffer.
protected  int entryInfoSize
          The size of the entry info buffer.
protected static int GOOD_MAGIC
          Good magic.
protected  int idToPosnBytes
          The number of bytes that each ID to posn map entry requires.
protected  long idToPosnPos
          The offset of the ID to position map in the file.
protected  int idToPosnSize
          The size of the map from ID to position in the dictionary.
protected  int magic
          A magic number, written last.
protected  int maxEntryID
          The maximum ID assigned to an entry, which may be different than the size.
protected  int nameOffsetsBytes
          The number of bytes used to encode the offsets for the uncompressed names.
protected  long nameOffsetsPos
          The position of the names offset buffer.
protected  int nameOffsetsSize
          The size of the names offset buffer.
protected  long namesPos
          The position of the names buffer.
protected  int namesSize
          The size of the names buffer.
protected  int nOffsets
          The number of name offsets.
protected  long[] postEnd
          The ending offsets for postings associated with this dictionary.
protected  long[] postStart
          The starting offsets for postings associated with this dictionary.
protected  int size
          The number of entries in the dictionary.
 
Constructor Summary
DictionaryHeader(int n)
          Creates an empty header, suitable for filling during dumping.
DictionaryHeader(java.io.RandomAccessFile dictFile)
          Creates a dictionary header by reading it from the provided channel.
 
Method Summary
protected  void computeValues()
          Computes derived values.
 int getMaxID()
          Gets the maximum ID in the dictionary.
 void goodMagic()
          Tells the header that the magic is good.
 void read(java.io.RandomAccessFile dictFile)
          Reads a dictionary header from the given channel.
 java.lang.String toString()
           
 void write(java.io.RandomAccessFile dictFile)
          Writes a dictionary header to the given channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

magic

protected int magic
A magic number, written last.


size

protected int size
The number of entries in the dictionary.


maxEntryID

protected int maxEntryID
The maximum ID assigned to an entry, which may be different than the size.


idToPosnPos

protected long idToPosnPos
The offset of the ID to position map in the file.


idToPosnSize

protected int idToPosnSize
The size of the map from ID to position in the dictionary.


idToPosnBytes

protected int idToPosnBytes
The number of bytes that each ID to posn map entry requires.


nameOffsetsPos

protected long nameOffsetsPos
The position of the names offset buffer.


nameOffsetsSize

protected int nameOffsetsSize
The size of the names offset buffer.


nameOffsetsBytes

protected int nameOffsetsBytes
The number of bytes used to encode the offsets for the uncompressed names.


namesPos

protected long namesPos
The position of the names buffer.


namesSize

protected int namesSize
The size of the names buffer.


nOffsets

protected int nOffsets
The number of name offsets.


entryInfoOffsetsPos

protected long entryInfoOffsetsPos
The position of the entry info offsets buffer.


entryInfoOffsetsSize

protected int entryInfoOffsetsSize
The size of the entry info offsets buffer.


entryInfoOffsetsBytes

protected int entryInfoOffsetsBytes
The number of bytes used to encode the offsets for the term information.


entryInfoPos

protected long entryInfoPos
The position of the entry info buffer.


entryInfoSize

protected int entryInfoSize
The size of the entry info buffer.


postStart

protected long[] postStart
The starting offsets for postings associated with this dictionary.


postEnd

protected long[] postEnd
The ending offsets for postings associated with this dictionary.


GOOD_MAGIC

protected static final int GOOD_MAGIC
Good magic.

See Also:
Constant Field Values

BAD_MAGIC

protected static final int BAD_MAGIC
See Also:
Constant Field Values
Constructor Detail

DictionaryHeader

public DictionaryHeader(int n)
Creates an empty header, suitable for filling during dumping.

Parameters:
n - The number of postings channels associated with the dictionary for which this is a header.

DictionaryHeader

public DictionaryHeader(java.io.RandomAccessFile dictFile)
                 throws java.io.IOException
Creates a dictionary header by reading it from the provided channel.

Throws:
java.io.IOException
Method Detail

computeValues

protected void computeValues()
Computes derived values.


goodMagic

public void goodMagic()
Tells the header that the magic is good.


read

public void read(java.io.RandomAccessFile dictFile)
          throws java.io.IOException
Reads a dictionary header from the given channel.

Throws:
java.io.IOException

write

public void write(java.io.RandomAccessFile dictFile)
           throws java.io.IOException
Writes a dictionary header to the given channel.

Throws:
java.io.IOException

getMaxID

public int getMaxID()
Gets the maximum ID in the dictionary.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object