Example #1
0
func newSargAny(pred *expression.Any) *sargAny {
	rv := &sargAny{}
	rv.sarger = func(expr2 expression.Expression) (plan.Spans, error) {
		if SubsetOf(pred, expr2) {
			return _SELF_SPANS, nil
		}

		all, ok := expr2.(*expression.All)
		if !ok {
			return nil, nil
		}

		array, ok := all.Array().(*expression.Array)
		if !ok {
			return nil, nil
		}

		if !pred.Bindings().EquivalentTo(array.Bindings()) {
			return nil, nil
		}

		if array.When() != nil &&
			!SubsetOf(pred.Satisfies(), array.When()) {
			return nil, nil
		}

		return sargFor(pred.Satisfies(), array.Mapping(), false)
	}

	return rv
}
Example #2
0
func newSargableAny(pred *expression.Any) *sargableAny {
	rv := &sargableAny{}
	rv.test = func(expr2 expression.Expression) (bool, error) {
		if SubsetOf(pred, expr2) {
			return true, nil
		}

		all, ok := expr2.(*expression.All)
		if !ok {
			return false, nil
		}

		array, ok := all.Array().(*expression.Array)
		if !ok {
			return false, nil
		}

		mappings := expression.Expressions{array.Mapping()}
		if !pred.Bindings().EquivalentTo(array.Bindings()) {
			return false, nil
		}

		if array.When() != nil &&
			!SubsetOf(pred.Satisfies(), array.When()) {
			return false, nil
		}

		return SargableFor(pred.Satisfies(), mappings) > 0, nil
	}

	return rv
}
Example #3
0
func (this *subsetAny) VisitAny(expr *expression.Any) (interface{}, error) {
	return this.any.Bindings().EquivalentTo(expr.Bindings()) &&
		SubsetOf(this.any.Satisfies(), expr.Satisfies()), nil
}