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

Method GetFactsDuring

factstore/temporal.go:198–221  ·  view source on GitHub ↗

GetFactsDuring returns facts that overlap with the given interval. Uses interval tree for O(log n + k) query performance.

(query ast.Atom, interval ast.Interval, fn func(TemporalFact) error)

Source from the content-addressed store, hash-verified

196// GetFactsDuring returns facts that overlap with the given interval.
197// Uses interval tree for O(log n + k) query performance.
198func (s *TemporalStore) GetFactsDuring(query ast.Atom, interval ast.Interval, fn func(TemporalFact) error) error {
199 predMap, ok := s.facts[query.Predicate]
200 if !ok {
201 return nil
202 }
203
204 start := GetStartTime(interval)
205 end := GetEndTime(interval)
206
207 for hash, tree := range predMap {
208 atom := s.atoms[hash]
209 if !Matches(query.Args, atom.Args) {
210 continue
211 }
212
213 err := tree.QueryRange(start, end, func(factInterval ast.Interval) error {
214 return fn(TemporalFact{Atom: atom, Interval: factInterval})
215 })
216 if err != nil {
217 return err
218 }
219 }
220 return nil
221}
222
223// GetAllFacts returns all facts matching the query with their intervals.
224func (s *TemporalStore) GetAllFacts(query ast.Atom, fn func(TemporalFact) error) error {

Calls 4

GetStartTimeFunction · 0.85
GetEndTimeFunction · 0.85
MatchesFunction · 0.85
QueryRangeMethod · 0.80