MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / CompareKeys

Method CompareKeys

channels/timed_set.go:224–248  ·  view source on GitHub ↗

CompareKeys returns sets of added and removed keys between two sets. Elements present in the set but not in the other are returned as 'added'. Elements present in the other set but not in set are returned as 'removed'. of false.

(other TimedSet)

Source from the content-addressed store, hash-verified

222// Elements present in the other set but not in set are returned as 'removed'.
223// of false.
224func (set TimedSet) CompareKeys(other TimedSet) ChangedKeys {
225
226 changed := make(ChangedKeys)
227
228 // Elements in set but not in other
229 for ch := range set {
230 if _, ok := other[ch]; !ok {
231 changed[ch] = true
232 }
233 }
234
235 // If no additions and lengths are the same, then set keys are identical
236 if len(changed) == 0 && len(other) == len(set) {
237 return changed
238 }
239
240 // Elements in other but not in set
241 for ch := range other {
242 if _, ok := set[ch]; !ok {
243 changed[ch] = false
244 }
245 }
246 return changed
247
248}
249
250// TimedSet can unmarshal from either:
251// 1. The regular format {"channel":vbSequence, ...}

Callers 3

TestTimedSetCompareKeysFunction · 0.80
checkForUserUpdatesMethod · 0.80

Calls

no outgoing calls

Tested by 1

TestTimedSetCompareKeysFunction · 0.64