-
Notifications
You must be signed in to change notification settings - Fork 582
Open
Labels
Description
Describe the bug
version(dependency in maven):
<dependency>
<groupId>org.roaringbitmap</groupId>
<artifactId>RoaringBitmap</artifactId>
<version>0.9.0</version>
</dependency>
host info: MACOS
Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Hardware:
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro16,1
Processor Name: 6-Core Intel Core i7
Processor Speed: 2.6 GHz
Number of Processors: 1
Total Number of Cores: 6
L2 Cache (per Core): 256 KB
L3 Cache: 12 MB
Hyper-Threading Technology: Enabled
Memory: 16 GB
System Firmware Version: 2069.0.0.0.0 (iBridge: 22.16.10353.0.0,0)
OS Loader Version: 582~1023
Serial Number (system): C02FX0LXMD6P
Hardware UUID: 14595071-B989-589D-BBC2-53D6136C660C
Provisioning UDID: 14595071-B989-589D-BBC2-53D6136C660C
Activation Lock Status: Disabled
To Reproduce
If it is a bug you encountered while working with the library, you should produce a code sample that allows us to reproduce the problem. Your code should be complete and immediately executable:
For example, this is a good example:
import org.roaringbitmap.BitmapDataProvider;
import org.roaringbitmap.longlong.Roaring64Bitmap;
import org.roaringbitmap.longlong.Roaring64NavigableMap;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.NavigableMap;
import java.util.concurrent.*;
public class RoaringBitmapConcurrentTest {
private final Roaring64NavigableMap bitmap;
private final ExecutorService executor;
public RoaringBitmapConcurrentTest() {
this.bitmap = new Roaring64NavigableMap();
this.executor = Executors.newFixedThreadPool(1000);
}
public void testConcurrentIsEmpty() throws InterruptedException {
bitmap.add(170L);
// ...
List<Callable<Boolean>> tasks = new ArrayList<>();
for (int i = 0; i < 50000; i++) {
tasks.add(() -> {
int j = 0;
boolean empty = false;
try {
bitmap.isEmpty();
while (j < 500) {
bitmap.isEmpty();
j++;
}
} catch (Exception e) {
Field field = Roaring64NavigableMap.class.getDeclaredField("sortedCumulatedCardinality");
field.setAccessible(true);
long[] cumulatedCardinalities = (long[]) field.get(bitmap);
System.out.println("Cumulated cardinalities array length: " + cumulatedCardinalities.length);
System.out.println(bitmap.getLongSizeInBytes());
throw e;
}
//System.out.println(Thread.currentThread().getName() + ": isEmpty = " + empty);
return empty;
});
}
List<Future<Boolean>> futures = executor.invokeAll(tasks);
for (Future<Boolean> future : futures) {
try {
future.get();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
executor.shutdown();
}
public static void main(String[] args) throws InterruptedException {
RoaringBitmapConcurrentTest test = new RoaringBitmapConcurrentTest();
test.testConcurrentIsEmpty();
}
}excute code above 10-20 times and you can reproduce error below

RoaringBitmap version:
0.9.0
stable version use in many projects
Java version:
java 1.8
Please tell us which Java version you are using.
Reactions are currently unavailable