org.cdlib.xtf.util
Class DiskHashReader

Object
  extended by DiskHashReader

public class DiskHashReader
extends Object

Provides quick access to a disk-based hash table created by a DiskHashWriter.

Author:
Martin Haye

Field Summary
(package private) static int headerSize
          Size of the header we expect to find
private  int nSlots
          Number of hash slots in the subfile
private  PackedByteBuf slotBuf
          Used to decode hash slot values
private  byte[] slotBytes
          Buffer used to read hash slot bytes
private  int slotSize
          Size of each hash slot
private  SubStoreReader subfile
          SubStore to read the hash from
 
Constructor Summary
DiskHashReader(SubStoreReader subfile)
          Read in the header of of the hash from the given subfile.
 
Method Summary
 void close()
          Closes the reader (and its associated subfile).
 PackedByteBuf find(String key)
          Locate the entry for the given string key.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headerSize

static final int headerSize
Size of the header we expect to find

See Also:
Constant Field Values

subfile

private SubStoreReader subfile
SubStore to read the hash from


nSlots

private int nSlots
Number of hash slots in the subfile


slotSize

private int slotSize
Size of each hash slot


slotBytes

private byte[] slotBytes
Buffer used to read hash slot bytes


slotBuf

private PackedByteBuf slotBuf
Used to decode hash slot values

Constructor Detail

DiskHashReader

public DiskHashReader(SubStoreReader subfile)
               throws IOException
Read in the header of of the hash from the given subfile.

Parameters:
subfile - Must have been created by DiskHashWriter.outputTo()
Throws:
IOException
Method Detail

close

public void close()
Closes the reader (and its associated subfile).


find

public PackedByteBuf find(String key)
                   throws IOException
Locate the entry for the given string key. If not found, returns null.

Parameters:
key - key to look for
Throws:
IOException