Add InterpretedHashGenerator#hashPosition that accepts block provider
@@ -15,12 +15,14 @@ package com.facebook.presto.operator;
import com.facebook.presto.operator.scalar.CombineHashFunction;
import com.facebook.presto.spi.Page;
+import com.facebook.presto.spi.block.Block;
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.sql.planner.optimizations.HashGenerationOptimizer;
import com.facebook.presto.type.TypeUtils;
import com.google.common.collect.ImmutableList;
import java.util.List;
+import java.util.function.IntFunction;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
@@ -46,11 +48,16 @@ public class InterpretedHashGenerator
@Override
public long hashPosition(int position, Page page)
+ {
+ return hashPosition(position, page::getBlock);
+ }
+
+ public long hashPosition(int position, IntFunction<Block> blockProvider)
{
long result = HashGenerationOptimizer.INITIAL_HASH_VALUE;
for (int i = 0; i < hashChannels.length; i++) {
Type type = hashChannelTypes.get(i);
- result = CombineHashFunction.getHash(result, TypeUtils.hashPosition(type, page.getBlock(hashChannels[i]), position));
+ result = CombineHashFunction.getHash(result, TypeUtils.hashPosition(type, blockProvider.apply(hashChannels[i]), position));
}
return result;
}
