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

Function printKeys

dgraph/cmd/debug/run.go:551–687  ·  view source on GitHub ↗

Current format is like: {i} attr: name term: [8] woods ts: 535 item: [28, b0100] sz: 81 dcnt: 3 key: 00000...6f6f6473 Fix the TestBulkLoadMultiShard accordingly, if the format changes.

(db *badger.DB)

Source from the content-addressed store, hash-verified

549// {i} attr: name term: [8] woods ts: 535 item: [28, b0100] sz: 81 dcnt: 3 key: 00000...6f6f6473
550// Fix the TestBulkLoadMultiShard accordingly, if the format changes.
551func printKeys(db *badger.DB) {
552 var prefix []byte
553 if len(opt.predicate) > 0 {
554 prefix = x.PredicatePrefix(opt.predicate)
555 } else if len(opt.prefix) > 0 {
556 p, err := hex.DecodeString(opt.prefix)
557 x.Check(err)
558 prefix = p
559 }
560 fmt.Printf("prefix = %s\n", hex.Dump(prefix))
561 stream := db.NewStreamAt(opt.readTs)
562 stream.Prefix = prefix
563 var total uint64
564 stream.KeyToList = func(key []byte, itr *badger.Iterator) (*bpb.KVList, error) {
565 item := itr.Item()
566 pk, err := x.Parse(key)
567 x.Check(err)
568
569 var buf bytes.Buffer
570 // Don't use a switch case here. Because multiple of these can be true. In particular,
571 // IsSchema can be true alongside IsData.
572 if pk.IsData() {
573 x.Check2(buf.WriteString("{d}"))
574 }
575 if pk.IsIndex() {
576 x.Check2(buf.WriteString("{i}"))
577 }
578 if pk.IsCountOrCountRev() {
579 x.Check2(buf.WriteString("{c}"))
580 }
581 if pk.IsSchema() {
582 x.Check2(buf.WriteString("{s}"))
583 }
584 if pk.IsReverse() {
585 x.Check2(buf.WriteString("{r}"))
586 }
587 ns, attr := x.ParseNamespaceAttr(pk.Attr)
588 x.Check2(buf.WriteString(fmt.Sprintf(" ns: %#x ", ns)))
589 x.Check2(buf.WriteString(" attr: " + attr))
590 if len(pk.Term) > 0 {
591 fmt.Fprintf(&buf, " term: [%d] [%v] ", pk.Term[0], pk.Term[1:])
592 }
593 if pk.Uid > 0 {
594 fmt.Fprintf(&buf, " uid: %d ", pk.Uid)
595 }
596 if pk.StartUid > 0 {
597 fmt.Fprintf(&buf, " startUid: %d ", pk.StartUid)
598 }
599
600 if opt.itemMeta {
601 fmt.Fprintf(&buf, " ts: %d", item.Version())
602 fmt.Fprintf(&buf, " item: [%d, b%04b]", item.EstimatedSize(), item.UserMeta())
603 }
604
605 var sz, deltaCount int64
606 pl, err := posting.GetNew(key, db, opt.readTs, false)
607 if err == nil {
608 pl.RLock()

Callers 1

runFunction · 0.85

Calls 15

PredicatePrefixFunction · 0.92
CheckFunction · 0.92
ParseFunction · 0.92
Check2Function · 0.92
ParseNamespaceAttrFunction · 0.92
GetNewFunction · 0.92
ItemMethod · 0.80
IsDataMethod · 0.80
IsIndexMethod · 0.80
IsCountOrCountRevMethod · 0.80
IsSchemaMethod · 0.80
IsReverseMethod · 0.80

Tested by

no test coverage detected