// processPredicate updates the working graph clause if there is an available // predicate. func processPredicate(c *GraphClause, ce ConsumedElement, lastNopToken *lexer.Token) (*predicate.Predicate, string, string, bool, error) { var ( nP *predicate.Predicate pID string pAnchorBinding string temporal bool ) raw := ce.Token().Text p, err := predicate.Parse(raw) if err == nil { // A fully specified predicate was provided. nP = p return nP, pID, pAnchorBinding, nP.Type() == predicate.Temporal, nil } // The predicate may have a binding on the anchor. cmps := predicateRegexp.FindAllStringSubmatch(raw, 2) if len(cmps) != 1 || (len(cmps) == 1 && len(cmps[0]) != 3) { return nil, "", "", false, fmt.Errorf("failed to extract partialy defined predicate %q, got %v instead", raw, cmps) } id, ta := cmps[0][1], cmps[0][2] pID = id if ta != "" { pAnchorBinding = ta temporal = true } return nil, pID, pAnchorBinding, temporal, nil }
// CheckAndUpdate checks if a predicate should be considered and it also updates // the internal state in case counts are needed. func (c *checker) CheckAndUpdate(p *predicate.Predicate) bool { if c.max { if c.c <= 0 { return false } c.c-- } if p.Type() == predicate.Immutable { return true } t, _ := p.TimeAnchor() if c.o.LowerAnchor != nil && t.Before(*c.o.LowerAnchor) { return false } if c.o.UpperAnchor != nil && t.After(*c.o.UpperAnchor) { return false } return true }
// CheckAndUpdate checks if a predicate should be considered and it also updates // the internal state in case counts are needed. func (c *checker) CheckAndUpdate(p *predicate.Predicate) bool { if c.max { if c.c <= 0 { return false } // TODO: Should it be decremented if later function returns false? c.c-- } if p.Type() == predicate.Immutable { return true } t, _ := p.TimeAnchor() if c.o.LowerAnchor != nil && t.Before(*c.o.LowerAnchor) { return false } if c.o.UpperAnchor != nil && t.After(*c.o.UpperAnchor) { return false } return true }