Skip to content

Commit

Permalink
Fix aggregatorFactory meta merge exception (apache#7504)
Browse files Browse the repository at this point in the history
  • Loading branch information
es1220 authored and clintropolis committed Apr 24, 2019
1 parent bcc43b1 commit bc13650
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.yahoo.sketches.hll.TgtHllType;
import com.yahoo.sketches.hll.Union;
import org.apache.druid.query.aggregation.Aggregator;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.AggregatorFactoryNotMergeableException;
import org.apache.druid.query.aggregation.AggregatorUtil;
import org.apache.druid.query.aggregation.BufferAggregator;
import org.apache.druid.segment.ColumnSelectorFactory;
Expand All @@ -51,6 +53,23 @@ public HllSketchMergeAggregatorFactory(
super(name, fieldName, lgK, tgtHllType);
}

@Override
public AggregatorFactory getMergingFactory(AggregatorFactory other) throws AggregatorFactoryNotMergeableException
{
if (other.getName().equals(this.getName()) && other instanceof HllSketchMergeAggregatorFactory) {
HllSketchMergeAggregatorFactory castedOther = (HllSketchMergeAggregatorFactory) other;

return new HllSketchMergeAggregatorFactory(
getName(),
getName(),
Math.max(getLgK(), castedOther.getLgK()),
getTgtHllType().compareTo(castedOther.getTgtHllType()) < 0 ? castedOther.getTgtHllType() : getTgtHllType()
);
} else {
throw new AggregatorFactoryNotMergeableException(this, other);
}
}

@Override
public String getTypeName()
{
Expand Down

0 comments on commit bc13650

Please sign in to comment.