Contains returns true if this store contains this atom already.
(a ast.Atom)
| 898 | |
| 899 | // Contains returns true if this store contains this atom already. |
| 900 | func (s *MultiIndexedArrayInMemoryStore) Contains(a ast.Atom) bool { |
| 901 | if a.Predicate.Arity == 0 { |
| 902 | _, ok := s.constants[a.Predicate] |
| 903 | return ok |
| 904 | } |
| 905 | shard, ok := s.shardsByPredicate[a.Predicate] |
| 906 | if !ok { |
| 907 | return false |
| 908 | } |
| 909 | params, ok := shard[0] |
| 910 | if !ok { |
| 911 | return false |
| 912 | } |
| 913 | h := a.Args[0].Hash() |
| 914 | atoms, ok := params[h] |
| 915 | if !ok { |
| 916 | return false |
| 917 | } |
| 918 | for _, fact := range atoms[a.Hash()] { |
| 919 | if a.Equals(*fact) { |
| 920 | return true |
| 921 | } |
| 922 | } |
| 923 | return false |
| 924 | } |
| 925 | |
| 926 | // EstimateFactCount returns the number of facts. |
| 927 | func (s *MultiIndexedArrayInMemoryStore) EstimateFactCount() int { |