MCPcopy Index your code
hub / github.com/RoaringBitmap/roaring / iorArray

Method iorArray

arraycontainer.go:388–419  ·  view source on GitHub ↗
(value2 *arrayContainer)

Source from the content-addressed store, hash-verified

386}
387
388func (ac *arrayContainer) iorArray(value2 *arrayContainer) container {
389 value1 := ac
390 len1 := value1.getCardinality()
391 len2 := value2.getCardinality()
392 maxPossibleCardinality := len1 + len2
393 if maxPossibleCardinality > cap(value1.content) {
394 // doubling the capacity reduces new slice allocations in the case of
395 // repeated calls to iorArray().
396 newSize := 2 * maxPossibleCardinality
397 // the second check is to handle overly large array containers
398 // and should not occur in normal usage,
399 // as all array containers should be at most arrayDefaultMaxSize
400 if newSize > 2*arrayDefaultMaxSize && maxPossibleCardinality <= 2*arrayDefaultMaxSize {
401 newSize = 2 * arrayDefaultMaxSize
402 }
403 newcontent := make([]uint16, 0, newSize)
404 copy(newcontent[len2:maxPossibleCardinality], ac.content[0:len1])
405 ac.content = newcontent
406 } else {
407 copy(ac.content[len2:maxPossibleCardinality], ac.content[0:len1])
408 }
409 nl := union2by2(value1.content[len2:maxPossibleCardinality], value2.content, ac.content)
410 ac.content = ac.content[:nl] // reslice to match actual used capacity
411
412 if nl > arrayDefaultMaxSize {
413 // Only converting to a bitmap when arrayDefaultMaxSize
414 // is actually exceeded minimizes conversions in the case of repeated
415 // calls to iorArray().
416 return ac.toBitmapContainer()
417 }
418 return ac
419}
420
421// Note: such code does not make practical sense, except for lazy evaluations
422func (ac *arrayContainer) iorBitmap(bc2 *bitmapContainer) container {

Callers 2

iorMethod · 0.95
lazyIorArrayMethod · 0.95

Calls 3

toBitmapContainerMethod · 0.95
union2by2Function · 0.70
getCardinalityMethod · 0.65

Tested by

no test coverage detected