當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Expression.EquivalentTo方法代碼示例

本文整理匯總了Golang中github.com/couchbase/query/expression.Expression.EquivalentTo方法的典型用法代碼示例。如果您正苦於以下問題:Golang Expression.EquivalentTo方法的具體用法?Golang Expression.EquivalentTo怎麽用?Golang Expression.EquivalentTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/couchbase/query/expression.Expression的用法示例。


在下文中一共展示了Expression.EquivalentTo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: constrainAggregate

/*

Constrain the WHERE condition to reflect the aggregate query. For
example:

SELECT AVG(v) FROM widget w;

is rewritten as:

SELECT AVG(v) FROM widget w WHERE v IS NOT NULL;

This enables the query to use an index on v.

*/
func constrainAggregate(cond expression.Expression, aggs map[string]algebra.Aggregate) expression.Expression {
	var first expression.Expression
	for _, agg := range aggs {
		if first == nil {
			first = agg.Operand()
			if first == nil {
				return cond
			}

			continue
		}

		op := agg.Operand()
		if op == nil || !first.EquivalentTo(op) {
			return cond
		}
	}

	if first == nil {
		return cond
	}

	var constraint expression.Expression = expression.NewIsNotNull(first)
	if cond != nil {
		constraint = expression.NewAnd(cond, constraint)
	}

	return constraint
}
開發者ID:jmptrader,項目名稱:query,代碼行數:43,代碼來源:build_select_sub.go

示例2: newSubsetDefault

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
}
開發者ID:pkdevboxy,項目名稱:query,代碼行數:45,代碼來源:subset_default.go

示例3: LessThanOrEquals

func LessThanOrEquals(expr1, expr2 expression.Expression) bool {
	return LessThan(expr1, expr2) || expr1.EquivalentTo(expr2)
}
開發者ID:pkdevboxy,項目名稱:query,代碼行數:3,代碼來源:lt.go


注:本文中的github.com/couchbase/query/expression.Expression.EquivalentTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。