MCPcopy
hub / github.com/RoaringBitmap/roaring / ReadFrom

Method ReadFrom

roaring.go:332–346  ·  view source on GitHub ↗

ReadFrom reads a serialized version of this bitmap from stream. E.g., you can use this method to read a serialized bitmap from a file written with the WriteTo method. The format is compatible with other RoaringBitmap implementations (Java, C) and is documented here: https://github.com/RoaringBitmap/

(reader io.Reader, cookieHeader ...byte)

Source from the content-addressed store, hash-verified

330// we add cookieHeader to accept the 4-byte data that has been read in roaring64.ReadFrom.
331// It is not necessary to pass cookieHeader when call roaring.ReadFrom to read the roaring32 data directly.
332func (rb *Bitmap) ReadFrom(reader io.Reader, cookieHeader ...byte) (p int64, err error) {
333 stream, ok := reader.(internal.ByteInput)
334 if !ok {
335 byteInputAdapter := internal.ByteInputAdapterPool.Get().(*internal.ByteInputAdapter)
336 byteInputAdapter.Reset(reader)
337 stream = byteInputAdapter
338 }
339
340 p, err = rb.highlowcontainer.readFrom(stream, cookieHeader...)
341
342 if !ok {
343 internal.ByteInputAdapterPool.Put(stream.(*internal.ByteInputAdapter))
344 }
345 return
346}
347
348// MustReadFrom calls ReadFrom internally.
349// After deserialization Validate will be called.

Calls 2

ResetMethod · 0.45
readFromMethod · 0.45