当前位置: 首页>>代码示例>>Java>>正文


Java Type.writeDouble方法代码示例

本文整理汇总了Java中com.facebook.presto.spi.type.Type.writeDouble方法的典型用法代码示例。如果您正苦于以下问题:Java Type.writeDouble方法的具体用法?Java Type.writeDouble怎么用?Java Type.writeDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.presto.spi.type.Type的用法示例。


在下文中一共展示了Type.writeDouble方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapKeyToObject

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Object mapKeyToObject(ConnectorSession session, String jsonKey, Type type)
{
    BlockBuilder blockBuilder;
    if (type instanceof FixedWidthType) {
        blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), 1);
    }
    else {
        blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), 1, jsonKey.length());
    }
    if (type.getJavaType() == boolean.class) {
        type.writeBoolean(blockBuilder, Boolean.parseBoolean(jsonKey));
    }
    else if (type.getJavaType() == long.class) {
        type.writeLong(blockBuilder, Long.parseLong(jsonKey));
    }
    else if (type.getJavaType() == double.class) {
        type.writeDouble(blockBuilder, Double.parseDouble(jsonKey));
    }
    else if (type.getJavaType() == Slice.class) {
        type.writeSlice(blockBuilder, Slices.utf8Slice(jsonKey));
    }
    return type.getObjectValue(session, blockBuilder.build(), 0);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:TypeJsonUtils.java

示例2: createBlock

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Block createBlock(Type type, Object value)
{
    BlockBuilder blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), 1);

    Class<?> javaType = type.getJavaType();
    if (value == null) {
        blockBuilder.appendNull();
    }
    else if (javaType == boolean.class) {
        type.writeBoolean(blockBuilder, (Boolean) value);
    }
    else if (javaType == long.class) {
        type.writeLong(blockBuilder, (Long) value);
    }
    else if (javaType == double.class) {
        type.writeDouble(blockBuilder, (Double) value);
    }
    else if (javaType == Slice.class) {
        Slice slice = (Slice) value;
        type.writeSlice(blockBuilder, slice, 0, slice.length());
    }
    else {
        type.writeObject(blockBuilder, value);
    }
    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:AbstractTestType.java

