github.com/parquet-go/parquet-go@v0.21.1-0.20240501160520-b3c3a0c3ed6f/internal/bitpack/unpack_int64_purego.go (about) 1 //go:build purego || !amd64 2 3 package bitpack 4 5 import "github.com/parquet-go/parquet-go/internal/unsafecast" 6 7 func unpackInt64(dst []int64, src []byte, bitWidth uint) { 8 bits := unsafecast.BytesToUint32(src) 9 bitMask := uint64(1<<bitWidth) - 1 10 bitOffset := uint(0) 11 12 for n := range dst { 13 i := bitOffset / 32 14 j := bitOffset % 32 15 d := (uint64(bits[i]) & (bitMask << j)) >> j 16 if j+bitWidth > 32 { 17 k := 32 - j 18 d |= (uint64(bits[i+1]) & (bitMask >> k)) << k 19 if j+bitWidth > 64 { 20 k := 64 - j 21 d |= (uint64(bits[i+2]) & (bitMask >> k)) << k 22 } 23 } 24 dst[n] = int64(d) 25 bitOffset += bitWidth 26 } 27 }