hazelcasthazelcast-imap

Is PartitionAware supported on Hazelcast's IMap values?


Like described in a title I want my IMap values to implement PartitionAware<T> interface. Does Hazelcast support that or are the IMap keys the only one that should implement it?

For instance I have IMap<Long, MyValueClass> where MyValueClass implements PartitionAware<SomeCustomObject>. Will Hazelcast respect PartitionAware on values and put all entries with same SomeCustomObject on same partition (assume that SomeCustomObject has equals and hashCode methods impemented)?


Solution

  • The partition to store the entry is based on the key.

    For example, IMap.get(K) only has access to the key, the value is unknown before the retrieval call. If the key didn't dictate the partition, all partitions would have to be scanned to find the entry.

    A key can be a compound, eg. IMap<Tuple2<Long, Long>, SomeCustomObject>. Here the key is a pair of numbers, partition placement could be based on either or both.