示例3: createZeroBlock

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private Block createZeroBlock(Type type, int rowsCount, Slice constantSlice)
{
    checkArgument(SUPPORTED_TYPES.contains(type), "Unsupported type [%s]", type);
    BlockBuilder builder;

    if (type instanceof FixedWidthType) {
        builder = type.createBlockBuilder(new BlockBuilderStatus(), rowsCount);
    }
    else {
        builder = type.createBlockBuilder(new BlockBuilderStatus(), rowsCount, constantSlice.length());
    }

    for (int i = 0; i < rowsCount; i++) {
        Class<?> javaType = type.getJavaType();
        if (javaType == boolean.class) {
            type.writeBoolean(builder, false);
        }
        else if (javaType == long.class) {
            type.writeLong(builder, 0);
        }
        else if (javaType == double.class) {
            type.writeDouble(builder, 0.0);
        }
        else if (javaType == Slice.class) {
            type.writeSlice(builder, constantSlice, 0, constantSlice.length());
        }
        else {
            throw new UnsupportedOperationException("Unknown javaType: " + javaType.getName());
        }
    }
    return builder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:33,代码来源:BlackHolePageSourceProvider.java

示例4: nextVector

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public void nextVector(Type type, int items, BlockBuilder builder)
        throws IOException
{
    for (int i = 0; i < items; i++) {
        type.writeDouble(builder, next());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:8,代码来源:FloatStream.java

示例5: write

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
static void write(Type type, NullableDoubleState state, BlockBuilder out)
{
    if (state.isNull()) {
        out.appendNull();
    }
    else {
        type.writeDouble(out, state.getDouble());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:NullableDoubleState.java

示例6: appendElement

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@UsedByGeneratedCode
public static Block appendElement(Type elementType, Block block, double value)
{
    BlockBuilder blockBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), block.getPositionCount() + 1);
    for (int i = 0; i < block.getPositionCount(); i++) {
        elementType.appendTo(block, i, blockBuilder);
    }

    elementType.writeDouble(blockBuilder, value);

    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:13,代码来源:ArrayConcatUtils.java

示例7: prependElement

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@UsedByGeneratedCode
public static Block prependElement(Type elementType, double value, Block block)
{
    BlockBuilder blockBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), block.getPositionCount() + 1);

    elementType.writeDouble(blockBuilder, value);
    for (int i = 0; i < block.getPositionCount(); i++) {
        elementType.appendTo(block, i, blockBuilder);
    }

    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:13,代码来源:ArrayConcatUtils.java

示例8: createBlock

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
/**
 * Produce a block with the given values in the last field.
 */
private static Block createBlock(Type type, List<Object> values)
{
    BlockBuilder blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), values.size());

    for (Object value : values) {
        Class<?> javaType = type.getJavaType();
        if (value == null) {
            blockBuilder.appendNull();
        }
        else if (javaType == boolean.class) {
            type.writeBoolean(blockBuilder, (Boolean) value);
        }
        else if (javaType == long.class) {
            type.writeLong(blockBuilder, (Long) value);
        }
        else if (javaType == double.class) {
            type.writeDouble(blockBuilder, (Double) value);
        }
        else if (javaType == Slice.class) {
            Slice slice = (Slice) value;
            type.writeSlice(blockBuilder, slice, 0, slice.length());
        }
        else {
            throw new UnsupportedOperationException("not yet implemented: " + javaType);
        }
    }

    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:33,代码来源:AbstractTestApproximateCountDistinct.java

示例9: getOutput

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public Page getOutput()
{
    if (!finishing) {
        int i;
        for (i = 0; i < ROWS_PER_REQUEST; i++) {
            if (pageBuilder.isFull()) {
                break;
            }

            if (!cursor.advanceNextPosition()) {
                finishing = true;
                break;
            }

            pageBuilder.declarePosition();
            for (int column = 0; column < types.size(); column++) {
                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) {
                        type.writeBoolean(output, cursor.getBoolean(column));
                    }
                    else if (javaType == long.class) {
                        type.writeLong(output, cursor.getLong(column));
                    }
                    else if (javaType == double.class) {
                        type.writeDouble(output, cursor.getDouble(column));
                    }
                    else if (javaType == Slice.class) {
                        Slice slice = cursor.getSlice(column);
                        type.writeSlice(output, slice, 0, slice.length());
                    }
                    else {
                        throw new AssertionError("Unimplemented type: " + javaType.getName());
                    }
                }
            }
        }

        long endCompletedBytes = cursor.getCompletedBytes();
        long endReadTimeNanos = cursor.getReadTimeNanos();
        operatorContext.recordGeneratedInput(endCompletedBytes - completedBytes, i, endReadTimeNanos - readTimeNanos);
        completedBytes = endCompletedBytes;
        readTimeNanos = endReadTimeNanos;
    }

    // only return a full page is buffer is full or we are finishing
    if (pageBuilder.isEmpty() || (!finishing && !pageBuilder.isFull())) {
        return null;
    }

    Page page = pageBuilder.build();
    pageBuilder.reset();

    return page;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:62,代码来源:RecordProjectOperator.java

示例10: getNextPage

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public Page getNextPage()
{
    if (!closed) {
        int i;
        for (i = 0; i < ROWS_PER_REQUEST; i++) {
            if (pageBuilder.isFull()) {
                break;
            }

            if (!cursor.advanceNextPosition()) {
                closed = true;
                break;
            }

            pageBuilder.declarePosition();
            for (int column = 0; column < types.size(); column++) {
                BlockBuilder output = pageBuilder.getBlockBuilder(column);
                if (cursor.isNull(column)) {
                    output.appendNull();
                }
                else {
                    Type type = types.get(column);
                    Class<?> javaType = type.getJavaType();
                    if (javaType == boolean.class) {
                        type.writeBoolean(output, cursor.getBoolean(column));
                    }
                    else if (javaType == long.class) {
                        type.writeLong(output, cursor.getLong(column));
                    }
                    else if (javaType == double.class) {
                        type.writeDouble(output, cursor.getDouble(column));
                    }
                    else if (javaType == Slice.class) {
                        Slice slice = cursor.getSlice(column);
                        type.writeSlice(output, slice, 0, slice.length());
                    }
                    else {
                        type.writeObject(output, cursor.getObject(column));
                    }
                }
            }
        }
    }

    // only return a page if the buffer is full or we are finishing
    if (pageBuilder.isEmpty() || (!closed && !pageBuilder.isFull())) {
        return null;
    }

    Page page = pageBuilder.build();
    pageBuilder.reset();

    return page;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:56,代码来源:RecordPageSource.java


注:本文中的com.facebook.presto.spi.type.Type.writeDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。