Search in sources :

Example 1 with InterpretedHashGenerator

use of com.facebook.presto.operator.InterpretedHashGenerator in project presto by prestodb.

the class TypeUtils method getHashBlock.

public static Block getHashBlock(List<? extends Type> hashTypes, Block... hashBlocks) {
    checkArgument(hashTypes.size() == hashBlocks.length);
    int[] hashChannels = new int[hashBlocks.length];
    for (int i = 0; i < hashBlocks.length; i++) {
        hashChannels[i] = i;
    }
    HashGenerator hashGenerator = new InterpretedHashGenerator(ImmutableList.copyOf(hashTypes), hashChannels);
    int positionCount = hashBlocks[0].getPositionCount();
    BlockBuilder builder = BIGINT.createFixedSizeBlockBuilder(positionCount);
    Page page = new Page(hashBlocks);
    for (int i = 0; i < positionCount; i++) {
        BIGINT.writeLong(builder, hashGenerator.hashPosition(i, page));
    }
    return builder.build();
}
Also used : InterpretedHashGenerator(com.facebook.presto.operator.InterpretedHashGenerator) Page(com.facebook.presto.spi.Page) HashGenerator(com.facebook.presto.operator.HashGenerator) InterpretedHashGenerator(com.facebook.presto.operator.InterpretedHashGenerator) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder)

Example 2 with InterpretedHashGenerator

use of com.facebook.presto.operator.InterpretedHashGenerator in project presto by prestodb.

the class TypeUtils method getHashPosition.

public static long getHashPosition(List<? extends Type> hashTypes, Block[] hashBlocks, int position) {
    int[] hashChannels = new int[hashBlocks.length];
    for (int i = 0; i < hashBlocks.length; i++) {
        hashChannels[i] = i;
    }
    HashGenerator hashGenerator = new InterpretedHashGenerator(ImmutableList.copyOf(hashTypes), hashChannels);
    Page page = new Page(hashBlocks);
    return hashGenerator.hashPosition(position, page);
}
Also used : InterpretedHashGenerator(com.facebook.presto.operator.InterpretedHashGenerator) Page(com.facebook.presto.spi.Page) HashGenerator(com.facebook.presto.operator.HashGenerator) InterpretedHashGenerator(com.facebook.presto.operator.InterpretedHashGenerator)

Example 3 with InterpretedHashGenerator

use of com.facebook.presto.operator.InterpretedHashGenerator in project presto by prestodb.

the class TestLocalExchange method assertPartitionedRemovePage.

private static void assertPartitionedRemovePage(LocalExchangeSource source, int partition, int partitionCount) {
    assertEquals(source.getTypes(), TYPES);
    assertTrue(source.waitForReading().isDone());
    Page page = source.removePage();
    assertNotNull(page);
    LocalPartitionGenerator partitionGenerator = new LocalPartitionGenerator(new InterpretedHashGenerator(TYPES, new int[] { 0 }), partitionCount);
    for (int position = 0; position < page.getPositionCount(); position++) {
        assertEquals(partitionGenerator.getPartition(position, page), partition);
    }
}
Also used : InterpretedHashGenerator(com.facebook.presto.operator.InterpretedHashGenerator) Page(com.facebook.presto.spi.Page)

Aggregations

InterpretedHashGenerator (com.facebook.presto.operator.InterpretedHashGenerator)3 Page (com.facebook.presto.spi.Page)3 HashGenerator (com.facebook.presto.operator.HashGenerator)2 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)1