Package com.facebook.presto.spi.type

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


            if (name.isEmpty()) {
                name = camelToSnake(method.getName());
            }
            SqlType returnTypeAnnotation = method.getAnnotation(SqlType.class);
            checkArgument(returnTypeAnnotation != null, "Method %s return type does not have a @SqlType annotation", method);
            Type returnType = type(returnTypeAnnotation);
            Signature signature = new Signature(name.toLowerCase(), returnType, parameterTypes(method), false, false);

            verifyMethodSignature(method, signature.getReturnType(), signature.getArgumentTypes());

            FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction.functionBinder());
View Full Code Here


            MethodHandle methodHandle = lookup().unreflect(method);
            OperatorType operatorType = scalarOperator.value();

            List<Type> parameterTypes = parameterTypes(method);

            Type returnType;
            if (operatorType == OperatorType.HASH_CODE) {
                // todo hack for hashCode... should be int
                returnType = BIGINT;
            }
            else {
View Full Code Here

                    columns.add(tableScanNode.getAssignments().get(symbol));

                    Integer input = channel;
                    sourceLayout.put(symbol, input);

                    Type type = checkNotNull(context.getTypes().get(symbol), "No type for symbol %s", symbol);
                    sourceTypes.put(input, type);

                    channel++;
                }
            }
View Full Code Here

        private Map<Integer, Type> getInputTypes(Map<Symbol, Integer> layout, List<Type> types)
        {
            Builder<Integer, Type> inputTypes = ImmutableMap.builder();
            for (Integer input : ImmutableSet.copyOf(layout.values())) {
                Type type = types.get(input);
                inputTypes.put(input, type);
            }
            return inputTypes.build();
        }
View Full Code Here

            int channel = 0;
            for (Symbol symbol : node.getOutputSymbols()) {
                Integer input = channel;
                outputMappings.put(symbol, input);

                Type type = checkNotNull(context.getTypes().get(symbol), "No type for symbol %s", symbol);
                outputTypes.add(type);

                channel++;
            }
View Full Code Here

            {
                MetadataDao dao = dbiHandle.attach(MetadataDao.class);
                long tableId = dao.insertTable(connectorId, table.getSchemaName(), table.getTableName());
                for (int i = 0; i < table.getColumnTypes().size(); i++) {
                    RaptorColumnHandle column = table.getColumnHandles().get(i);
                    Type columnType = table.getColumnTypes().get(i);
                    dao.insertColumn(tableId, i + 1, column.getColumnName(), i, columnType.getName());
                }
            }
        });

        ImmutableMap.Builder<UUID, String> shards = ImmutableMap.builder();
View Full Code Here

                    BlockBuilder output = pageBuilder.getBlockBuilder(column);
                    if (cursor.isNull(column)) {
                        output.appendNull();
                    }
                    else {
                        Type type = getTypes().get(column);
                        Class<?> javaType = type.getJavaType();
                        if (javaType == boolean.class) {
                            output.appendBoolean(cursor.getBoolean(column));
                        }
                        else if (javaType == long.class) {
                            output.appendLong(cursor.getLong(column));
View Full Code Here

    private static void assertReadFields(RecordCursor cursor, List<ColumnMetadata> schema)
    {
        for (int columnIndex = 0; columnIndex < schema.size(); columnIndex++) {
            ColumnMetadata column = schema.get(columnIndex);
            if (!cursor.isNull(columnIndex)) {
                Type type = column.getType();
                if (BOOLEAN.equals(type)) {
                    cursor.getBoolean(columnIndex);
                }
                else if (BIGINT.equals(type)) {
                    cursor.getLong(columnIndex);
View Full Code Here

            public Expression rewriteExpression(Expression node, Void context, ExpressionTreeRewriter<Void> treeRewriter)
            {
                Expression rewrittenExpression = treeRewriter.defaultRewrite(node, context);

                // cast expression if coercion is registered
                Type coercion = analysis.getCoercion(node);
                if (coercion != null) {
                    rewrittenExpression = new Cast(rewrittenExpression, coercion.getName());
                }

                return rewrittenExpression;
            }

            @Override
            public Expression rewriteQualifiedNameReference(QualifiedNameReference node, Void context, ExpressionTreeRewriter<Void> treeRewriter)
            {
                QualifiedName name = node.getName();

                Integer fieldIndex = resolvedNames.get(name);
                Preconditions.checkState(fieldIndex != null, "No field mapping for name '%s'", name);

                Symbol symbol = rewriteBase.getSymbol(fieldIndex);
                Preconditions.checkState(symbol != null, "No symbol mapping for name '%s' (%s)", name, fieldIndex);

                Expression rewrittenExpression = new QualifiedNameReference(symbol.toQualifiedName());

                // cast expression if coercion is registered
                Type coercion = analysis.getCoercion(node);
                if (coercion != null) {
                    rewrittenExpression = new Cast(rewrittenExpression, coercion.getName());
                }

                return rewrittenExpression;
            }
        }, expression);
View Full Code Here

            assertTrue(cursor.isNull(0));
            assertTrue(cursor.isNull(1));
            for (int i = 2; i < TEST_VALUES.size(); i++) {
                Object fieldFromCursor;

                Type type = HiveType.getHiveType(FIELD_INSPECTORS.get(i)).getNativeType();
                if (BOOLEAN.equals(type)) {
                    fieldFromCursor = cursor.getBoolean(i);
                }
                else if (BIGINT.equals(type)) {
                    fieldFromCursor = cursor.getLong(i);
View Full Code Here

TOP

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

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.