MCPcopy
hub / github.com/uber/aresdb / CheckAllValid

Method CheckAllValid

memstore/vectors/vector.go:283–310  ·  view source on GitHub ↗

CheckAllValid checks whether all bits are 1 in a bool typed vector.

()

Source from the content-addressed store, hash-verified

281
282// CheckAllValid checks whether all bits are 1 in a bool typed vector.
283func (v *Vector) CheckAllValid() bool {
284 i := 0
285 totalCompleteBytes := v.Size / 8
286 remainingBits := v.Size % 8
287 wordBoundary := totalCompleteBytes - totalCompleteBytes%4
288
289 // First check word by word.
290 for ; i < wordBoundary; i += 4 {
291 if !(*(*uint32)(utils.MemAccess(unsafe.Pointer(v.buffer), i)) == 0xFFFFFFFF) {
292 return false
293 }
294 }
295
296 // then we check byte by byte.
297 for ; i < totalCompleteBytes; i++ {
298 if !(*(*uint8)(utils.MemAccess(unsafe.Pointer(v.buffer), i)) == 0xFF) {
299 return false
300 }
301 }
302
303 if remainingBits == 0 {
304 return true
305 }
306
307 // check remaining bits.
308 var mask uint8 = (1 << uint(remainingBits)) - 1
309 return ((*(*uint8)(utils.MemAccess(unsafe.Pointer(v.buffer), i))) & mask) == mask
310}

Callers 2

JudgeModeMethod · 0.80
vector_test.goFile · 0.80

Calls 1

MemAccessFunction · 0.92

Tested by

no test coverage detected