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

Method GetFacts

factstore/temporal.go:446–462  ·  view source on GitHub ↗

GetFacts returns facts matching the query (respecting queryAt if set).

(query ast.Atom, fn func(ast.Atom) error)

Source from the content-addressed store, hash-verified

444
445// GetFacts returns facts matching the query (respecting queryAt if set).
446func (a *TemporalFactStoreAdapter) GetFacts(query ast.Atom, fn func(ast.Atom) error) error {
447 seen := make(map[uint64]bool)
448
449 callback := func(tf TemporalFact) error {
450 hash := tf.Atom.Hash()
451 if seen[hash] {
452 return nil
453 }
454 seen[hash] = true
455 return fn(tf.Atom)
456 }
457
458 if a.queryAt != nil {
459 return a.temporal.GetFactsAt(query, *a.queryAt, callback)
460 }
461 return a.temporal.GetAllFacts(query, callback)
462}
463
464// ListPredicates returns all predicates in the store.
465func (a *TemporalFactStoreAdapter) ListPredicates() []ast.PredicateSym {

Callers 1

Calls 3

HashMethod · 0.65
GetFactsAtMethod · 0.65
GetAllFactsMethod · 0.65

Tested by 1