Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.facebook.presto.operator.scalar;
 /*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import static com.facebook.presto.metadata.FunctionRegistry.operatorInfo;
import static com.facebook.presto.metadata.OperatorType.EQUAL;
import static com.facebook.presto.metadata.OperatorType.HASH_CODE;
import static com.facebook.presto.metadata.OperatorType.NOT_EQUAL;
import static com.facebook.presto.metadata.Signature.comparableTypeParameter;
import static com.facebook.presto.spi.type.TypeSignature.parseTypeSignature;
import static com.facebook.presto.util.Reflection.methodHandle;
public class MapNotEqualOperator
        extends ParametricOperator
    public static final MapNotEqualOperator MAP_NOT_EQUAL = new MapNotEqualOperator();
    private static final TypeSignature RETURN_TYPE = parseTypeSignature(.);
    private MapNotEqualOperator()
    {
        super(, ImmutableList.of(comparableTypeParameter("K"), comparableTypeParameter("V")), ., ImmutableList.of("map<K,V>""map<K,V>"));
    }
    @Override
    public FunctionInfo specialize(Map<StringTypetypesint arityTypeManager typeManagerFunctionRegistry functionRegistry)
    {
        Type keyType = types.get("K");
        Type valueType = types.get("V");
        Type type = typeManager.getParameterizedType(., ImmutableList.of(keyType.getTypeSignature(), valueType.getTypeSignature()), ImmutableList.of());
        TypeSignature typeSignature = type.getTypeSignature();
        MethodHandle keyEqualsFunction = functionRegistry.resolveOperator(, ImmutableList.of(keyTypekeyType)).getMethodHandle();
        MethodHandle keyHashcodeFunction = functionRegistry.resolveOperator(, ImmutableList.of(keyType)).getMethodHandle();
        MethodHandle valueEqualsFunction = functionRegistry.resolveOperator(, ImmutableList.of(valueTypevalueType)).getMethodHandle();
        MethodHandle methodHandle = methodHandle(MapNotEqualOperator.class"notEqual"MethodHandle.classMethodHandle.classMethodHandle.classType.classType.classSlice.classSlice.class);
        MethodHandle method = methodHandle.bindTo(keyEqualsFunction).bindTo(keyHashcodeFunction).bindTo(valueEqualsFunction).bindTo(keyType).bindTo(valueType);
        return operatorInfo(, ImmutableList.of(typeSignaturetypeSignature), methodtrue, ImmutableList.of(falsefalse));
    }
    public static Boolean notEqual(MethodHandle keyEqualsFunctionMethodHandle keyHashcodeFunctionMethodHandle valueEqualsFunctionType keyTypeType valueTypeSlice leftSlice right)
    {
        Boolean equals = MapEqualOperator.equals(keyEqualsFunctionkeyHashcodeFunctionvalueEqualsFunctionkeyTypevalueTypeleftright);
        if (equals == null) {
            return null;
        }
        return !equals;
    }
New to GrepCode? Check out our FAQ X