MCPcopy
hub / github.com/google/mangle / Add

Method Add

factstore/factstore.go:159–170  ·  view source on GitHub ↗

Add implements the FactStore interface by adding the fact to the backing map.

(a ast.Atom)

Source from the content-addressed store, hash-verified

157
158// Add implements the FactStore interface by adding the fact to the backing map.
159func (s SimpleInMemoryStore) Add(a ast.Atom) bool {
160 key := a.Hash()
161 if atoms, ok := s.shardsByPredicate[a.Predicate]; ok {
162 _, ok := atoms[key]
163 if !ok {
164 atoms[key] = a
165 }
166 return !ok
167 }
168 s.shardsByPredicate[a.Predicate] = map[uint64]ast.Atom{key: a}
169 return true
170}
171
172// Remove removes the fact from the backing map.
173func (s SimpleInMemoryStore) Remove(a ast.Atom) bool {

Callers 15

MergeMethod · 0.95
testStoreFunction · 0.95
TestNewBytesFunction · 0.95
TestGzipFunction · 0.95
TestAddContainsRemoveFunction · 0.95
TestMergedAddContainsFunction · 0.95
TestMergedMergeFunction · 0.95
runEvalFunction · 0.95
TestRewriteIdempotencyFunction · 0.95
TestSimpleEvalFunction · 0.95
TestSimpleEvalDeferFunction · 0.95

Calls 1

HashMethod · 0.65

Tested by 15

testStoreFunction · 0.76
TestNewBytesFunction · 0.76
TestGzipFunction · 0.76
TestAddContainsRemoveFunction · 0.76
TestMergedAddContainsFunction · 0.76
TestMergedMergeFunction · 0.76
runEvalFunction · 0.76
TestRewriteIdempotencyFunction · 0.76
TestSimpleEvalFunction · 0.76
TestSimpleEvalDeferFunction · 0.76
TestManyPathsFunction · 0.76