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

Method SInter

internal/data/set.go:134–147  ·  view source on GitHub ↗

SInter Returns the members of the set resulting from the intersection of all the given sets.

(key1, key2 string)

Source from the content-addressed store, hash-verified

132
133// SInter Returns the members of the set resulting from the intersection of all the given sets.
134func (s *Set) SInter(key1, key2 string) ([]*core.Record, error) {
135 if !s.SHasKey(key1) || !s.SHasKey(key2) {
136 return nil, ErrSetNotExist
137 }
138
139 records := make([]*core.Record, 0)
140
141 for hash, record := range s.M[key1] {
142 if _, ok := s.M[key2][hash]; ok {
143 records = append(records, record)
144 }
145 }
146 return records, nil
147}
148
149// SIsMember Returns if member is a member of the set stored at key.
150func (s *Set) SIsMember(key string, value []byte) (bool, error) {

Callers 1

TestSet_SInterFunction · 0.80

Calls 2

SHasKeyMethod · 0.95
appendFunction · 0.85

Tested by 1

TestSet_SInterFunction · 0.64