I have written a simple code to find out the partition id for a data key.
Please check following code.

When I run the code keeping assetGroupId constant for different ids, I get
the same partition Id.
As you can see the for loop runs for 1000 million times changing 'id' in
every step and I get the partition id as 590 every time.

It means that if there are 1000 million records for assetGroupId "123456789",
all the record will land up in same partition.

Does data colocation completely depends on a property which is annotated
with "@AffinityKeyMapped" annotation?

Does the other property "id" in this (which is a primary key) does not make
in difference?

Is property "id" used only for locating a bucket in a given partition?

Can someone please explain the internals of data colocation? How it happens?

I want to populate partition ids in my oracle table to speed up data
loading process. In this particular case column "id" is a surrogate key
(oracle auto increment). It is introduced only to put data in ignite cache
using some unique identifier. Main column to identify data is assetGroupId
and one assetGroupId can have 0 to N records (approx. 1 million).  There
could be millions of such assetGroupIds. In current scenario I have total
380 million records with approx. 100K unique assetgroupIds.
So I am thinking to find out the partition Ids only for all the distinct
assetGrooupIds and do batch update for the same in oracle table.

Is this a correct way to find out partition Ids?

public static void main(String[] args) {

  Set<Integer> partitions = new HashSet<>();

  try (Ignite ignite =
    Affinity<Object> affinity =

    System.out.println("Ignite configured...");
    for (long ctr = 1; ctr < 1000000000; ctr++) {

      IPRangeDataKey key = new IPRangeDataKey(ctr,123456789);
      int partitionId = affinity.partition(key);


public class IPRangeDataKey implements Serializable {

    //Primary key IPV4RangeData
    private long id;

    private long assetGroupId;

    public IPRangeDataKey(long id, long assetGroupId) {
        this.id = id;
        this.assetGroupId = assetGroupId;



Reply via email to