RoaringBitmap / RoaringBitmap/RoaringBitmap

.map() function

Open
#160 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
3.9k
Forks
592
Avg merge
5d 21h
Merged PRs (30d)
2

Description

I'd like to implement .map(IntToIntFunction f) that returns new RoaringBitmap as a result of mapping.
Example:

RoaringBitmap r1 = RoaringBitmap.bitmapOf(1, 3, 6, 8, 9, 14)
RoaringBitmap r2 = r1.map(i -> (i*7)%13)
r2 // {7, 8, 3, 4, 11}

I would like to gather ideas how to solve problem with performance of inserting new values in non-ordered way.

Currently I can see that using java.util.BitSet as a temporary buffer gives me speed-up 6x. I assume it is because of skipping binary-search part.

public class Main {
  public static void main(String[] args) {
    RoaringBitmap b = new RoaringBitmap();
    Random r = new Random(1333);
    for (int i = 0; i < 120_000_000; i++) {
      b.add(r.nextInt(200_000_000));
    }
    b.runOptimize();

    for (int i = 0; i < 100; i++) { //naive benchmark
      Instant s = Instant.now();
      //RoaringBitmap res = new RoaringBitmap();
      BitSet altRes = new java.util.BitSet(77_333_333);
      b.forEach((IntConsumer) value -> altRes.set((value * 3) % 77_333_333));
      RoaringBitmap altResAsBitmap = BitSetUtil.bitmapOf(altRes);
      Instant e = Instant.now();
      System.out.println("res:" + altResAsBitmap.getCardinality() + " time: " + Duration.between(s, e).toMillis());
    }
  }
}

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 with the proposed RoaringBitmap.map(IntToIntFunction) entry point and review the existing bitmap insertion and iteration APIs. Use the benchmark in the issue to understand the non-ordered insertion concern. Done means an agreed mapping API and implementation strategy with performance and result-cardinality behavior validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.