File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed
Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -541,28 +541,17 @@ func (ra *roaringArray) fromBuffer(buf []byte) (int64, error) {
541541 pos += 4
542542 var size uint32 // number of containers
543543 haveRunContainers := false
544- var isRun * bitmapContainer
544+ var isRunBitmap [] byte
545545
546546 // cookie header
547547 if cookie & 0x0000FFFF == serialCookie {
548548 haveRunContainers = true
549549 size = uint32 (uint16 (cookie >> 16 ) + 1 ) // number of containers
550550
551551 // create is-run-container bitmap
552- bytesToRead := (int (size ) + 7 ) / 8
553- by := buf [pos : pos + bytesToRead ]
554- pos += bytesToRead
555- isRun = newBitmapContainer ()
556- i := 0
557- for ; len (by ) >= 8 ; i ++ {
558- isRun .bitmap [i ] = binary .LittleEndian .Uint64 (by )
559- by = by [8 :]
560- }
561- if len (by ) > 0 {
562- bx := make ([]byte , 8 )
563- copy (bx , by )
564- isRun .bitmap [i ] = binary .LittleEndian .Uint64 (bx )
565- }
552+ isRunBitmapSize := (int (size ) + 7 ) / 8
553+ isRunBitmap = buf [pos : pos + isRunBitmapSize ]
554+ pos += isRunBitmapSize
566555 } else if cookie == serialCookieNoRunContainer {
567556 size = binary .LittleEndian .Uint32 (buf [pos :])
568557 pos += 4
@@ -590,7 +579,7 @@ func (ra *roaringArray) fromBuffer(buf []byte) (int64, error) {
590579 ra .keys [i ] = key
591580 ra .needCopyOnWrite [i ] = true
592581
593- if haveRunContainers && isRun . contains ( uint16 ( i )) {
582+ if haveRunContainers && isRunBitmap [ i / 8 ] & ( 1 << ( i % 8 )) != 0 {
594583 // run container
595584 nr := binary .LittleEndian .Uint16 (buf [pos :])
596585 pos += 2
You can’t perform that action at this time.
0 commit comments