A
Arne Vajhøj
Roedy said:I rolled my own something similar. It is not that much code to handle
the random quotations you see on my website.
What you could do in write a class that uses a HashMap internally just
to hold the keys and objects that are offsets in a sequential file.
When you build the Map, you write the objects out with writeUTF or
writeObject, and record the size/offset of the stream before the
write.
Then to lookup in the Map, you look up the key, get the offset, seek
and do a read. You don't even need to know the length.
This is pretty fast, especially when the drive/OS does read caching.
If you wanted to make it even faster, you could put the objects in a
NIO memory mapped file, but that limits your file size. You also
might put the file on fast flash drive.
I would write such a beast to your specs for $50 US.
I think Stefan is capable of writing his own code.
Arne