apache/flink · error · IllegalArgumentException
Unsupported bitmap type: %s.
Error message
Unsupported bitmap type: %s.
What it means
Thrown by RoaringBitmapData.toRoaringBitmapData(Bitmap) when the passed Bitmap is not a RoaringBitmapData instance. The method is an identity-ish cast helper: it only accepts the RoaringBitmapData implementation of the Bitmap interface, and any other implementation (e.g. a future BashBitmap-style type or a user-defined Bitmap) is rejected with the concrete class name in the message.
Source
Thrown at flink-core/src/main/java/org/apache/flink/types/bitmap/RoaringBitmapData.java:82
throws DeserializationException {
RoaringBitmapData rb32 = new RoaringBitmapData();
try {
rb32.roaringBitmap.deserialize(ByteBuffer.wrap(bytes));
} catch (Exception e) {
throw new DeserializationException("Failed to deserialize bitmap from bytes.", e);
}
return rb32;
}
public static RoaringBitmapData fromArray(@Nonnull int[] values) {
RoaringBitmapData rb32 = new RoaringBitmapData();
rb32.roaringBitmap.add(values);
return rb32;
}
public static RoaringBitmapData toRoaringBitmapData(Bitmap bm) throws IllegalArgumentException {
if (!(bm instanceof RoaringBitmapData)) {
throw new IllegalArgumentException("Unsupported bitmap type: " + bm.getClass() + ".");
}
return (RoaringBitmapData) bm;
}
// ~ Bitmap Interface Implementations ------------------------------------------------
@Override
public void add(int value) {
roaringBitmap.add(value);
}
/**
* @throws IllegalArgumentException if rangeStart or rangeEnd is out of range.
*/
@Override
public void add(long rangeStart, long rangeEnd) throws IllegalArgumentException {
roaringBitmap.add(rangeStart, rangeEnd);
}View on GitHub (pinned to 2f3c205e92)
Solutions
- Pass a RoaringBitmapData (construct via fromArray, fromBytes, or new RoaringBitmapData) instead of a custom Bitmap implementation.
- If you own a custom Bitmap type, convert its contents into a RoaringBitmapData (e.g. iterate set values and add them) before calling this API.
- In tests, build real RoaringBitmapData instances rather than mocking the Bitmap interface.
Example fix
// before
Bitmap custom = new MyCustomBitmap();
RoaringBitmapData rb = RoaringBitmapData.from(custom); // throws
// after
RoaringBitmapData rb = new RoaringBitmapData();
for (int v : customValues) {
rb.add(v);
} Defensive patterns
Strategy: type-guard
Validate before calling
if (!(bitmap instanceof RoaringBitmapData)) {
throw new IllegalArgumentException("Unsupported bitmap type: " + bitmap.getClass());
} Type guard
static boolean isRoaringBitmapData(Bitmap bm) {
return bm instanceof RoaringBitmapData;
} Prevention
- Type-check Bitmap inputs before conversion APIs when implementations may vary.
- Keep Bitmap-typed APIs backed exclusively by RoaringBitmapData unless you add converters.
- Avoid mocking the Bitmap interface in tests; build real instances.
When it happens
Trigger: Calling toRoaringBitmapData(other) or the from(Bitmap) factory with a Bitmap implementation that is not RoaringBitmapData — user-defined Bitmap subclasses, mocks in tests, or new Bitmap implementations added to the codebase.
Common situations: Custom Bitmap implementations passed into code paths that only support RoaringBitmapData (the sole in-tree implementation); test doubles implementing Bitmap; adding a new bitmap type without updating conversion call sites.
Related errors
- Failed to deserialize bitmap from bytes.
- The runtime context has not been initialized yet. Try access
- The broadcast input name may not be null.
- The broadcast input root operator may not be null.
- Cannot execute operator {}
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/4fce595ce4bb8d81.
Report an issue: GitHub.