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


Java BlockBuilder.getPositionCount方法代码示例

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


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

示例1: combine

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static void combine(Type type, ArrayAggregationState state, ArrayAggregationState otherState)
{
    BlockBuilder stateBlockBuilder = state.getBlockBuilder();
    BlockBuilder otherStateBlockBuilder = otherState.getBlockBuilder();
    if (otherStateBlockBuilder == null) {
        return;
    }
    if (stateBlockBuilder == null) {
        state.setBlockBuilder(otherStateBlockBuilder);
        return;
    }
    int otherPositionCount = otherStateBlockBuilder.getPositionCount();
    long startSize = stateBlockBuilder.getRetainedSizeInBytes();
    for (int i = 0; i < otherPositionCount; i++) {
        type.appendTo(otherStateBlockBuilder, i, stateBlockBuilder);
    }
    state.addMemoryUsage(stateBlockBuilder.getRetainedSizeInBytes() - startSize);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:ArrayAggregationFunction.java

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

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

示例4: output

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
public static void output(Type outputType, ArrayAggregationState state, BlockBuilder out)
{
    BlockBuilder stateBlockBuilder = state.getBlockBuilder();
    if (stateBlockBuilder == null || stateBlockBuilder.getPositionCount() == 0) {
        out.appendNull();
    }
    else {
        outputType.writeObject(out, stateBlockBuilder.build());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:ArrayAggregationFunction.java

示例5: toMultimapNativeEncoding

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
/**
 * Serialize as a multimap: map<key, array<value>>, each key can be associated with multiple values
 */
public Block toMultimapNativeEncoding()
{
    if (!isMultiValue) {
        throw new PrestoException(INTERNAL_ERROR, "This KeyValuePairs is not multimap.");
    }

    Block keys = keyBlockBuilder.build();
    Block values = valueBlockBuilder.build();

    // Merge values of the same key into an array
    BlockBuilder distinctKeyBlockBuilder = keyType.createBlockBuilder(new BlockBuilderStatus(), keys.getPositionCount(), expectedValueSize(keyType, EXPECTED_ENTRY_SIZE));
    ObjectBigArray<BlockBuilder> valueArrayBlockBuilders = new ObjectBigArray<>();
    valueArrayBlockBuilders.ensureCapacity(keys.getPositionCount());
    TypedSet keySet = new TypedSet(keyType, keys.getPositionCount());
    for (int keyValueIndex = 0; keyValueIndex < keys.getPositionCount(); keyValueIndex++) {
        if (!keySet.contains(keys, keyValueIndex)) {
            keySet.add(keys, keyValueIndex);
            keyType.appendTo(keys, keyValueIndex, distinctKeyBlockBuilder);
            BlockBuilder valueArrayBuilder = valueType.createBlockBuilder(new BlockBuilderStatus(), 10, expectedValueSize(valueType, EXPECTED_ENTRY_SIZE));
            valueArrayBlockBuilders.set(keySet.positionOf(keys, keyValueIndex), valueArrayBuilder);
        }
        valueType.appendTo(values, keyValueIndex, valueArrayBlockBuilders.get(keySet.positionOf(keys, keyValueIndex)));
    }

    // Write keys and value arrays into one Block
    Block distinctKeys = distinctKeyBlockBuilder.build();
    Type valueArrayType = new ArrayType(valueType);
    BlockBuilder multimapBlockBuilder = new InterleavedBlockBuilder(ImmutableList.of(keyType, valueArrayType), new BlockBuilderStatus(), distinctKeyBlockBuilder.getPositionCount());
    for (int i = 0; i < distinctKeys.getPositionCount(); i++) {
        keyType.appendTo(distinctKeys, i, multimapBlockBuilder);
        valueArrayType.writeObject(multimapBlockBuilder, valueArrayBlockBuilders.get(i).build());
    }

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

示例6: split

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@ScalarFunction
@SqlType("array<varchar>")
public static Block split(@SqlType(StandardTypes.VARCHAR) Slice string, @SqlType(StandardTypes.VARCHAR) Slice delimiter, @SqlType(StandardTypes.BIGINT) long limit)
{
    checkCondition(limit > 0, INVALID_FUNCTION_ARGUMENT, "Limit must be positive");
    checkCondition(limit <= Integer.MAX_VALUE, INVALID_FUNCTION_ARGUMENT, "Limit is too large");
    checkCondition(delimiter.length() > 0, INVALID_FUNCTION_ARGUMENT, "The delimiter may not be the empty string");
    BlockBuilder parts = VARCHAR.createBlockBuilder(new BlockBuilderStatus(), 1, string.length());
    // If limit is one, the last and only element is the complete string
    if (limit == 1) {
        VARCHAR.writeSlice(parts, string);
        return parts.build();
    }

    int index = 0;
    while (index < string.length()) {
        int splitIndex = string.indexOf(delimiter, index);
        // Found split?
        if (splitIndex < 0) {
            break;
        }
        // Add the part from current index to found split
        VARCHAR.writeSlice(parts, string, index, splitIndex - index);
        // Continue searching after delimiter
        index = splitIndex + delimiter.length();
        // Reached limit-1 parts so we can stop
        if (parts.getPositionCount() == limit - 1) {
            break;
        }
    }
    // Rest of string
    VARCHAR.writeSlice(parts, string, index, string.length() - index);

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

示例7: testGetElementPosition

import com.facebook.presto.spi.block.BlockBuilder; //导入方法依赖的package包/类
@Test
public void testGetElementPosition()
        throws Exception
{
    int elementCount = 100;
    TypedSet typedSet = new TypedSet(BIGINT, elementCount);
    BlockBuilder blockBuilder = BIGINT.createFixedSizeBlockBuilder(elementCount);
    for (int i = 0; i < elementCount; i++) {
        BIGINT.writeLong(blockBuilder, i);
        typedSet.add(blockBuilder, i);
    }
    for (int j = 0; j < blockBuilder.getPositionCount(); j++) {
        assertEquals(typedSet.positionOf(blockBuilder, j), j);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:16,代码来源:TestTypedSet.java


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