예제 #1
0
파일: sarg_lt.go 프로젝트: pkdevboxy/query
func newSargLT(pred *expression.LT) *sargLT {
	rv := &sargLT{}
	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) {
			exprs = expression.Expressions{pred.Second().Static()}
			span.Range.High = exprs
		} else if pred.Second().EquivalentTo(expr2) {
			exprs = expression.Expressions{pred.First().Static()}
			span.Range.Low = exprs
		} else {
			return nil, nil
		}

		if len(exprs) == 0 || exprs[0] == nil {
			return nil, nil
		}

		span.Range.Inclusion = datastore.NEITHER
		return plan.Spans{span}, nil
	}

	return rv
}
예제 #2
0
func (this *JSConverter) VisitLT(expr *expression.LT) (interface{}, error) {
	var buf bytes.Buffer
	buf.WriteString("(")
	buf.WriteString(this.Visit(expr.First()))
	buf.WriteString(" < ")
	buf.WriteString(this.Visit(expr.Second()))
	buf.WriteString(")")
	return buf.String(), nil
}
예제 #3
0
func (this *subsetLT) VisitLT(expr *expression.LT) (interface{}, error) {
	if this.lt.First().EquivalentTo(expr.First()) {
		return LessThanOrEquals(this.lt.Second(), expr.Second()), nil
	}

	if this.lt.Second().EquivalentTo(expr.Second()) {
		return LessThanOrEquals(expr.First(), this.lt.First()), nil
	}

	return false, nil
}