You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Matthias J. Sax (JIRA)" <ji...@apache.org> on 2017/07/26 19:00:08 UTC

[jira] [Commented] (KAFKA-5648) make Merger extend Aggregator

    [ https://issues.apache.org/jira/browse/KAFKA-5648?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16102119#comment-16102119 ] 

Matthias J. Sax commented on KAFKA-5648:
----------------------------------------

Your observation is correct, that {{Merger}} and {{Aggregator}} are similar. You also stated correctly, that the types are different though, as the {{Merger}} merges two aggregates of same type, while the Aggregator in general merged a single value (of type-A) merges the value into an aggregate (of type-B). Thus, {{Merger<K,V> extends Aggregator<K,V,V}} is a hierarchy one could do. But the question is, what do you really gain? Also, if you want to share business logic, you can simply define one class that implements both interfaces at the same time, and do an private method that does the actual merging and call it from {{apply}}. ATM, I don't see the value and this would be an breaking change so we should really gain something out if it.

> make Merger extend Aggregator
> -----------------------------
>
>                 Key: KAFKA-5648
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5648
>             Project: Kafka
>          Issue Type: New Feature
>          Components: streams
>    Affects Versions: 0.11.0.0
>            Reporter: Clemens Valiente
>            Assignee: Clemens Valiente
>            Priority: Minor
>
> Hi,
> I suggest that Merger<K,V> should extend Aggregator<K,V,V>.
> reason:
> Both classes usually do very similar things. A merger takes two sessions and combines them, an aggregator takes an existing session and aggregates new values into it.
> in some use cases it is actually the same thing, e.g.:
> <null, log_event> -> .map() to <session_id,SingletonList<log_event>> -> .groupByKey().aggregate() to <session_id, List<log_event>>
> In this case both merger and aggregator do the same thing: take two lists and combine them into one.
> With the proposed change we could pass the Merger as both the merger and aggregator to the .aggregate() method and keep our business logic within one merger class.
> Or in other words: The Merger is simply an Aggregator that happens to aggregate two objects of the same class



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)