MCPcopy Create free account
hub / github.com/RoaringBitmap/roaring / BoundSerializedSizeInBytes

Function BoundSerializedSizeInBytes

roaring.go:492–511  ·  view source on GitHub ↗

BoundSerializedSizeInBytes returns an upper bound on the serialized size in bytes assuming that one wants to store "cardinality" integers in [0, universe_size)

(cardinality uint64, universeSize uint64)

Source from the content-addressed store, hash-verified

490// BoundSerializedSizeInBytes returns an upper bound on the serialized size in bytes
491// assuming that one wants to store "cardinality" integers in [0, universe_size)
492func BoundSerializedSizeInBytes(cardinality uint64, universeSize uint64) uint64 {
493 contnbr := (universeSize + uint64(65535)) / uint64(65536)
494 if contnbr > cardinality {
495 contnbr = cardinality
496 // we cannot have more containers than we have values
497 }
498 headermax := 8*contnbr + 4
499 if 4 > (contnbr+7)/8 {
500 headermax += 4
501 } else {
502 headermax += (contnbr + 7) / 8
503 }
504 valsarray := uint64(arrayContainerSizeInBytes(int(cardinality)))
505 valsbitmap := contnbr * uint64(bitmapContainerSizeInBytes())
506 valsbest := valsarray
507 if valsbest > valsbitmap {
508 valsbest = valsbitmap
509 }
510 return valsbest + headermax
511}
512
513// IntIterable allows you to iterate over the values in a Bitmap
514type IntIterable interface {

Callers 1

Calls 2

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…