apache / apache/druid

Free AggregatorFactory implementors from boilerplate in getMergingFactory()

Open
#6,858 4 comments 0 reactions 0 assignees View on GitHub
Refactoring stale
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

Currently AggregatorFactory implementors should write code like the following themselves:
```java
if (other.getName().equals(this.getName()) && other.getClass() == getClass()) {
...
} else {
throw new AggregatorFactoryNotMergeableException(...);
}
```
or
```java
if (other.getName().equals(this.getName()) && other instanceof MyBaseAggregatorFactory) {
...
} else {
throw new AggregatorFactoryNotMergeableException(...);
}
```

if `MyBaseAggregatorFactory` is extended by other aggregator factory classes.

It could be replaced by e. g. by adding a generic parameter `BaseMergeAggregatorFactory` to `AggregatorFactory` class; adding a method `Class getBaseMergeAggregatorFactory()` method; and changing the signature of `getMergeFactory()` to accept `BaseMergeAggregatorFactory` as the parameter.

Contributor guide

Open the contributing guide

Research direction

Start by locating AggregatorFactory, getMergingFactory(), and existing AggregatorFactory implementors that repeat the name and type checks. Review how AggregatorFactoryNotMergeableException is used; done means the shared merge contract removes that boilerplate while preserving the existing mergeability behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.