Search code examples
javahazelcastdistributed-cachingdistributed-cachehazelcast-imap

Multiple maps in a single partition in hazelcast map


I have two hazelcast maps defined as follows.

IMap<EmpKey, Employee> employeeMap = hazelcastInstance.getMap("employeeMap");
IMap<EmpKey, EmployeeFamily> familyMap = hazelcastInstance.getMap("familyMap");

I understand that key gets serialized (gets converted into a byte[] array) which is then hashed and the result of which is 'mod' by no of partitions. This gives us the id of the partition where data will be stored. Also, from the partition table in each member, it identifies the owner of the partition. This follows that both employeeObj and family object withe the same empKey will be stored in the same partition.

I would like to know what happens after this step. I understand that keys are stored as com.hazelcast.nio.serialization.Data class (binary form). Will there be​ ​ separate hash buckets maintained for each hashmap whose key is present in a given partition, for faster access ?

I understand that partition count is configurable, but I would like to know some internals before I modify any configuration.


Solution

  • This follows that both employeeObj and family object withe the same empKey will be stored in the same partition.

    Correct.

    I would like to know what happens after this step. I understand that keys are stored as com.hazelcast.nio.serialization.Data class (binary form). Will there be​ ​ separate hash buckets maintained for each hashmap whose key is present in a given partition, for faster access ?

    Each IMap gets its totally private internal storage (it will gets its own ConcurrentHashMap instance as backing structure). So you will have separate hashbucket.