intersect method throws ArrayIndexOutOfBoundsException after serialize/deserialize
shanielh opened this issue · comments
Describe the bug
intersect
method on Mutable/Immutable
Roaring Bitmap throws ArrayIndexOutOfBoundsException
after serialization / deserialization.
To Reproduce
import java.io.*;
import org.roaringbitmap.RoaringBitmap;
import org.roaringbitmap.MutableRoaringBitmap
public class Main {
public static void main(String[] args) throws IOException {
MutableRoaringBitmap source = MutableRoaringBitmap.bitmapOf(25286760);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
source.serialize(new DataOutputStream(outputStream));
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
MutableRoaringBitmap test = new MutableRoaringBitmap();
test.deserialize(new DataInputStream(inputStream));
test.intersects(26244001, 27293761);
}
}
edit: Seems like the difference between the objects is that the source
has 4 elements in each array (keys
and values
inside highLowContainer
) while the test
has only one element in each array, so it's probably related to the deserialization method not using the extendArray
method.
edit a workaround for now would be to call the flip
method on some value twice.
If you fail to provide the necessary information for us to reproduce the issue, we may reject your bug report.
RoaringBitmap version: Latest (0.9.49-SNAPSHOT
)
Java version: Temurin-11.0.17+8 (aarch64)
Thanks for the report and the test case. I can take a look at this today.
Thanks for the report and the test case. I can take a look at this today.
Just pushed a PR 😄
Consider upgrading to the latest version where the bug fix now appears.