Remove the temporary code for backward-compatibility in DistinctCountAggregationFunction
@@ -290,47 +290,8 @@ public class DistinctCountAggregationFunction extends BaseSingleInputAggregation
if (intermediateResult2.isEmpty()) {
return intermediateResult1;
}
- if (intermediateResult1.getClass() == intermediateResult2.getClass()) {
- // Both results are of the same type, directly merge
intermediateResult1.addAll(intermediateResult2);
return intermediateResult1;
- } else {
- // TODO: Remove this part after releasing 0.5.0
- // The results are not of the same type. This can happen when servers are getting upgraded, and some servers are
- // still running the old code and store hash codes in the set. For backward-compatibility, we convert the values
- // into hash codes and insert them into the hash code set.
- IntOpenHashSet hashCodeSet;
- Set valueSet;
- if (intermediateResult1 instanceof IntOpenHashSet) {
- hashCodeSet = (IntOpenHashSet) intermediateResult1;
- valueSet = intermediateResult2;
- } else {
- hashCodeSet = (IntOpenHashSet) intermediateResult2;
- valueSet = intermediateResult1;
- }
- if (valueSet instanceof LongOpenHashSet) {
- LongOpenHashSet longSet = (LongOpenHashSet) valueSet;
- for (long value : longSet) {
- hashCodeSet.add(Long.hashCode(value));
- }
- } else if (valueSet instanceof FloatOpenHashSet) {
- FloatOpenHashSet floatSet = (FloatOpenHashSet) valueSet;
- for (float value : floatSet) {
- hashCodeSet.add(Float.hashCode(value));
- }
- } else if (valueSet instanceof DoubleOpenHashSet) {
- DoubleOpenHashSet doubleSet = (DoubleOpenHashSet) valueSet;
- for (double value : doubleSet) {
- hashCodeSet.add(Double.hashCode(value));
- }
- } else {
- // STRING and BYTES
- for (Object value : valueSet) {
- hashCodeSet.add(value.hashCode());
- }
- }
- return hashCodeSet;
- }
}
@Override
