Package com.facebook.presto.spi.type

Examples of com.facebook.presto.spi.type.TypeSignature


    private static Object fixValue(String type, Object value)
    {
        if (value == null) {
            return null;
        }
        TypeSignature signature = parseTypeSignature(type);
        if (signature.getBase().equals("array")) {
            List<Object> fixedValue = new ArrayList<>();
            for (Object object : List.class.cast(value)) {
                fixedValue.add(fixValue(signature.getParameters().get(0).toString(), object));
            }
            return fixedValue;
        }
        if (signature.getBase().equals("map")) {
            String keyType = signature.getParameters().get(0).toString();
            String valueType = signature.getParameters().get(1).toString();
            Map<Object, Object> fixedValue = new HashMap<>();
            for (Map.Entry<?, ?> entry : (Set<Map.Entry<?, ?>>) Map.class.cast(value).entrySet()) {
                fixedValue.put(fixValue(keyType, entry.getKey()), fixValue(valueType, entry.getValue()));
            }
            return fixedValue;
View Full Code Here


            }
        }

        for (int i = 0; i < types.size(); i++) {
            // Get the current argument signature, or the last one, if this is a varargs function
            TypeSignature typeSignature = argumentTypes.get(Math.min(i, argumentTypes.size() - 1));
            Type type = types.get(i);
            if (!matchAndBind(boundParameters, unboundParameters, typeSignature, type, allowCoercion, typeManager)) {
                return false;
            }
        }
View Full Code Here

            if (type.getTypeParameters().size() != signature.getParameters().size()) {
                return false;
            }
            for (int i = 0; i < signature.getParameters().size(); i++) {
                Type componentType = type.getTypeParameters().get(i);
                TypeSignature componentSignature = signature.getParameters().get(i);
                if (!matchAndBind(boundParameters, unboundParameters, componentSignature, componentType, allowCoercion, typeManager)) {
                    return false;
                }
            }
        }
View Full Code Here

    private synchronized void instantiateParametricType(String typeName)
    {
        if (types.containsKey(typeName)) {
            return;
        }
        TypeSignature signature = TypeSignature.parseTypeSignature(typeName);
        ImmutableList.Builder<Type> parameterTypes = ImmutableList.builder();
        for (TypeSignature parameter : signature.getParameters()) {
            parameterTypes.add(getType(parameter.toString()));
        }

        ParametricType parametricType = parametricTypes.get(signature.getBase());
        if (parametricType == null) {
            return;
        }
        Type instantiatedType = parametricType.createType(parameterTypes.build());
        checkState(instantiatedType.getName().equalsIgnoreCase(typeName), "Instantiated parametric type name (%s) does not match expected name (%s)", instantiatedType.getName(), typeName);
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.type.TypeSignature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.