func newSargEq(pred *expression.Eq) *sargEq { rv := &sargEq{} rv.sarger = func(expr2 expression.Expression) (plan.Spans, error) { if SubsetOf(pred, expr2) { return _SELF_SPANS, nil } span := &plan.Span{} if pred.First().EquivalentTo(expr2) { span.Range.Low = expression.Expressions{pred.Second().Static()} } else if pred.Second().EquivalentTo(expr2) { span.Range.Low = expression.Expressions{pred.First().Static()} } else { return nil, nil } if span.Range.Low[0] == nil { return nil, nil } if rv.MissingHigh() { span.Range.High = expression.Expressions{expression.NewSuccessor(span.Range.Low[0])} span.Range.Inclusion = datastore.LOW } else { span.Range.High = span.Range.Low span.Range.Inclusion = datastore.BOTH } return plan.Spans{span}, nil } return rv }
func newSargLE(pred *expression.LE) *sargLE { rv := &sargLE{} rv.sarger = func(expr2 expression.Expression) (plan.Spans, error) { if SubsetOf(pred, expr2) { return _SELF_SPANS, nil } var exprs expression.Expressions span := &plan.Span{} if pred.First().EquivalentTo(expr2) { hs := pred.Second().Static() if hs != nil { if rv.MissingHigh() { exprs = expression.Expressions{expression.NewSuccessor(hs)} } else { exprs = expression.Expressions{hs} span.Range.Inclusion = datastore.HIGH } span.Range.High = exprs } } else if pred.Second().EquivalentTo(expr2) { exprs = expression.Expressions{pred.First().Static()} span.Range.Low = exprs span.Range.Inclusion = datastore.LOW } else { return nil, nil } if len(exprs) == 0 || exprs[0] == nil { return nil, nil } return plan.Spans{span}, nil } return rv }