|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gov.nist.nlpir.irf.index.braf.PersistentIrfHashtable
Persistent version of IrfHashtable. This hashtable has been designed to remain only partly in memory, separating the hash space in slices that can be or not be in memory at one point. The coming to/back from disk of those slices is managed via a LFU-like algorithm thanks to slots receiving blocks.
DualKeyContainer
,
Hashtable
, Serialized FormField Summary | |
private int |
accesses
Statistics on the Hashtable efficiency. |
private int |
blockInitialCapacity
Blocks will be created with this parameter. |
private float |
blockLoadFactor
Blocks will be created with this parameter. |
private int[] |
blockMap
For each block number, gives the slot number where this block is, or -1 if the block isn't in memory. |
private HashBlock[] |
blocks
This array is composed of slots. |
private int |
blockSize
Size of each block computed knowing the number of blocks and the maximum number of hashcodes susceptible of being coded (Integer.MAX_VALUE). |
private int[] |
blocksUsed
For each slot, gives the number of times it has been used since it was filled with a block. |
private int |
count
Total number of elements stored in the blocks. |
private java.lang.String |
filePath
The blocks will be stored on disk in files in the directory fully specified by filePath |
private java.lang.String |
filePrefix
The blocks will be stored on disk in files named filePrefixOO where OO is a number from 0 to (numberOfBlocks - 1). |
private int |
hits
|
private int[] |
inversedBlockMap
for each slot number, gives the number of the block this slot contains, -1 if none. |
(package private) int |
numberOfBlocks
Total number of blocks composing the hashtable. |
private int |
numberOfSlots
Size of the previous array. |
(package private) static long |
serialVersionUID
serial version universal id - put here so Java does not insert one which may change due to revisions and make it impossible to deserialize earlier versions of serialized objects |
Constructor Summary | |
PersistentIrfHashtable(java.lang.String filePath,
java.lang.String filePrefix,
int numberOfSlots,
int numberOfBlocks,
int blockInitialCapacity,
float blockLoadFactor)
Builds a PersistentIrfHashtable with the given charateristics: |
Method Summary | |
java.util.Enumeration |
elements()
Exact same result as values(). |
java.lang.Object |
get(java.lang.Object key)
The comment for put is also valid here. |
java.lang.Object |
getActualKey(java.lang.Object key)
With special hashCode() and equals() methods, you may want to know at one point what is the key you are really working with if you call get(thisKey) or put(thisKey, something) . |
(package private) HashBlock |
getBlock(int blockNr)
This method is only used by the PersistentIrfHashtable itself and by its enumerator. |
java.util.Enumeration |
keys()
Returns the keys available in the hashtable for the get method. |
int |
length()
Exact same result as size(). |
private int |
load(int blockNr)
This method finds out where to load a block with a LFU-like algorithm, loads the block and returns the slot number where it just loaded the block. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
This put is the equivalent of the one in Hashtable. |
private HashBlock |
readBlock(int blockNr)
This method is the symetric of writeBlock(), as it reads a HashBlock back from disk. |
private void |
readObject(java.io.ObjectInputStream in)
The serializable interface method for matrialization. |
void |
showStatistics()
Displays statistics about the table and its usage with the given format: PersistentIrfHashtable tableName: x hits for y accesses, ie z% hits. |
int |
size()
Number of values stored in the persistent hashtable. |
java.util.Enumeration |
values()
Returns the values stored in the hashtable, exactly like the elements() method. |
private void |
writeBlock(HashBlock toWrite,
int blockNr)
As the name tells, this method writes a block to disk, using a tuned serialization scheme with a BufferedRandomAccessFile. |
private void |
writeObject(java.io.ObjectOutputStream out)
The serializable interface method for storage. |
Methods inherited from class java.lang.Object |
|
Field Detail |
static final long serialVersionUID
private transient HashBlock[] blocks
private int numberOfSlots
int numberOfBlocks
private int blockSize
private transient int[] blockMap
private transient int[] inversedBlockMap
private transient int[] blocksUsed
private java.lang.String filePath
private java.lang.String filePrefix
private int count
private int blockInitialCapacity
private float blockLoadFactor
private transient int accesses
private transient int hits
Constructor Detail |
public PersistentIrfHashtable(java.lang.String filePath, java.lang.String filePrefix, int numberOfSlots, int numberOfBlocks, int blockInitialCapacity, float blockLoadFactor)
filePath
- the path from root to the file(s)filePrefix
- the prefix that will be used for the names of the
files where the differentblocks of the hashtable will be stored.numberOfSlots
- the more slots there is, the less swapping should
occur but the more memory used.numberOfBlocks
- number of chunks for the hashtable. The more
numerous they will be, the smaller and the faster to load, but
again it may mean several swapping phases.blockInitialCapacity
- - as in @ref java.util.HashtableblockLoadFactor
- - as in @ref java.util.HashtableMethod Detail |
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
Hashtable.put(java.lang.Object, java.lang.Object)
,
ProxyFeatureList
public java.lang.Object get(java.lang.Object key)
Hashtable.get(java.lang.Object)
HashBlock getBlock(int blockNr)
private int load(int blockNr)
private void writeBlock(HashBlock toWrite, int blockNr)
toWrite
- the block that is to be written.blockNr
- the actual BLOCK number, NOT the SLOT number. Be careful.private HashBlock readBlock(int blockNr)
blockNr
- the number of the block to be loaded.null
unless an IOException has occured.public final java.util.Enumeration keys()
Hashtable.keys()
public final java.util.Enumeration values()
Hashtable.elements()
public final int size()
public final int length()
public java.lang.Object getActualKey(java.lang.Object key)
get(thisKey)
or put(thisKey, something)
.
This method returns the actual object that will be used as a key if
you give thisKey as a parameter to one of the two methods.public final java.util.Enumeration elements()
values()
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
public void showStatistics()
PersistentIrfHashtable tableName: x hits for y accesses, ie z% hits.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |