-
Notifications
You must be signed in to change notification settings - Fork 540
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
Conversation
…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>
@@ -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); |
There was a problem hiding this comment.
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));
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) { |
There was a problem hiding this comment.
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>
LGTM |
Taking into account @richardstartin 's review... merging... |
…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>
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