(lookup []byte, itr *badger.Iterator)
| 363 | } |
| 364 | |
| 365 | func 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")) |
no test coverage detected