Skip to content

Commit

Permalink
Fix bounds check in MultiChannelGroupByHash and BigintGroupByHash
Browse files Browse the repository at this point in the history
There's an off-by-one error in the check that
can cause a failure when the page is empty
  • Loading branch information
sopel39 committed May 31, 2022
1 parent f023b29 commit d9bb461
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,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");
int remainingPositions = positionCount - lastPosition;

while (remainingPositions != 0) {
Expand Down Expand Up @@ -437,7 +437,7 @@ public AddDictionaryPageWork(DictionaryBlock 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 @@ -524,7 +524,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);

int remainingPositions = positionCount - lastPosition;
Expand Down Expand Up @@ -581,7 +581,7 @@ public GetDictionaryGroupIdsWork(DictionaryBlock 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 @@ -591,7 +591,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");
int remainingPositions = positionCount - lastPosition;

while (remainingPositions != 0) {
Expand Down Expand Up @@ -641,7 +641,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 @@ -777,7 +777,7 @@ public GetNonDictionaryGroupIdsWork(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);

int remainingPositions = positionCount - lastPosition;
Expand Down Expand Up @@ -899,7 +899,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

0 comments on commit d9bb461

Please sign in to comment.