示例#1
0
func newSubsetDefault(expr expression.Expression) *subsetDefault {
	rv := &subsetDefault{}
	rv.test = func(expr2 expression.Expression) (bool, error) {
		value2 := expr2.Value()
		if value2 != nil {
			return value2.Truth(), nil
		}

		if expr.EquivalentTo(expr2) {
			return true, nil
		}

		switch expr2 := expr2.(type) {
		case *expression.And:
			for _, op := range expr2.Operands() {
				if !SubsetOf(expr, op) {
					return false, nil
				}
			}

			return true, nil
		case *expression.Or:
			for _, op := range expr2.Operands() {
				if SubsetOf(expr, op) {
					return true, nil
				}
			}

			return false, nil
		case *expression.IsNotMissing:
			return expr.PropagatesMissing() &&
				expr.DependsOn(expr2.Operand()), nil
		case *expression.IsNotNull:
			return expr.PropagatesNull() &&
				expr.DependsOn(expr2.Operand()), nil
		case *expression.IsValued:
			return expr.PropagatesNull() &&
				expr.DependsOn(expr2.Operand()), nil
		}

		return false, nil
	}

	return rv
}
示例#2
0
func newSargDefault(pred expression.Expression) *sargDefault {
	var spans plan.Spans
	if pred.PropagatesNull() {
		spans = _VALUED_SPANS
	} else if pred.PropagatesMissing() {
		spans = _FULL_SPANS
	}

	rv := &sargDefault{}
	rv.sarger = func(expr2 expression.Expression) (plan.Spans, error) {
		if SubsetOf(pred, expr2) {
			return _SELF_SPANS, nil
		}

		if spans != nil && pred.DependsOn(expr2) {
			return spans, nil
		}

		return nil, nil
	}

	return rv
}