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


Java BlockBuilder.closeEntry方法代码示例

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


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

示例1: parseAgent

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@ScalarFunction("parse_agent")
@Description("Returns Map, which has keys such as 'category', 'name', 'os', 'version', 'vendor' and 'os_version'")
@SqlType("map<varchar,varchar>")
public Block parseAgent(@TypeParameter("map<varchar,varchar>") Type mapType, @SqlType(StandardTypes.VARCHAR) Slice slice) {
    String argument = slice.toStringUtf8();
    Map<String, String> stringMap = Classifier.parse(argument);

    if (pageBuilder.isFull()) {
        pageBuilder.reset();
    }

    BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0);
    BlockBuilder singleMapBlockBuilder = blockBuilder.beginBlockEntry();
    for (Map.Entry<String, String> entry : stringMap.entrySet()) {
        VARCHAR.writeSlice(singleMapBlockBuilder, Slices.utf8Slice(entry.getKey()));
        VARCHAR.writeSlice(singleMapBlockBuilder, Slices.utf8Slice(entry.getValue()));
    }
    blockBuilder.closeEntry();
    pageBuilder.declarePosition();

    return (Block) mapType.getObject(blockBuilder, blockBuilder.getPositionCount() - 1);
}
 
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:23,代码来源:ParseAgentFuntion.java

