Contains returns true if this store contains this atom already.
(a ast.Atom)
| 669 | |
| 670 | // Contains returns true if this store contains this atom already. |
| 671 | func (s MultiIndexedInMemoryStore) Contains(a ast.Atom) bool { |
| 672 | if a.Predicate.Arity == 0 { |
| 673 | _, ok := s.constants[a.Predicate] |
| 674 | return ok |
| 675 | } |
| 676 | shard, ok := s.shardsByPredicate[a.Predicate] |
| 677 | if !ok { |
| 678 | return false |
| 679 | } |
| 680 | params, ok := shard[0] |
| 681 | if !ok { |
| 682 | return false |
| 683 | } |
| 684 | h := a.Args[0].Hash() |
| 685 | atoms, ok := params[h] |
| 686 | if !ok { |
| 687 | return false |
| 688 | } |
| 689 | _, exists := atoms[a.Hash()] |
| 690 | return exists |
| 691 | } |
| 692 | |
| 693 | // EstimateFactCount returns the number of facts. |
| 694 | func (s MultiIndexedInMemoryStore) EstimateFactCount() int { |