Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests and fix for issue #254 (RunContainer.contains(ArrayContainer)) #255

Merged
merged 3 commits into from
Jun 13, 2018

Conversation

sesuncedu
Copy link
Contributor

Legal-Meta - I didn't notice I didn't have sign-off set when I committed the change to the test case, but by signing off on the substantive fix, and by submitting this pull request, it is my express intent to grant any and all rights necessary to incorporate these changes into the existing codebase, and that I am legally entitled to grant such rights under the laws of the United States of America and the State of North Carolina.

/s/ Simon Spero

…map#254

1. Change termination test to ir <runCount from ir <= runCount to avoid index overflow.

2. Change result expresson to ia == arrayContainer.getCardinality().  Previous expression checked for ia <= cardinality (which would always be true), and ir <= runCount (which only worked if there was unused entries at the end of the valuesLength array.

Signed-off-by: Simon Spero <sesuncedu@gmail.com>
@coveralls
Copy link

coveralls commented Jun 12, 2018

Coverage Status

Coverage decreased (-0.007%) to 91.438% when pulling d5c9563 on sesuncedu:RoaringBitmap-254 into 18de8b5 on RoaringBitmap:master.

@@ -808,7 +808,7 @@ protected boolean contains(ArrayContainer arrayContainer) {
return false;
}
int ia = 0, ir = 0;
while(ia < arrayContainer.getCardinality() && ir <= runCount) {
while(ia < arrayContainer.getCardinality() && ir < runCount) {
int start = getValue(ir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is actually yet another error here: this should be

int start = Util.toIntUnsigned(getValue(ir));

@richardstartin
Copy link
Member

Good catch. There is another error in the method you are patching, perhaps you could add that fix in too while you are at it?

@@ -808,7 +808,7 @@ protected boolean contains(ArrayContainer arrayContainer) {
return false;
}
int ia = 0, ir = 0;
while(ia < arrayContainer.getCardinality() && ir <= runCount) {
while(ia < arrayContainer.getCardinality() && ir < runCount) {
int start = getValue(ir);
int stop = start + toIntUnsigned(getLength(ir));
if(arrayContainer.content[ia] < start) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's another one here; we should be storing arrayContainer.content[ia] in an int variable:

int value = Util.toIntUnsigned(arrayContainer.content[ia]);
if (value < start) {
...
} else if (value > stop) {
...```

Signed-off-by: Simon Spero <sesuncedu@gmail.com>
@richardstartin
Copy link
Member

LGTM

@lemire
Copy link
Member

lemire commented Jun 13, 2018

Taking into account @richardstartin 's review... merging...

@lemire lemire merged commit d7eb4de into RoaringBitmap:master Jun 13, 2018
@lemire
Copy link
Member

lemire commented Jun 13, 2018

Smallhi pushed a commit to Smallhi/RoaringBitmap that referenced this pull request Jun 14, 2021
…yContainer)) (RoaringBitmap#255)

* Tests demonstrating RunContainer::contains bug mentioned in issue RoaringBitmap#254

* Fixing Bug in RunContainer::contains as mentioned in issue RoaringBitmap#254

1. Change termination test to ir <runCount from ir <= runCount to avoid index overflow.

2. Change result expresson to ia == arrayContainer.getCardinality().  Previous expression checked for ia <= cardinality (which would always be true), and ir <= runCount (which only worked if there was unused entries at the end of the valuesLength array.

Signed-off-by: Simon Spero <sesuncedu@gmail.com>

* Convert range start and value from array container to unsigned ints.

Signed-off-by: Simon Spero <sesuncedu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants