Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public AddPageWork(Block block)
public boolean process()
{
int positionCount = block.getPositionCount();
checkState(lastPosition < positionCount, "position count out of bound");
checkState(lastPosition <= positionCount, "position count out of bound");

// needRehash() == false indicates we have reached capacity boundary and a rehash is needed.
// We can only proceed if tryRehash() successfully did a rehash.
Expand Down Expand Up @@ -402,7 +402,7 @@ public GetGroupIdsWork(Block block)
public boolean process()
{
int positionCount = block.getPositionCount();
checkState(lastPosition < positionCount, "position count out of bound");
checkState(lastPosition <= positionCount, "position count out of bound");
checkState(!finished);

// needRehash() == false indicates we have reached capacity boundary and a rehash is needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public AddNonDictionaryPageWork(Page page)
public boolean process()
{
int positionCount = page.getPositionCount();
checkState(lastPosition < positionCount, "position count out of bound");
checkState(lastPosition <= positionCount, "position count out of bound");

// needRehash() == false indicates we have reached capacity boundary and a rehash is needed.
// We can only proceed if tryRehash() successfully did a rehash.
Expand Down Expand Up @@ -637,7 +637,7 @@ public AddDictionaryPageWork(Page page)
public boolean process()
{
int positionCount = page.getPositionCount();
checkState(lastPosition < positionCount, "position count out of bound");
checkState(lastPosition <= positionCount, "position count out of bound");

// needRehash() == false indicates we have reached capacity boundary and a rehash is needed.
// We can only proceed if tryRehash() successfully did a rehash.
Expand Down Expand Up @@ -780,7 +780,7 @@ public GetDictionaryGroupIdsWork(Page page)
public boolean process()
{
int positionCount = page.getPositionCount();
checkState(lastPosition < positionCount, "position count out of bound");
checkState(lastPosition <= positionCount, "position count out of bound");
checkState(!finished);

// needRehash() == false indicates we have reached capacity boundary and a rehash is needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,38 @@ else if (type == BIGINT) {
assertEquals(rehashCount.get(), log2(length / 0.75, RoundingMode.FLOOR));
}

@Test(dataProvider = "dataType")
public void testEmptyPage(Type type)
{
// Create an empty page
int length = 0;
Block valuesBlock;
if (type == VARCHAR) {
valuesBlock = createStringSequenceBlock(0, length);
}
else if (type == BIGINT) {
valuesBlock = createLongSequenceBlock(0, length);
}
else {
throw new IllegalArgumentException("unsupported data type");
}
Block hashBlock = getHashBlock(ImmutableList.of(type), valuesBlock);
Page page = new Page(valuesBlock, hashBlock);
AtomicInteger currentQuota = new AtomicInteger(0);
AtomicInteger allowedQuota = new AtomicInteger(3);
UpdateMemory updateMemory = () -> {
if (currentQuota.get() < allowedQuota.get()) {
currentQuota.getAndIncrement();
return true;
}
return false;
};

GroupByHash groupByHash = createGroupByHash(ImmutableList.of(type), new int[] {0}, Optional.of(1), 1, false, JOIN_COMPILER, updateMemory);
Work<?> addPageWork = groupByHash.addPage(page);
assertTrue(addPageWork.process());
}

@Test(dataProvider = "dataType")
public void testMemoryReservationYield(Type type)
{
Expand Down