Fix aggregatorFactory meta merge exception (#7504)

This commit is contained in:
es1220 2019-04-25 06:08:46 +09:00 committed by Jonathan Wei
parent 11a7e91a73
commit 3e25b75c3f
1 changed files with 19 additions and 0 deletions

View File

@ -25,6 +25,8 @@ import com.yahoo.sketches.hll.HllSketch;
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;
@ -51,6 +53,23 @@ public class HllSketchMergeAggregatorFactory extends HllSketchAggregatorFactory
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()
{