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

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

public class FieldStoreHeader
extends java.lang.Object


Field Summary
protected  java.nio.ByteBuffer bb
          The byte buffer underlying our buffer of longs.
protected  java.nio.LongBuffer lb
          A buffer to hold the offsets of the dictionaries for the fields.
protected  int nFields
          The number of field offsets that we're storing.
 
Constructor Summary
FieldStoreHeader(java.nio.channels.FileChannel c)
          Creates a header for the given number of fields by reading it from the given channel.
FieldStoreHeader(int nFields)
          Creates a header for the given number of fields.
 
Method Summary
 void addOffset(int f, long offset)
          Adds a dictionary offset for a given field.
 long getOffset(int f)
          Gets an offset for a given field.
 void read(java.nio.channels.FileChannel c)
          Reads the header from the given channel
 java.lang.String toString()
           
 void write(java.nio.channels.FileChannel c)
          Writes the header to the given channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nFields

protected int nFields
The number of field offsets that we're storing.


lb

protected java.nio.LongBuffer lb
A buffer to hold the offsets of the dictionaries for the fields.


bb

protected java.nio.ByteBuffer bb
The byte buffer underlying our buffer of longs.

Constructor Detail

FieldStoreHeader

public FieldStoreHeader(int nFields)
Creates a header for the given number of fields.


FieldStoreHeader

public FieldStoreHeader(java.nio.channels.FileChannel c)
                 throws java.io.IOException
Creates a header for the given number of fields by reading it from the given channel.

Parameters:
c - The channel from which to read the header.
Throws:
java.io.IOException - if there is any error reading the header.
Method Detail

addOffset

public void addOffset(int f,
                      long offset)
Adds a dictionary offset for a given field.

Parameters:
f - The ID of the field whose offset we want to add.
offset - The offset of the field dictionary.

getOffset

public long getOffset(int f)
Gets an offset for a given field.

Parameters:
f - The ID of the field whose offset we want to get.

write

public void write(java.nio.channels.FileChannel c)
           throws java.io.IOException
Writes the header to the given channel.

Parameters:
c - The channel to which we will write the header.
Throws:
java.io.IOException - if there is any error writing the data.

read

public void read(java.nio.channels.FileChannel c)
          throws java.io.IOException
Reads the header from the given channel

Parameters:
c - The channel from which to read the header.
Throws:
java.io.IOException - if there is any error reading the header.

toString

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