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


Java BlockBuilder.build方法代码示例

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


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

示例1: createTestBlock

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static Block createTestBlock()
{
    BlockBuilder blockBuilder = TIME_WITH_TIME_ZONE.createBlockBuilder(new BlockBuilderStatus(), 15);
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(0)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(1)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(2)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(3)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(4)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(5)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(6)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(7)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(3333, getTimeZoneKeyForOffset(8)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(3333, getTimeZoneKeyForOffset(9)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(4444, getTimeZoneKeyForOffset(10)));
    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TestTimeWithTimeZoneType.java

示例2: testPrimitiveLongSerialization

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Test
public void testPrimitiveLongSerialization()
{
    StateCompiler compiler = new StateCompiler();

    AccumulatorStateFactory<LongState> factory = compiler.generateStateFactory(LongState.class);
    AccumulatorStateSerializer<LongState> serializer = compiler.generateStateSerializer(LongState.class);
    LongState state = factory.createSingleState();
    LongState deserializedState = factory.createSingleState();

    state.setLong(2);

    BlockBuilder builder = BIGINT.createBlockBuilder(new BlockBuilderStatus(), 1);
    serializer.serialize(state, builder);

    Block block = builder.build();

    assertEquals(BIGINT.getLong(block, 0), state.getLong());
    serializer.deserialize(block, 0, deserializedState);
    assertEquals(deserializedState.getLong(), state.getLong());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:TestStateCompiler.java

示例3: createTestBlock

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static Block createTestBlock()
{
    BlockBuilder blockBuilder = VARBINARY.createBlockBuilder(new BlockBuilderStatus(), 15);
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("apple"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("apple"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("apple"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("cherry"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("cherry"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("date"));
    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TestVarbinaryType.java

示例4: 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

示例5: 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

示例6: 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

示例7: testCompactDictionaryBlocks

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Test
public void testCompactDictionaryBlocks()
        throws Exception
{
    Slice[] expectedValues = createExpectedValues(10);
    BlockBuilder blockBuilder = BIGINT.createBlockBuilder(new BlockBuilderStatus(), expectedValues.length);
    for (Slice expectedValue : expectedValues) {
        BIGINT.writeLong(blockBuilder, expectedValue.length());
    }
    Block lengthsDictionary = blockBuilder.build();

    // Create 2 dictionary blocks with the same source id
    DictionaryId commonSourceId = randomDictionaryId();
    DictionaryBlock commonSourceIdBlock1 = createDictionaryBlock(expectedValues, 100, commonSourceId);
    DictionaryBlock commonSourceIdBlock2 = new DictionaryBlock(commonSourceIdBlock1.getPositionCount(), lengthsDictionary, commonSourceIdBlock1.getIds(), commonSourceId);

    // Create block with a different source id
    DictionaryBlock randomSourceIdBlock = createDictionaryBlock(expectedValues, 100, randomDictionaryId());

    Page page = new Page(commonSourceIdBlock1, randomSourceIdBlock, commonSourceIdBlock2);
    page.compact();

    // Blocks that had the same source id before compacting page should have the same source id after compacting page
    assertNotEquals(((DictionaryBlock) page.getBlock(0)).getDictionarySourceId(), ((DictionaryBlock) page.getBlock(1)).getDictionarySourceId());
    assertEquals(((DictionaryBlock) page.getBlock(0)).getDictionarySourceId(), ((DictionaryBlock) page.getBlock(2)).getDictionarySourceId());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:TestPage.java

示例8: 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

示例9: 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

示例10: geohash_decode

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@SqlType("array(double)")
public static Block geohash_decode(@SqlType(StandardTypes.VARCHAR) Slice geohash) {

    BlockBuilder blockBuilder = DOUBLE.createBlockBuilder(new BlockBuilderStatus(), 2);
    LatLong coordinates = GeoHash.decodeHash(geohash.toStringUtf8());
    DOUBLE.writeDouble(blockBuilder, coordinates.getLat());
    DOUBLE.writeDouble(blockBuilder, coordinates.getLon());
    return blockBuilder.build();
}
 
开发者ID:Cuebiq,项目名称:presto-cuebiq-functions,代码行数:10,代码来源:GeoHashDecode.java

示例11: serializeList

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
private static Block serializeList(Type type, BlockBuilder builder, Object object, ListObjectInspector inspector)
{
    List<?> list = inspector.getList(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);
    ObjectInspector elementInspector = inspector.getListElementObjectInspector();
    BlockBuilder currentBuilder;
    if (builder != null) {
        currentBuilder = builder.beginBlockEntry();
    }
    else {
        currentBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), list.size());
    }

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

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

示例12: regexpSplit

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@ScalarFunction
@Description("returns array of strings split by pattern")
@SqlType("array<varchar>")
public static Block regexpSplit(@SqlType(StandardTypes.VARCHAR) Slice source, @SqlType(RegexpType.NAME) Regex pattern)
{
    Matcher matcher = pattern.matcher(source.getBytes());
    BlockBuilder blockBuilder = VARCHAR.createBlockBuilder(new BlockBuilderStatus(), 32);

    int lastEnd = 0;
    int nextStart = 0;
    while (true) {
        int offset = matcher.search(nextStart, source.length(), Option.DEFAULT);
        if (offset == -1) {
            break;
        }
        if (matcher.getEnd() == matcher.getBegin()) {
            nextStart = matcher.getEnd() + 1;
        }
        else {
            nextStart = matcher.getEnd();
        }
        Slice slice = source.slice(lastEnd, matcher.getBegin() - lastEnd);
        lastEnd = matcher.getEnd();
        VARCHAR.writeSlice(blockBuilder, slice);
    }
    VARCHAR.writeSlice(blockBuilder, source.slice(lastEnd, source.length() - lastEnd));

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

示例13: mapBlockOf

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static Block mapBlockOf(Type keyType, Type valueType, Object key, Object value)
{
    BlockBuilder blockBuilder = new InterleavedBlockBuilder(ImmutableList.of(keyType, valueType), new BlockBuilderStatus(), 1024);
    appendToBlockBuilder(keyType, key, blockBuilder);
    appendToBlockBuilder(valueType, value, blockBuilder);
    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:8,代码来源:StructuralTestUtil.java

示例14: createTimestampsWithTimezoneBlock

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static Block createTimestampsWithTimezoneBlock(Long... values)
{
    BlockBuilder builder = TIMESTAMP_WITH_TIME_ZONE.createFixedSizeBlockBuilder(values.length);
    for (long value : values) {
        TIMESTAMP_WITH_TIME_ZONE.writeLong(builder, value);
    }
    return builder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:9,代码来源:BlockAssertions.java

示例15: createBooleansBlock

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static Block createBooleansBlock(Iterable<Boolean> values)
{
    BlockBuilder builder = BOOLEAN.createBlockBuilder(new BlockBuilderStatus(), 100);

    for (Boolean value : values) {
        if (value == null) {
            builder.appendNull();
        }
        else {
            BOOLEAN.writeBoolean(builder, value);
        }
    }

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


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