We need to add IgniteMultimap data structure in addition to other data structures provided by Ignite. IgniteMultiMap should have similar API to java.util.Map class in JDK, but support the semantics of multiple values per key, similar to Guava Multimap.
However, unlike in Guava, our multi-map should work with Lists, not Collections. Lists should make it possible to support the following methods:
The most natural way to implement such map, would be to store every value under a separate key in an Ignite cache. For example, let's say that we have a key K with multiple values: V0, V1, V2, .... Then the cache should end up with the following values K0, V0, K1, V1, K2, V2, etc. This means that we need to wrap user key into our own, internal key, which will also have index field.
Also note that we need to collocate all the values for the same key on the same node, which means that we need to define user key K as the affinity key, like so:
Look ups of values at specific indexes becomes very simple. Just attach a specific index to a key and do a cache lookup. Look ups for all values for a key should work as following:
We could also use batching for performance reason. In this case the batch size should be configurable.
Evictions in the IgniteMultiMap should have 2 levels: maximum number of keys, and maximum number of values for a key. The maximum number of keys should be controlled by Ignite standard eviction policy. The maximum number of values for a key should be controlled by the implementation of the multi-map. Either eviction parameter should be configurable.