MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / SUnion

Method SUnion

internal/data/set.go:242–260  ·  view source on GitHub ↗

SUnion returns the members of the set resulting from the union of all the given sets.

(key1, key2 string)

Source from the content-addressed store, hash-verified

240
241// SUnion returns the members of the set resulting from the union of all the given sets.
242func (s *Set) SUnion(key1, key2 string) ([]*core.Record, error) {
243 if !s.SHasKey(key1) || !s.SHasKey(key2) {
244 return nil, ErrSetNotExist
245 }
246
247 records, err := s.SMembers(key1)
248
249 if err != nil {
250 return nil, err
251 }
252
253 for hash, record := range s.M[key2] {
254 if _, ok := s.M[key1][hash]; !ok {
255 records = append(records, record)
256 }
257 }
258
259 return records, nil
260}

Callers 2

SUnionByOneBucketMethod · 0.80
TestSet_SUnionFunction · 0.80

Calls 3

SHasKeyMethod · 0.95
SMembersMethod · 0.95
appendFunction · 0.85

Tested by 1

TestSet_SUnionFunction · 0.64