MCPcopy
hub / github.com/dgraph-io/badger / appendIterators

Method appendIterators

level_handler.go:291–313  ·  view source on GitHub ↗

appendIterators appends iterators to an array of iterators, for merging. Note: This obtains references for the table handlers. Remember to close these iterators.

(iters []y.Iterator, opt *IteratorOptions)

Source from the content-addressed store, hash-verified

289// appendIterators appends iterators to an array of iterators, for merging.
290// Note: This obtains references for the table handlers. Remember to close these iterators.
291func (s *levelHandler) appendIterators(iters []y.Iterator, opt *IteratorOptions) []y.Iterator {
292 s.RLock()
293 defer s.RUnlock()
294
295 if s.level == 0 {
296 // Remember to add in reverse order!
297 // The newer table at the end of s.tables should be added first as it takes precedence.
298 // Level 0 tables are not in key sorted order, so we need to consider them one by one.
299 var out []*table.Table
300 for _, t := range s.tables {
301 if opt.pickTable(t) {
302 out = append(out, t)
303 }
304 }
305 return appendIteratorsReversed(iters, out, opt.Reverse)
306 }
307
308 tables := opt.pickTables(s.tables)
309 if len(tables) == 0 {
310 return iters
311 }
312 return append(iters, table.NewConcatIterator(tables, opt.Reverse))
313}
314
315type levelHandlerRLocked struct{}
316

Callers

nothing calls this directly

Calls 4

NewConcatIteratorFunction · 0.92
appendIteratorsReversedFunction · 0.85
pickTableMethod · 0.80
pickTablesMethod · 0.80

Tested by

no test coverage detected