BaseXdb/basex — pull request #414 by dimitarp (2012-03-03 14:03:14+00:00)
Title: [ADD] Index cache: new implementation based on java.util.WeakHashMap using soft references

I've re-written the IndexCache class by using some of the ideas in java.util.WeakHashMap. The result is a hash-map which has a soft reference to both key and value.
The TokenObjMap could not be used, since it does not offer a convenient way of shrinking the bucket lists. The implementation in java.util.WeakHashMap uses linked lists, which I'm also using.
The cache interface is also cleaned up - there are no more hash map ids, which makes the code cleaner.
Open issues:
1. Please, REVIEW THE CODE BEFORE MERGING! There are simple unit tests and a "performance" unit test which shows that the cache can continuously store new records (it is, however, annotated with @Ignored, since it is not supposed to finish). However, there might be bugs ;)
2. Currently, the bucket array is not shrunk (the same is in java.util.WeakHashMap). A minimal threshold should be introduced, if we want to support that.
3. The default constants are chosen similar to the one in java.util.WeakHashMap. However, a proper constructor could be added.