MCPcopy
hub / github.com/dgraph-io/dgraph / rollupKey

Function rollupKey

dgraph/cmd/debug/run.go:445–482  ·  view source on GitHub ↗
(db *badger.DB)

Source from the content-addressed store, hash-verified

443 fmt.Fprintln(w, "")
444}
445func rollupKey(db *badger.DB) {
446 txn := db.NewTransactionAt(opt.readTs, false)
447 defer txn.Discard()
448
449 key, err := hex.DecodeString(opt.rollupKey)
450 x.Check(err)
451
452 iopts := badger.DefaultIteratorOptions
453 iopts.AllVersions = true
454 iopts.PrefetchValues = false
455 itr := txn.NewKeyIterator(key, iopts)
456 defer itr.Close()
457
458 itr.Rewind()
459 if !itr.Valid() {
460 log.Fatalf("Unable to seek to key: %s", hex.Dump(key))
461 }
462
463 item := itr.Item()
464 // Don't need to do anything if the bitdelta is not set.
465 if item.UserMeta()&posting.BitDeltaPosting == 0 {
466 fmt.Printf("First item has UserMeta:[b%04b]. Nothing to do\n", item.UserMeta())
467 return
468 }
469 pl, err := posting.ReadPostingList(item.KeyCopy(nil), itr)
470 x.Check(err)
471
472 alloc := z.NewAllocator(32<<20, "Debug.RollupKey")
473 defer alloc.Release()
474
475 // Setting kvs at their original value as we can't give a new timestamp in debug mode.
476 kvs, err := pl.Rollup(alloc, math.MaxUint64)
477 x.Check(err)
478
479 wb := db.NewManagedWriteBatch()
480 x.Check(wb.WriteList(&bpb.KVList{Kv: kvs}))
481 x.Check(wb.Flush())
482}
483
484func lookup(db *badger.DB) {
485 txn := db.NewTransactionAt(opt.readTs, false)

Callers 1

runFunction · 0.85

Calls 9

CheckFunction · 0.92
ReadPostingListFunction · 0.92
ValidMethod · 0.80
FatalfMethod · 0.80
ItemMethod · 0.80
ReleaseMethod · 0.80
RollupMethod · 0.80
CloseMethod · 0.65
FlushMethod · 0.65

Tested by

no test coverage detected