| 860 | } |
| 861 | |
| 862 | func (s *MultiIndexedArrayInMemoryStore) removeAtom(a ast.Atom) bool { |
| 863 | if a.Predicate.Arity == 0 { |
| 864 | if _, ok := s.constants[a.Predicate]; ok { |
| 865 | delete(s.constants, a.Predicate) |
| 866 | return true |
| 867 | } |
| 868 | return false |
| 869 | } |
| 870 | aHash := a.Hash() |
| 871 | shard, ok := s.shardsByPredicate[a.Predicate] |
| 872 | if !ok { |
| 873 | return false |
| 874 | } |
| 875 | removed := false |
| 876 | for i := 0; i < a.Predicate.Arity; i++ { |
| 877 | iHash := a.Args[i].Hash() |
| 878 | params, ok := shard[uint16(i)] |
| 879 | if !ok { |
| 880 | continue |
| 881 | } |
| 882 | atoms, ok := params[iHash] |
| 883 | if !ok { |
| 884 | continue |
| 885 | } |
| 886 | if _, ok := atoms[aHash]; ok { |
| 887 | for j, atom := range atoms[aHash] { |
| 888 | if a.Equals(*atom) { |
| 889 | atoms[aHash] = append(atoms[aHash][:j], atoms[aHash][j+1:]...) |
| 890 | removed = true |
| 891 | break |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | } |
| 896 | return removed |
| 897 | } |
| 898 | |
| 899 | // Contains returns true if this store contains this atom already. |
| 900 | func (s *MultiIndexedArrayInMemoryStore) Contains(a ast.Atom) bool { |