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.GREATER_THAN;
import static com.facebook.presto.metadata.OperatorType.GREATER_THAN_OR_EQUAL;
import static com.facebook.presto.metadata.Signature.orderableTypeParameter;
import static com.facebook.presto.spi.StandardErrorCode.INTERNAL_ERROR;
import static com.facebook.presto.spi.type.TypeSignature.parseTypeSignature;
import static com.facebook.presto.type.ArrayType.ARRAY_NULL_ELEMENT_MSG;
import static com.facebook.presto.type.TypeUtils.castValue;
import static com.facebook.presto.type.TypeUtils.checkElementNotNull;
import static com.facebook.presto.type.TypeUtils.readStructuralBlock;
import static com.facebook.presto.util.Reflection.methodHandle;
        extends ParametricOperator
    private static final TypeSignature RETURN_TYPE = parseTypeSignature(.);
    private static final MethodHandle METHOD_HANDLE = methodHandle(ArrayGreaterThanOrEqualOperator.class"greaterThanOrEqual"MethodHandle.classType.classSlice.classSlice.class);
    {
        super(, ImmutableList.of(orderableTypeParameter("T")), ., ImmutableList.of("array<T>""array<T>"));
    }
    @Override
    public FunctionInfo specialize(Map<StringTypetypesint arityTypeManager typeManagerFunctionRegistry functionRegistry)
    {
        Type elementType = types.get("T");
        Type type = typeManager.getParameterizedType(., ImmutableList.of(elementType.getTypeSignature()), ImmutableList.of());
        TypeSignature typeSignature = type.getTypeSignature();
        MethodHandle greaterThanFunction = functionRegistry.resolveOperator(, ImmutableList.of(elementTypeelementType)).getMethodHandle();
        MethodHandle method = .bindTo(greaterThanFunction).bindTo(elementType);
        return operatorInfo(, ImmutableList.of(typeSignaturetypeSignature), methodfalse, ImmutableList.of(falsefalse));
    }
    public static boolean greaterThanOrEqual(MethodHandle greaterThanFunctionType typeSlice leftSlice right)
    {
        Block leftArray = readStructuralBlock(left);
        Block rightArray = readStructuralBlock(right);
        int len = Math.min(leftArray.getPositionCount(), rightArray.getPositionCount());
        int index = 0;
        while (index < len) {
            checkElementNotNull(leftArray.isNull(index), );
            checkElementNotNull(rightArray.isNull(index), );
            Object leftElement = castValue(typeleftArrayindex);
            Object rightElement = castValue(typerightArrayindex);
            try {
                if ((booleangreaterThanFunction.invoke(leftElementrightElement)) {
                    return true;
                }
                if ((booleangreaterThanFunction.invoke(rightElementleftElement)) {
                    return false;
                }
            }
            catch (Throwable t) {
                Throwables.propagateIfInstanceOf(tError.class);
                Throwables.propagateIfInstanceOf(tPrestoException.class);
                throw new PrestoException(t);
            }
            index++;
        }
        return leftArray.getPositionCount() >= rightArray.getPositionCount();
    }
New to GrepCode? Check out our FAQ X