user3458271
user3458271

Reputation: 660

Hazelcast multiple left joins not working for two it is working fine

I am new to Hazelcast Jet and I m tryin to join 4 datas but join is not working as accepted I am not sure what wrong I am doing as for two tables it is working fine. Please help My Code:

BatchStageWithKey<Object, Object> jdbcGroupByKey = batch1.groupingKey(jdbcData ->  {
                 // logic for creating key   
             });

    BatchStageWithKey<Object, Object> jdbcGroupByKey2 = batch2.groupingKey(jdbcData ->  {
                 // logic for creating key   
             });

BatchStageWithKey<Object, Object> jdbcGroupByKey3 = batch3.groupingKey(jdbcData ->  {
                 // logic for creating key   
             });

Now joining both with left join

BatchStage<Entry<Object, Tuple2<Object, List<Object>>>> d = jdbcGroupByKey.aggregate2(AggregateOperations.pickAny(),jdbcGroupByKey1,AggregateOperations.toList());

This works fine but when I try it with multiple it's not working: Here I convert "d" to BatchStage<Object>

BatchStage<Entry<Object, Tuple2<Object, List<Object>>>> d2 = d1.aggregate2(AggregateOperations.pickAny(),jdbcGroupByKey1,AggregateOperations.toList());

This just example there can be 5 tables also so cannot use Tuple3 , so what can I do please help.

Upvotes: 0

Views: 118

Answers (1)

Oliv
Oliv

Reputation: 10812

You should use aggregate3(), or aggregateBuilder() if you have more than 3 inputs to aggregate. What you do in your example is you're aggregating the output of aggregation. You can do that too, but it's less efficient. It would look like this:

BatchStage<Entry<Object, Tuple2<Object, List<Object>>>> d1 = 
    jdbcGroupByKey.aggregate2(pickAny(),jdbcGroupByKey1,toList());
BatchStage<Entry<Object, Tuple2<Tuple2<Object, List<Object>>, List<Object>>>> d2 = 
    d1.groupingKey(Entry::getKey)
      .aggregate2(pickAny(),jdbcGroupByKey1,toList());

(Code not compiled, there can be a mistake, but hope you get the idea.)

Upvotes: 0

Related Questions