MCPcopy
hub / github.com/dropbox/godropbox / readBitArray

Function readBitArray

database/binlog/decoder.go:75–91  ·  view source on GitHub ↗
(bytes []byte, numVals int)

Source from the content-addressed store, hash-verified

73}
74
75func readBitArray(bytes []byte, numVals int) (
76 bits []bool,
77 remaining []byte,
78 err error) {
79
80 bytesUsed := ((numVals + 7) / 8)
81
82 if len(bytes) < bytesUsed {
83 return nil, nil, errors.New("Not enough bytes")
84 }
85
86 bitVector := make([]bool, numVals, numVals)
87 for i := 0; i < numVals; i++ {
88 bitVector[i] = (uint8(bytes[i/8]) & (1 << (uint(i) % 8))) != 0
89 }
90 return bitVector, bytes[bytesUsed:], nil
91}

Callers 3

parseColumnsMethod · 0.85
parseUsedColumnsMethod · 0.85
parseRowMethod · 0.85

Calls 1

NewFunction · 0.92

Tested by

no test coverage detected