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

Method KeySplits

db.go:1369–1381  ·  view source on GitHub ↗

KeySplits can be used to get rough key ranges to divide up iteration over the DB.

(prefix []byte)

Source from the content-addressed store, hash-verified

1367// KeySplits can be used to get rough key ranges to divide up iteration over
1368// the DB.
1369func (db *DB) KeySplits(prefix []byte) []string {
1370 var splits []string
1371 // We just want table ranges here and not keys count.
1372 for _, ti := range db.Tables(false) {
1373 // We don't use ti.Left, because that has a tendency to store !badger
1374 // keys.
1375 if bytes.HasPrefix(ti.Right, prefix) {
1376 splits = append(splits, string(ti.Right))
1377 }
1378 }
1379 sort.Strings(splits)
1380 return splits
1381}
1382
1383// MaxBatchCount returns max possible entries in batch
1384func (db *DB) MaxBatchCount() int64 {

Callers 2

produceRangesMethod · 0.80

Calls 1

TablesMethod · 0.95

Tested by 1