encode

bitmap in the portable format.

Each container is written in whichever of the three encodings is smallest for it — the same rule rabosh's own format uses, over this format's two-byte-cheaper run container, which is why RoaringPortableFormat.kindFor is a separate function from BitmapFormat.smallestKind. Two consequences worth knowing:

  • the output is canonical, so two bitmaps holding the same ordinals export to identical bytes however they were built, exactly as ReadableBitmap.encode does for rabosh's format;

  • the output is byte-identical to what RoaringBitmap itself writes for the same ordinals after runOptimize(), which the committed conformance fixtures assert rather than assume.

An empty bitmap is eight bytes: the no-run cookie, a zero count and an empty offset header.