RoaringBitmap / RoaringBitmap/roaring

Iterate over bit ranges

Open
#491 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.9k
Forks
262
Avg merge
2h 34m
Merged PRs (30d)
8

Description

Sometimes we want to find the ranges of 1 bits, and there's no obviously efficient way to do that currently.
(Maybe I'm missing something!).

If #22 was implemented, then we could do it without allocation, but currently
the only way I can think of doing it with reasonable efficiency (avoiding O(nbits)
complexity I think) is by using Flip and two iterators.

Providing a way to iterator over the unset bits or providing a way to iterate
over the bit-ranges would make this more efficient and/or convenient.

Something like this, perhaps:

// Ranges returns an iterator over all the [start, end)
// ranges of 1-bits in b.
func (b *Bitmap) Ranges() iter.Seq2[uint64, uint64]

Given that, it's trivial to write a function to iterate over the inverted bits.

PoC of the range functions using Flip: https://go.dev/play/p/Ss3T8NCDdJ0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing Bitmap and Flip behavior, then run the linked Go playground proof of concept to understand the proposed range iteration. Define completion as an iterator that yields each [start, end) range of 1-bits and supports the stated inverted-bit use case without relying on an O(nbits) scan.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.