roaring bitmap in Go consumes storage in bytes rather than in bits, am I wrong?

30 views
Skip to first unread message

Tao Tse

unread,
Sep 26, 2020, 11:03:00 PM9/26/20
to Roaring Bitmaps
Hi,
I'm new to Go, and searching for a efficient bitmap implementation, https://pkg.go.dev/github.com/pilosa/pilosa/roaring comes popular choice. Then I tried it.

    buf1 := new(bytes.Buffer)
    buf2 := new(bytes.Buffer)
    rb1 := bm.NewBitmap()
    for i := 1; i < 5000; i++ {
        rb1.Add(uint64(rand.Intn(5000)))
    }
    rb1.WriteTo(buf1)
    fmt.Println("buf1 len:", buf1.Len())
    rb2 := bm.NewBitmap()
    for i := 1; i < 1000; i++ {
        rb2.Add(uint64(rand.Intn(1000)))
    }
    rb2.WriteTo(buf2)
    fmt.Println("buf2 len:", buf2.Len())

it prints:
buf1 len: 4766
buf2 len: 1002

Why it consumes storage in bytes rather than in bits?
Is there anything I missed?

--
xtao

Daniel Lemire

unread,
Sep 27, 2020, 11:12:49 AM9/27/20
to Tao Tse, Roaring Bitmaps
If you have some questions regarding Pilosa' roaring implementation and its usage, you probably should open an issue at github.com/pilosa/roaring.

--


You received this message because you are subscribed to the Google Groups "Roaring Bitmaps" group.


To unsubscribe from this group and stop receiving emails from it, send an email to roaring-bitma...@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/roaring-bitmaps/9708b601-1435-48a4-a44a-629e1a33d5dfn%40googlegroups.com.


Reply all
Reply to author
Forward
0 new messages