Remove implementation for FactStoreWithRemove.
(a ast.Atom)
| 636 | |
| 637 | // Remove implementation for FactStoreWithRemove. |
| 638 | func (s MultiIndexedInMemoryStore) Remove(a ast.Atom) bool { |
| 639 | if a.Predicate.Arity == 0 { |
| 640 | if _, ok := s.constants[a.Predicate]; ok { |
| 641 | delete(s.constants, a.Predicate) |
| 642 | return true |
| 643 | } |
| 644 | return false |
| 645 | } |
| 646 | aHash := a.Hash() |
| 647 | shard, ok := s.shardsByPredicate[a.Predicate] |
| 648 | if !ok { |
| 649 | return false |
| 650 | } |
| 651 | removed := false |
| 652 | for i := 0; i < a.Predicate.Arity; i++ { |
| 653 | iHash := a.Args[i].Hash() |
| 654 | params, ok := shard[uint16(i)] |
| 655 | if !ok { |
| 656 | return false |
| 657 | } |
| 658 | atoms, ok := params[iHash] |
| 659 | if !ok { |
| 660 | return false |
| 661 | } |
| 662 | if _, ok := atoms[aHash]; ok { |
| 663 | delete(atoms, aHash) |
| 664 | removed = true |
| 665 | } |
| 666 | } |
| 667 | return removed |
| 668 | } |
| 669 | |
| 670 | // Contains returns true if this store contains this atom already. |
| 671 | func (s MultiIndexedInMemoryStore) Contains(a ast.Atom) bool { |