Avoid constructing default values in Map IS DISTINCT FROM
@@ -29,7 +29,6 @@ import static com.facebook.presto.spi.function.OperatorType.EQUAL;
import static com.facebook.presto.spi.function.OperatorType.HASH_CODE;
import static com.facebook.presto.spi.function.OperatorType.IS_DISTINCT_FROM;
import static com.facebook.presto.spi.type.TypeUtils.readNativeValue;
-import static com.google.common.base.Defaults.defaultValue;
@ScalarOperator(IS_DISTINCT_FROM)
public final class MapDistinctFromOperator
@@ -66,14 +65,11 @@ public final class MapDistinctFromOperator
rightMapBlock,
(leftMapIndex, rightMapIndex) -> {
Object leftValue = readNativeValue(valueType, leftMapBlock, leftMapIndex);
- boolean leftNull = leftValue == null;
- if (leftNull) {
- leftValue = defaultValue(valueType.getJavaType());
- }
Object rightValue = readNativeValue(valueType, rightMapBlock, rightMapIndex);
+ boolean leftNull = leftValue == null;
boolean rightNull = rightValue == null;
- if (rightNull) {
- rightValue = defaultValue(valueType.getJavaType());
+ if (leftNull || rightNull) {
+ return leftNull == rightNull;
}
return !(boolean) valueDistinctFromFunction.invoke(leftValue, leftNull, rightValue, rightNull);
});
