|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lempinen.util.RandomAccessArray
Class for storing and retrieving objects from a random access file.
This class serves the purpose of providing a persistent storage of Serializable objects. It provides fast access to the objects using a Long identifier, which is in fact the byte offset of the object from the beginning of the file. This makes the identifiers unique. The name Array is really a bit of a misnomer, as the index numbers do not run sequentially. Futhermore, once an Object has been added, it cannot be safely replaced or deleted, as the individual objects can be of any type and therefore of a varying size.
This class was developed in order to speed up reading a NeatSeeker TargetIndex. Indexes of > 10000 HTML documents had a noticeable (over 10s) bottleneck when deserializing the old TreeMap format TargetIndex.
Field Summary | |
protected java.io.RandomAccessFile |
rafile
The file to use for serializing the objects. |
Constructor Summary | |
RandomAccessArray(java.lang.String file)
Creates a new RandomAccessArray object in read-write mode. |
|
RandomAccessArray(java.lang.String file,
boolean readonly)
Creates a new RandomAccessArray object (read or read-write). |
Method Summary | |
java.io.Serializable |
get(long id)
Returns the object indicated by the ID. |
long |
getNextID()
Returns the ID of the next put() operation. |
long |
put(java.io.Serializable s)
Adds an object into the index and returns a unique ID. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected java.io.RandomAccessFile rafile
Constructor Detail |
public RandomAccessArray(java.lang.String file) throws java.io.IOException
public RandomAccessArray(java.lang.String file, boolean readonly) throws java.io.IOException
Method Detail |
public long getNextID() throws java.io.IOException
public long put(java.io.Serializable s) throws java.io.IOException
public java.io.Serializable get(long id) throws java.io.IOException, java.lang.ClassNotFoundException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |