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

  1. Pass a RoaringBitmapData (construct via fromArray, fromBytes, or new RoaringBitmapData) instead of a custom Bitmap implementation.
  2. 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.
  3. 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

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


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/4fce595ce4bb8d81. Report an issue: GitHub.