IdGenerator
makes use of so called "defragged" ids. A defragged id is an id that has been in use one or many times but the resource that was using it doesn't exist anymore. This makes it possible to reuse the id and that in turn makes it possible to write a resource store with fixed records and size (you can calculate the position of a record by knowing the id without using indexes or a translation table).
The id returned from {@link #nextId} may not be the lowestavailable id but will be one of the defragged ids if such exist or the next new free id that has never been used.
The {@link #freeId} will not check if the id passed in to it really is free.Passing a non free id will corrupt the id generator and {@link #nextId}method will eventually return that id.
The {@link #close()} method must always be invoked when done using angenerator (for this time). Failure to do will render the generator as "sticky" and unusable next time you try to initialize a generator using the same file. There can only be one id generator instance per id generator file.
In case of disk/file I/O failure an IOException
is thrown.
|
|