Add implements the FactStore interface by adding the fact to the backing map.
(a ast.Atom)
| 157 | |
| 158 | // Add implements the FactStore interface by adding the fact to the backing map. |
| 159 | func (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. |
| 173 | func (s SimpleInMemoryStore) Remove(a ast.Atom) bool { |