erigon-pulse/kv/bitmapdb/stream.go

19 lines
618 B
Go
Raw Normal View History

2023-01-12 02:58:17 +00:00
package bitmapdb
import (
"github.com/RoaringBitmap/roaring/roaring64"
)
type BitmapStream struct {
bm *roaring64.Bitmap
it roaring64.IntPeekable64
}
func NewBitmapStream(bm *roaring64.Bitmap) *BitmapStream {
return &BitmapStream{bm: bm, it: bm.Iterator()}
}
func (it *BitmapStream) HasNext() bool { return it.it.HasNext() }
func (it *BitmapStream) Close() { ReturnToPool64(it.bm) }
2023-01-12 02:58:17 +00:00
func (it *BitmapStream) Next() (uint64, error) { return it.it.Next(), nil }
func (it *BitmapStream) ToBitmap() (*roaring64.Bitmap, error) { return it.bm, nil }