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

Method Map

worker/restore_map.go:685–714  ·  view source on GitHub ↗

Map reads the backup, converts the keys and values to the required format, and loads them to the given badger DB. The set of predicates is used to avoid restoring values from predicates no longer assigned to this group. If restoreTs is greater than zero, the key-value pairs will be written with that

(r io.Reader, in *loadBackupInput)

Source from the content-addressed store, hash-verified

683// Otherwise, the original value is used.
684// TODO(DGRAPH-1234): Check whether restoreTs can be removed.
685func (m *mapper) Map(r io.Reader, in *loadBackupInput) error {
686 br := bufio.NewReaderSize(r, 16<<10)
687 zbuf := z.NewBuffer(bufSz, "Restore.Map")
688
689 for {
690 var sz uint64
691 err := binary.Read(br, binary.LittleEndian, &sz)
692 if err == io.EOF {
693 break
694 }
695 if err != nil {
696 return err
697 }
698
699 m.szHist.Update(int64(sz))
700 buf := zbuf.SliceAllocate(int(sz))
701 if _, err = io.ReadFull(br, buf); err != nil {
702 return err
703 }
704
705 if zbuf.LenNoPadding() > bufSoftLimit {
706 atomic.AddUint64(&m.bytesRead, uint64(zbuf.LenNoPadding()))
707 glog.Infof("Sending req of size: %s\n", humanize.IBytes(uint64(zbuf.LenNoPadding())))
708 m.reqCh <- listReq{zbuf, in}
709 zbuf = z.NewBuffer(bufSz, "Restore.Map")
710 }
711 }
712 m.reqCh <- listReq{zbuf, in}
713 return nil
714}
715
716type mapResult struct {
717 maxUid uint64

Callers 3

RunMapperFunction · 0.95
stripSpacesFunction · 0.80
FastParseJSONMethod · 0.80

Calls 3

InfofMethod · 0.80
ReadMethod · 0.65
UpdateMethod · 0.45

Tested by

no test coverage detected