MCPcopy Create free account
hub / github.com/RoaringBitmap/roaring / iorOnRange

Function iorOnRange

roaring64/parallel64.go:236–297  ·  view source on GitHub ↗
(ra1, ra2 *roaringArray64, start, last uint32)

Source from the content-addressed store, hash-verified

234}
235
236func iorOnRange(ra1, ra2 *roaringArray64, start, last uint32) *roaringArray64 {
237 length1 := ra1.size()
238 length2 := ra2.size()
239
240 idx1 := 0
241 idx2 := parNaiveStartAt(ra2, start, last)
242
243 var key1 uint32
244 var key2 uint32
245 if idx1 < length1 && idx2 < length2 {
246 key1 = ra1.getKeyAtIndex(idx1)
247 key2 = ra2.getKeyAtIndex(idx2)
248
249 for key1 <= last && key2 <= last {
250 if key1 < key2 {
251 idx1++
252 if idx1 >= length1 {
253 break
254 }
255 key1 = ra1.getKeyAtIndex(idx1)
256 } else if key1 > key2 {
257 ra1.insertNewKeyValueAt(idx1, key2, ra2.getContainerAtIndex(idx2))
258 ra1.needCopyOnWrite[idx1] = true
259 idx2++
260 idx1++
261 length1++
262 if idx2 >= length2 {
263 break
264 }
265 key2 = ra2.getKeyAtIndex(idx2)
266 } else {
267 c1 := ra1.getWritableContainerAtIndex(idx1)
268
269 // ra1.containers[idx1] = c1.lazyIOR(ra2.getContainerAtIndex(idx2))
270 c1.Or(ra2.getContainerAtIndex(idx2))
271 ra1.setContainerAtIndex(idx1, c1)
272
273 ra1.needCopyOnWrite[idx1] = false
274 idx1++
275 idx2++
276 if idx1 >= length1 || idx2 >= length2 {
277 break
278 }
279
280 key1 = ra1.getKeyAtIndex(idx1)
281 key2 = ra2.getKeyAtIndex(idx2)
282 }
283 }
284 }
285 if idx2 < length2 {
286 key2 = ra2.getKeyAtIndex(idx2)
287 for key2 <= last {
288 ra1.appendCopy(*ra2, idx2)
289 idx2++
290 if idx2 >= length2 {
291 break
292 }
293 key2 = ra2.getKeyAtIndex(idx2)

Callers 1

ParOrFunction · 0.85

Calls 9

parNaiveStartAtFunction · 0.70
sizeMethod · 0.45
getKeyAtIndexMethod · 0.45
insertNewKeyValueAtMethod · 0.45
getContainerAtIndexMethod · 0.45
OrMethod · 0.45
setContainerAtIndexMethod · 0.45
appendCopyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…