MCPcopy
hub / github.com/RoaringBitmap/roaring / appenderRoutine

Function appenderRoutine

parallel.go:143–178  ·  view source on GitHub ↗
(bitmapChan chan<- *Bitmap, resultChan <-chan keyedContainer, expectedKeysChan <-chan int)

Source from the content-addressed store, hash-verified

141}
142
143func appenderRoutine(bitmapChan chan<- *Bitmap, resultChan <-chan keyedContainer, expectedKeysChan <-chan int) {
144 expectedKeys := -1
145 appendedKeys := 0
146 var keys []uint16
147 var containers []container
148 for appendedKeys != expectedKeys {
149 select {
150 case item := <-resultChan:
151 if len(keys) <= item.idx {
152 keys = append(keys, make([]uint16, item.idx-len(keys)+1)...)
153 containers = append(containers, make([]container, item.idx-len(containers)+1)...)
154 }
155 keys[item.idx] = item.key
156 containers[item.idx] = item.container
157
158 appendedKeys++
159 case msg := <-expectedKeysChan:
160 expectedKeys = msg
161 }
162 }
163 answer := &Bitmap{
164 roaringArray{
165 make([]uint16, 0, expectedKeys),
166 make([]container, 0, expectedKeys),
167 make([]bool, 0, expectedKeys),
168 false,
169 },
170 }
171 for i := range keys {
172 if containers[i] != nil { // in case a resulting container was empty, see ParAnd function
173 answer.highlowcontainer.appendContainer(keys[i], containers[i], false)
174 }
175 }
176
177 bitmapChan <- answer
178}
179
180// ParHeapOr computes the union (OR) of all provided bitmaps in parallel,
181// where the parameter "parallelism" determines how many workers are to be used

Callers 2

ParHeapOrFunction · 0.85
ParAndFunction · 0.85

Calls 1

appendContainerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…