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)
| 435 | // bindIntervalVariables binds interval variables in the query to the fact's interval. |
| 436 | // Supports binding @[T] (point/variable) or @[T1, T2] (range). |
| 437 | func (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). |
| 463 | func intervalToConstant(interval ast.Interval) ast.Constant { |
no test coverage detected