Contains returns true if this store contains this atom already.
(a ast.Atom)
| 490 | |
| 491 | // Contains returns true if this store contains this atom already. |
| 492 | func (s IndexedInMemoryStore) Contains(a ast.Atom) bool { |
| 493 | if a.Predicate.Arity == 0 { |
| 494 | _, ok := s.constants[a.Predicate] |
| 495 | return ok |
| 496 | } |
| 497 | shard, ok := s.shardsByPredicate[a.Predicate] |
| 498 | if !ok { |
| 499 | return false |
| 500 | } |
| 501 | h := a.Args[0].Hash() |
| 502 | atoms, ok := shard[h] |
| 503 | if !ok { |
| 504 | return false |
| 505 | } |
| 506 | _, exists := atoms[a.Hash()] |
| 507 | return exists |
| 508 | } |
| 509 | |
| 510 | // EstimateFactCount returns the number of facts. |
| 511 | func (s IndexedInMemoryStore) EstimateFactCount() int { |