Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregation in Java combines different partition keys to one request #128

Open
mustafaakin-atl opened this issue Jan 11, 2021 · 1 comment

Comments

@mustafaakin-atl
Copy link

mustafaakin-atl commented Jan 11, 2021

To test my understanding of the library, I created the following code:

    RecordAggregator aggregator = new RecordAggregator();

    byte[] data1 = "wow".getBytes();
    byte[] data2 = "oh-yeah".getBytes();

    AggRecord rec1 = aggregator.addUserRecord("key-1", data1);
    AggRecord rec2 = aggregator.addUserRecord("key-2", data2);

    AggRecord g1 = aggregator.clearAndGet();
    AggRecord g2 = aggregator.clearAndGet();

So I assumed it would create different aggregations for different partition keys. However, it does not work like that.

    System.out.println(g1.getPartitionKey());   <-- key-1
    System.out.println(g1.getNumUserRecords());   <--key- 2

    System.out.println(g2);  <-- null

    System.out.println(g1.toPutRecordsRequestEntry().getPartitionKey());  <-- key-1

I get the with random partition keys, we would use the benefits because nothing can be aggregated. However, with the above code, the entry with key-2 partition would land in key-1 which might be undesirable for applications that want to work on a single partition.

@IanMeyers
Copy link
Contributor

Yes, this is the expected behaviour, which you can modify with the addition of the ExplicitHashKey value. In general, to achieve higher compression rates common partitions keys will be grouped by KPL unless EHK is supplied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants