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

Method bindIntervalVariables

engine/temporal.go:437–460  ·  view source on GitHub ↗

bindIntervalVariables binds interval variables in the query to the fact's interval. Supports binding @[T] (point/variable) or @[T1, T2] (range).

(queryInterval ast.Interval, factInterval ast.Interval, subst unionfind.UnionFind)

Source from the content-addressed store, hash-verified

435// bindIntervalVariables binds interval variables in the query to the fact's interval.
436// Supports binding @[T] (point/variable) or @[T1, T2] (range).
437func (te *TemporalEvaluator) bindIntervalVariables(queryInterval ast.Interval, factInterval ast.Interval, subst unionfind.UnionFind) unionfind.UnionFind {
438 newSubst := subst
439
440 // Bind start variable if present
441 if queryInterval.Start.Type == ast.VariableBound {
442 // Create a constant for the start timestamp
443 startNano := factstore.GetStartTime(factInterval)
444 startConst := ast.Time(startNano)
445 if s, err := unionfind.UnifyTermsExtend([]ast.BaseTerm{queryInterval.Start.Variable}, []ast.BaseTerm{startConst}, newSubst); err == nil {
446 newSubst = s
447 }
448 }
449
450 // Bind end variable if present
451 if queryInterval.End.Type == ast.VariableBound {
452 endNano := factstore.GetEndTime(factInterval)
453 endConst := ast.Time(endNano)
454 if s, err := unionfind.UnifyTermsExtend([]ast.BaseTerm{queryInterval.End.Variable}, []ast.BaseTerm{endConst}, newSubst); err == nil {
455 newSubst = s
456 }
457 }
458
459 return newSubst
460}
461
462// intervalToConstant converts an interval to a Mangle constant (pair of numbers).
463func intervalToConstant(interval ast.Interval) ast.Constant {

Callers 5

evalDiamondMinusMethod · 0.95
evalBoxMinusMethod · 0.95
evalDiamondPlusMethod · 0.95
evalBoxPlusMethod · 0.95

Calls 4

GetStartTimeFunction · 0.92
TimeFunction · 0.92
UnifyTermsExtendFunction · 0.92
GetEndTimeFunction · 0.92

Tested by

no test coverage detected