MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / removeDuplicates

Function removeDuplicates

worker/sort.go:726–738  ·  view source on GitHub ↗

removeDuplicates removes elements from uids if they are in set. It also adds all uids to set.

(uids []uint64, set map[uint64]struct{})

Source from the content-addressed store, hash-verified

724// removeDuplicates removes elements from uids if they are in set. It also adds
725// all uids to set.
726func removeDuplicates(uids []uint64, set map[uint64]struct{}) []uint64 {
727 for i := 0; i < len(uids); i++ {
728 uid := uids[i]
729 if _, ok := set[uid]; ok {
730 copy(uids[i:], uids[i+1:])
731 uids = uids[:len(uids)-1]
732 i-- // we just removed an entry, so go back one step
733 } else {
734 set[uid] = struct{}{}
735 }
736 }
737 return uids
738}
739
740func paginate(ts *pb.SortMessage, dest *pb.List, vals []types.Val) (int, int, error) {
741 count := int(ts.Count)

Callers 2

intersectBucketFunction · 0.85
TestRemoveDuplicatesFunction · 0.85

Calls 1

copyFunction · 0.85

Tested by 1

TestRemoveDuplicatesFunction · 0.68