示例2: output

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@OutputFunction("array<bigint>")
public static void output(DigestAndPercentileArrayState state, BlockBuilder out)
{
    QuantileDigest digest = state.getDigest();
    List<Double> percentiles = state.getPercentiles();

    if (percentiles == null || digest == null) {
        out.appendNull();
        return;
    }

    BlockBuilder blockBuilder = out.beginBlockEntry();

    for (int i = 0; i < percentiles.size(); i++) {
        Double percentile = percentiles.get(i);
        BIGINT.writeLong(blockBuilder, digest.getQuantile(percentile));
    }

    out.closeEntry();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:ApproximateLongPercentileArrayAggregations.java

示例3: output

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@OutputFunction("map<double,double>")
public static void output(State state, BlockBuilder out)
{
    if (state.get() == null) {
        out.appendNull();
    }
    else {
        Map<Double, Double> value = state.get().getBuckets();
        BlockBuilder blockBuilder = DoubleType.DOUBLE.createBlockBuilder(new BlockBuilderStatus(), value.size() * 2);
        for (Map.Entry<Double, Double> entry : value.entrySet()) {
            DoubleType.DOUBLE.writeDouble(blockBuilder, entry.getKey());
            DoubleType.DOUBLE.writeDouble(blockBuilder, entry.getValue());
        }
        Block block = blockBuilder.build();
        out.writeObject(block);
        out.closeEntry();
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:NumericHistogramAggregation.java

示例4: output

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static void output(ArrayType outputType, MinMaxByNState state, BlockBuilder out)
{
    TypedKeyValueHeap heap = state.getTypedKeyValueHeap();
    if (heap == null || heap.isEmpty()) {
        out.appendNull();
        return;
    }

    Type elementType = outputType.getElementType();

    BlockBuilder arrayBlockBuilder = out.beginBlockEntry();
    BlockBuilder reversedBlockBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), heap.getCapacity());
    long startSize = heap.getEstimatedSize();
    heap.popAll(reversedBlockBuilder);
    state.addMemoryUsage(heap.getEstimatedSize() - startSize);

    for (int i = reversedBlockBuilder.getPositionCount() - 1; i >= 0; i--) {
        elementType.appendTo(reversedBlockBuilder, i, arrayBlockBuilder);
    }
    out.closeEntry();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:AbstractMinMaxByNAggregationFunction.java

示例5: output

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@OutputFunction("array<double>")
public static void output(DigestAndPercentileArrayState state, BlockBuilder out)
{
    QuantileDigest digest = state.getDigest();
    List<Double> percentiles = state.getPercentiles();

    if (percentiles == null || digest == null) {
        out.appendNull();
        return;
    }

    BlockBuilder blockBuilder = out.beginBlockEntry();

    for (int i = 0; i < percentiles.size(); i++) {
        Double percentile = percentiles.get(i);
        DOUBLE.writeDouble(blockBuilder, sortableLongToDouble(digest.getQuantile(percentile)));
    }

    out.closeEntry();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:ApproximateDoublePercentileArrayAggregations.java

示例6: serialize

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public void serialize(MaxOrMinByState state, BlockBuilder out)
{
    Block keyState = state.getKey();
    Block valueState = state.getValue();

    checkState((keyState == null) == (valueState == null), "(keyState == null) != (valueState == null)");
    if (keyState == null) {
        out.appendNull();
        return;
    }

    BlockBuilder blockBuilder = out.beginBlockEntry();
    keyType.appendTo(keyState, 0, blockBuilder);
    valueType.appendTo(valueState, 0, blockBuilder);
    out.closeEntry();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:MaxOrMinByStateSerializer.java

示例7: output

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static void output(ArrayType outputType, MinMaxNState state, BlockBuilder out)
{
    TypedHeap heap = state.getTypedHeap();
    if (heap == null || heap.isEmpty()) {
        out.appendNull();
        return;
    }

    Type elementType = outputType.getElementType();

    BlockBuilder reversedBlockBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), heap.getCapacity());
    long startSize = heap.getEstimatedSize();
    heap.popAll(reversedBlockBuilder);
    state.addMemoryUsage(heap.getEstimatedSize() - startSize);

    BlockBuilder arrayBlockBuilder = out.beginBlockEntry();
    for (int i = reversedBlockBuilder.getPositionCount() - 1; i >= 0; i--) {
        elementType.appendTo(reversedBlockBuilder, i, arrayBlockBuilder);
    }
    out.closeEntry();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:AbstractMinMaxNAggregationFunction.java

示例8: serialize

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public void serialize(BlockBuilder out)
{
    BlockBuilder blockBuilder = out.beginBlockEntry();
    BIGINT.writeLong(blockBuilder, getCapacity());

    BlockBuilder keyElements = blockBuilder.beginBlockEntry();
    for (int i = 0; i < positionCount; i++) {
        keyType.appendTo(keyBlockBuilder, heapIndex[i], keyElements);
    }
    blockBuilder.closeEntry();

    BlockBuilder valueElements = blockBuilder.beginBlockEntry();
    for (int i = 0; i < positionCount; i++) {
        valueType.appendTo(valueBlockBuilder, heapIndex[i], valueElements);
    }
    blockBuilder.closeEntry();

    out.closeEntry();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:TypedKeyValueHeap.java

示例9: createLongArraysBlock

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public Block createLongArraysBlock(Long[] values)
{
    ArrayType arrayType = new ArrayType(BIGINT);
    BlockBuilder blockBuilder = arrayType.createBlockBuilder(new BlockBuilderStatus(), values.length);
    for (Long value : values) {
        if (value == null) {
            blockBuilder.appendNull();
        }
        else {
            BlockBuilder elementBlockBuilder = blockBuilder.beginBlockEntry();
            BIGINT.writeLong(elementBlockBuilder, value);
            blockBuilder.closeEntry();
        }
    }
    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TestArrayMaxNAggregation.java

示例10: createChannel

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
private static Block createChannel(int positionCount, int arraySize, ArrayType arrayType)
{
    BlockBuilder blockBuilder = arrayType.createBlockBuilder(new BlockBuilderStatus(), positionCount);
    for (int position = 0; position < positionCount; position++) {
        BlockBuilder entryBuilder = blockBuilder.beginBlockEntry();
        for (int i = 0; i < arraySize; i++) {
            if (arrayType.getElementType().getJavaType() == long.class) {
                arrayType.getElementType().writeLong(entryBuilder, ThreadLocalRandom.current().nextLong());
            }
            else if (arrayType.getElementType().equals(VARCHAR)) {
                arrayType.getElementType().writeSlice(entryBuilder, Slices.utf8Slice("test_string"));
            }
            else {
                throw new UnsupportedOperationException();
            }
        }
        blockBuilder.closeEntry();
    }
    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:BenchmarkArrayDistinct.java

示例11: serializeList

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
private static Block serializeList(Type type, BlockBuilder builder, Object object) {
    List<?> list = (List) object;
    if (list == null) {
        requireNonNull(builder, "parent builder is null").appendNull();
        return null;
    }

    List<Type> typeParameters = type.getTypeParameters();
    checkArgument(typeParameters.size() == 1, "list must have exactly 1 type parameter");
    Type elementType = typeParameters.get(0);

    BlockBuilder currentBuilder;
    if (builder != null) {
        currentBuilder = builder.beginBlockEntry();
    } else {
        currentBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), list.size());
    }

    for (Object element : list) {
        serializeObject(elementType, currentBuilder, element);
    }

    if (builder != null) {
        builder.closeEntry();
        return null;
    } else {
        Block resultBlock = currentBuilder.build();
        return resultBlock;
    }
}
 
开发者ID:xiaoyao1991,项目名称:presto-ethereum,代码行数:31,代码来源:EthereumRecordCursor.java

示例12: serializeMap

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
private static Block serializeMap(Type type, BlockBuilder builder, Object object) {
    Map<?, ?> map = (Map) object;
    if (map == null) {
        requireNonNull(builder, "parent builder is null").appendNull();
        return null;
    }

    List<Type> typeParameters = type.getTypeParameters();
    checkArgument(typeParameters.size() == 2, "map must have exactly 2 type parameter");
    Type keyType = typeParameters.get(0);
    Type valueType = typeParameters.get(1);

    BlockBuilder currentBuilder;
    if (builder != null) {
        currentBuilder = builder.beginBlockEntry();
    } else {
        currentBuilder = new InterleavedBlockBuilder(typeParameters, new BlockBuilderStatus(), map.size());
    }

    for (Map.Entry<?, ?> entry : map.entrySet()) {
        // Hive skips map entries with null keys
        if (entry.getKey() != null) {
            serializeObject(keyType, currentBuilder, entry.getKey());
            serializeObject(valueType, currentBuilder, entry.getValue());
        }
    }

    if (builder != null) {
        builder.closeEntry();
        return null;
    } else {
        Block resultBlock = currentBuilder.build();
        return resultBlock;
    }
}
 
开发者ID:xiaoyao1991,项目名称:presto-ethereum,代码行数:36,代码来源:EthereumRecordCursor.java

示例13: appendTo

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writeBytesTo(position, 0, block.getLength(position), blockBuilder);
        blockBuilder.closeEntry();
    }
}
 
开发者ID:vitillo,项目名称:presto-hyperloglog,代码行数:12,代码来源:HyperLogLogType.java

示例14: output

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static void output(KeyValuePairsState state, BlockBuilder out)
{
    KeyValuePairs pairs = state.get();
    if (pairs == null) {
        out.appendNull();
    }
    else {
        Block block = pairs.toMultimapNativeEncoding();
        out.writeObject(block);
        out.closeEntry();
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:13,代码来源:MultimapAggregationFunction.java

示例15: output

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static void output(KeyValuePairsState state, BlockBuilder out)
{
    KeyValuePairs pairs = state.get();
    if (pairs == null) {
        out.appendNull();
    }
    else {
        Block block = pairs.toMapNativeEncoding();
        out.writeObject(block);
        out.closeEntry();
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:13,代码来源:MapAggregationFunction.java


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