MCPcopy
hub / github.com/google/mangle / Contains

Method Contains

factstore/factstore.go:900–924  ·  view source on GitHub ↗

Contains returns true if this store contains this atom already.

(a ast.Atom)

Source from the content-addressed store, hash-verified

898
899// Contains returns true if this store contains this atom already.
900func (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.
927func (s *MultiIndexedArrayInMemoryStore) EstimateFactCount() int {

Callers

nothing calls this directly

Calls 2

HashMethod · 0.65
EqualsMethod · 0.65

Tested by

no test coverage detected