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

Function history

dgraph/cmd/debug/run.go:365–425  ·  view source on GitHub ↗
(lookup []byte, itr *badger.Iterator)

Source from the content-addressed store, hash-verified

363}
364
365func history(lookup []byte, itr *badger.Iterator) {
366 var buf bytes.Buffer
367 pk, err := x.Parse(lookup)
368 x.Check(err)
369 fmt.Fprintf(&buf, "==> key: %x. PK: %+v\n", lookup, pk)
370 for ; itr.Valid(); itr.Next() {
371 item := itr.Item()
372 if !bytes.Equal(item.Key(), lookup) {
373 break
374 }
375
376 fmt.Fprintf(&buf, "ts: %d", item.Version())
377 x.Check2(buf.WriteString(" {item}"))
378 if item.IsDeletedOrExpired() {
379 x.Check2(buf.WriteString("{deleted}"))
380 }
381 if item.DiscardEarlierVersions() {
382 x.Check2(buf.WriteString("{discard}"))
383 }
384 val, err := item.ValueCopy(nil)
385 x.Check(err)
386
387 meta := item.UserMeta()
388 if meta&posting.BitCompletePosting > 0 {
389 x.Check2(buf.WriteString("{complete}"))
390 }
391 if meta&posting.BitDeltaPosting > 0 {
392 x.Check2(buf.WriteString("{delta}"))
393 }
394 if meta&posting.BitEmptyPosting > 0 {
395 x.Check2(buf.WriteString("{empty}"))
396 }
397 fmt.Fprintln(&buf)
398 if meta&posting.BitDeltaPosting > 0 {
399 plist := &pb.PostingList{}
400 x.Check(proto.Unmarshal(val, plist))
401 for _, p := range plist.Postings {
402 appendPosting(&buf, p)
403 }
404 }
405 if meta&posting.BitCompletePosting > 0 {
406 var plist pb.PostingList
407 x.Check(proto.Unmarshal(val, &plist))
408
409 for _, p := range plist.Postings {
410 appendPosting(&buf, p)
411 }
412
413 fmt.Fprintf(&buf, " Num uids = %d. Size = %d\n",
414 codec.ExactLen(plist.Pack), proto.Size(plist.Pack))
415 dec := codec.Decoder{Pack: plist.Pack}
416 for uids := dec.Seek(0, codec.SeekStart); len(uids) > 0; uids = dec.Next() {
417 for _, uid := range uids {
418 fmt.Fprintf(&buf, " Uid = %d\n", uid)
419 }
420 }
421 }
422 x.Check2(buf.WriteString("\n"))

Callers 1

lookupFunction · 0.85

Calls 13

SeekMethod · 0.95
NextMethod · 0.95
ParseFunction · 0.92
CheckFunction · 0.92
Check2Function · 0.92
ExactLenFunction · 0.92
appendPostingFunction · 0.85
ValidMethod · 0.80
ItemMethod · 0.80
NextMethod · 0.45
KeyMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected