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();
}
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);
}
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);
}
}
Aggregations