Skip to content

Commit

Permalink
Use io.ReadFull in roaring64.Bitmap.ReadFrom.
Browse files Browse the repository at this point in the history
  • Loading branch information
wjohnson-aurora committed Jan 29, 2024
1 parent 0d5af75 commit 8c5bae9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions roaring64/roaring64.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ func (rb *Bitmap) FromUnsafeBytes(data []byte) (p int64, err error) {
func (rb *Bitmap) ReadFrom(stream io.Reader) (p int64, err error) {
sizeBuf := make([]byte, 8)
var n int
n, err = stream.Read(sizeBuf)
if n == 0 || err != nil {
n, err = io.ReadFull(stream, sizeBuf)
if err != nil {
return int64(n), err
}
p += int64(n)
Expand All @@ -159,8 +159,8 @@ func (rb *Bitmap) ReadFrom(stream io.Reader) (p int64, err error) {
}
keyBuf := sizeBuf[:4]
for i := uint64(0); i < size; i++ {
n, err = stream.Read(keyBuf)
if n == 0 || err != nil {
n, err = io.ReadFull(stream, keyBuf)
if err != nil {
return int64(n), fmt.Errorf("error in bitmap.readFrom: could not read key #%d: %s", i, err)
}
p += int64(n)
Expand Down

0 comments on commit 8c5bae9

Please sign in to comment.