Remove removes the fact to the backing map.
(a ast.Atom)
| 464 | |
| 465 | // Remove removes the fact to the backing map. |
| 466 | func (s IndexedInMemoryStore) Remove(a ast.Atom) bool { |
| 467 | if a.Predicate.Arity == 0 { |
| 468 | if _, ok := s.constants[a.Predicate]; ok { |
| 469 | delete(s.constants, a.Predicate) |
| 470 | return true |
| 471 | } |
| 472 | return false |
| 473 | } |
| 474 | h := a.Args[0].Hash() |
| 475 | shard, ok := s.shardsByPredicate[a.Predicate] |
| 476 | if !ok { |
| 477 | return false |
| 478 | } |
| 479 | key := a.Hash() |
| 480 | atoms, ok := shard[h] |
| 481 | if !ok { |
| 482 | return false |
| 483 | } |
| 484 | if _, ok := atoms[key]; ok { |
| 485 | delete(atoms, key) |
| 486 | return true |
| 487 | } |
| 488 | return false |
| 489 | } |
| 490 | |
| 491 | // Contains returns true if this store contains this atom already. |
| 492 | func (s IndexedInMemoryStore) Contains(a ast.Atom) bool { |