Skip to content

Commit

Permalink
Add getRawHash method to GroupByHash
Browse files Browse the repository at this point in the history
  • Loading branch information
pnowojski authored and cberner committed Nov 7, 2016
1 parent 4f607ad commit 892b073
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.block.Block;
import com.facebook.presto.spi.block.BlockBuilder;
import com.facebook.presto.spi.type.BigintType;
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.type.BigintOperators;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -189,6 +190,12 @@ public int putIfAbsent(int position, Page page)
return putIfAbsent(position, block);
}

@Override
public long getRawHash(int groupId)
{
return BigintType.hash(valuesByGroupId.get(groupId));
}

private int putIfAbsent(int position, Block block)
{
if (block.isNull(position)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ static GroupByHash createGroupByHash(
boolean contains(int position, Page page, int[] hashChannels);

int putIfAbsent(int position, Page page);

long getRawHash(int groupyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ public MultiChannelGroupByHash(
groupAddressByGroupId.ensureCapacity(maxFill);
}

@Override
public long getRawHash(int groupId)
{
long address = groupAddressByGroupId.get(groupId);
int blockIndex = decodeSliceIndex(address);
int position = decodePosition(address);
return hashStrategy.hashPosition(blockIndex, position);
}

@Override
public long getEstimatedSize()
{
Expand Down

0 comments on commit 892b073

Please sign in to comment.