I've been looking at the problem of writing a concurrent Multimap, and I have an implementation backed by the Google Guava AbstractSetMultimap and a MapMaker computing map that creates on demand the values-collections as a set view over a ConcurrentHashMap. With some care over the view collections and various wrappers, I think this gets pretty close.
The big problem, which has already been discussed by others who have tried this, appears to be that of removing the values-collections from the underlying map when they become empty, without introducing race conditions.
A couple of options appear to exist.
Questions:
Thanks
Edit: see also the discussion here on the guava mailing list.
Edit 2: I've since written this up. Please see this Google code area for an implementation. I would greatly appreciate any feedback from anyone who tries it, there rather than here.
I asked the same question earlier, and ended up implementing 4 different implementations.
The question: High-performance Concurrent MultiMap Java/Scala
The impl (I call it Index) http://github.com/jboner/akka/blob/master/akka-actor/src/main/scala/actor/ActorRegistry.scala#L314
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With