Package com.facebook.presto.spi.type

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


                    Object value = data.get(i);
                    if (value == null) {
                        row.add(null);
                        continue;
                    }
                    Type type = types.get(i);
                    if (type.equals(BOOLEAN)) {
                        row.add(value);
                    }
                    else if (type.equals(BIGINT)) {
                        row.add(((Number) value).longValue());
                    }
                    else if (type.equals(DOUBLE)) {
                        row.add(((Number) value).doubleValue());
                    }
                    else if (type.equals(VARCHAR)) {
                        row.add(value);
                    }
                    else {
                        throw new AssertionError("unhandled type: " + type);
                    }
View Full Code Here


        {
            @Override
            public Type apply(Column column)
            {
                String typeName = column.getType();
                Type type = prestoServer.getMetadata().getType(typeName);
                if (type == null) {
                    throw new AssertionError("Unhandled type: " + typeName);
                }
                return type;
            }
View Full Code Here

                    if (value == null) {
                        row.add(null);
                        continue;
                    }

                    Type type = types.get(i);
                    if (BOOLEAN.equals(type)) {
                        row.add(value);
                    }
                    else if (BIGINT.equals(type)) {
                        row.add(((Number) value).longValue());
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());
                }
                return tableId;
            }
        });
View Full Code Here

    @Override
    public ByteCodeNode visitInputReference(InputReferenceExpression node, CompilerContext context)
    {
        int field = node.getField();
        Type type = node.getType();

        Class<?> javaType = type.getJavaType();

        if (sourceIsCursor) {
            Block isNullCheck = new Block(context)
                    .setDescription(format("cursor.get%s(%d)", type, field))
                    .getVariable("cursor")
View Full Code Here

    }

    @Override
    protected ByteCodeNode visitGenericLiteral(GenericLiteral node, CompilerContext context)
    {
        Type type = metadata.getType(node.getType());
        if (type == null) {
            throw new IllegalArgumentException("Unsupported type: " + node.getType());
        }

        ByteCodeNode value = sliceConstant(node.getValue());
View Full Code Here

    @Override
    public ByteCodeNode visitInputReference(InputReference node, CompilerContext context)
    {
        int channel = node.getChannel();

        Type type = expressionTypes.get(node);
        checkState(type != null, "No type for input %d", channel);
        Class<?> javaType = type.getJavaType();

        if (sourceIsCursor) {
            Block isNullCheck = new Block(context)
                    .setDescription(format("cursor.get%s(%d)", type, channel))
                    .getVariable("cursor")
View Full Code Here

    }

    @Override
    public ByteCodeNode visitCast(Cast node, CompilerContext context)
    {
        Type type = metadata.getType(node.getType());
        if (type == null) {
            throw new IllegalArgumentException("Unsupported type: " + node.getType());
        }

        if (expressionTypes.get(node.getExpression()).equals(UNKNOWN)) {
            // set was null and push java default
            return new Block(context).putVariable("wasNull", true).pushJavaDefault(type.getJavaType());
        }

        ByteCodeNode value = process(node.getExpression(), context);
        FunctionBinding functionBinding = bootstrapFunctionBinder.bindCastOperator(
                getSessionByteCode,
                value,
                expressionTypes.get(node.getExpression()),
                type);

        ByteCodeNode castFunction = visitFunctionBinding(context, functionBinding, node.toString());

        if (!node.isSafe()) {
            return castFunction;
        }

        Block catchBlock = new Block(context)
                .comment("propagate InterruptedException")
                .invokeStatic(CompilerOperations.class, "propagateInterruptedException", void.class, Throwable.class)
                .comment("wasNull = true;")
                .putVariable("wasNull", true)
                .comment("restore stack after exception")
                .getVariable("output")
                .comment("return dummy value for null")
                .pushJavaDefault(type.getJavaType());

        return new TryCatch(context, node.toString(), castFunction, catchBlock, type(Exception.class));
    }
View Full Code Here

    @Override
    protected ByteCodeNode visitLogicalBinaryExpression(LogicalBinaryExpression node, CompilerContext context)
    {
        ByteCodeNode left = process(node.getLeft(), context);
        Type leftType = expressionTypes.get(node.getLeft());
        ByteCodeNode right = process(node.getRight(), context);
        Type rightType = expressionTypes.get(node.getRight());

        switch (node.getType()) {
            case AND:
                return visitAnd(context, left, leftType, right, rightType, node.toString());
            case OR:
View Full Code Here

        return visitFunctionBinding(context, functionBinding, node.toString());
    }

    private ByteCodeNode visitIsDistinctFrom(ComparisonExpression node, CompilerContext context)
    {
        Type leftType = expressionTypes.get(node.getLeft());
        Type rightType = expressionTypes.get(node.getRight());

        FunctionBinding functionBinding = bootstrapFunctionBinder.bindOperator(
                OperatorType.EQUAL,
                getSessionByteCode,
                ImmutableList.<ByteCodeNode>of(NOP, NOP),
                ImmutableList.of(leftType, rightType));

        ByteCodeNode equalsCall = new Block(context).comment("equals(%s, %s)", leftType, rightType)
                .invokeDynamic(functionBinding.getName(), functionBinding.getCallSite().type(), functionBinding.getBindingId());

        Block block = new Block(context)
                .comment(node.toString())
                .comment("left")
                .append(process(node.getLeft(), context))
                .append(new IfStatement(context,
                        new Block(context).getVariable("wasNull"),
                        new Block(context)
                                .pop(leftType.getJavaType())
                                .putVariable("wasNull", false)
                                .comment("right is not null")
                                .append(process(node.getRight(), context))
                                .pop(rightType.getJavaType())
                                .getVariable("wasNull")
                                .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class),
                        new Block(context)
                                .comment("right")
                                .append(process(node.getRight(), context))
                                .append(new IfStatement(context,
                                        new Block(context).getVariable("wasNull"),
                                        new Block(context)
                                                .pop(leftType.getJavaType())
                                                .pop(rightType.getJavaType())
                                                .push(true),
                                        new Block(context)
                                                .append(equalsCall)
                                                .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class)))))
                .putVariable("wasNull", false);
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.