github.com/parquet-go/parquet-go@v0.21.1-0.20240501160520-b3c3a0c3ed6f/sparse/gather_purego.go (about) 1 //go:build purego || !amd64 2 3 package sparse 4 5 func gatherBits(dst []byte, src Uint8Array) int { 6 n := min(len(dst)*8, src.Len()) 7 i := 0 8 9 if k := (n / 8) * 8; k > 0 { 10 for j := 0; i < k; j++ { 11 b0 := src.Index(i + 0) 12 b1 := src.Index(i + 1) 13 b2 := src.Index(i + 2) 14 b3 := src.Index(i + 3) 15 b4 := src.Index(i + 4) 16 b5 := src.Index(i + 5) 17 b6 := src.Index(i + 6) 18 b7 := src.Index(i + 7) 19 20 dst[j] = (b0 & 1) | 21 ((b1 & 1) << 1) | 22 ((b2 & 1) << 2) | 23 ((b3 & 1) << 3) | 24 ((b4 & 1) << 4) | 25 ((b5 & 1) << 5) | 26 ((b6 & 1) << 6) | 27 ((b7 & 1) << 7) 28 29 i += 8 30 } 31 } 32 33 for i < n { 34 x := i / 8 35 y := i % 8 36 b := src.Index(i) 37 dst[x] = ((b & 1) << y) | (dst[x] & ^(1 << y)) 38 i++ 39 } 40 41 return n 42 } 43 44 func gather32(dst []uint32, src Uint32Array) int { 45 n := min(len(dst), src.Len()) 46 47 for i := range dst[:n] { 48 dst[i] = src.Index(i) 49 } 50 51 return n 52 } 53 54 func gather64(dst []uint64, src Uint64Array) int { 55 n := min(len(dst), src.Len()) 56 57 for i := range dst[:n] { 58 dst[i] = src.Index(i) 59 } 60 61 return n 62 } 63 64 func gather128(dst [][16]byte, src Uint128Array) int { 65 n := min(len(dst), src.Len()) 66 67 for i := range dst[:n] { 68 dst[i] = src.Index(i) 69 } 70 71 return n 72 }