本文整理匯總了Golang中github.com/couchbase/query/expression.Or.Operands方法的典型用法代碼示例。如果您正苦於以下問題:Golang Or.Operands方法的具體用法?Golang Or.Operands怎麽用?Golang Or.Operands使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbase/query/expression.Or
的用法示例。
在下文中一共展示了Or.Operands方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newSargOr
func newSargOr(pred *expression.Or) *sargOr {
rv := &sargOr{}
rv.sarger = func(expr2 expression.Expression) (plan.Spans, error) {
if SubsetOf(pred, expr2) {
return _SELF_SPANS, nil
}
spans := make(plan.Spans, 0, len(pred.Operands()))
for _, child := range pred.Operands() {
cspans, err := sargFor(child, expr2, rv.MissingHigh())
if err != nil {
return nil, err
}
if len(cspans) == 0 {
return nil, nil
}
if cspans[0] == _FULL_SPANS[0] ||
len(spans)+len(cspans) > 16 {
return _FULL_SPANS, nil
}
spans = append(spans, cspans...)
}
return spans, nil
}
return rv
}
示例2: newSubsetOr
func newSubsetOr(expr *expression.Or) *subsetOr {
rv := &subsetOr{}
rv.test = func(expr2 expression.Expression) (bool, error) {
for _, child := range expr.Operands() {
if !SubsetOf(child, expr2) {
return false, nil
}
}
return true, nil
}
return rv
}
示例3: newSargableOr
func newSargableOr(pred *expression.Or) *sargableOr {
rv := &sargableOr{}
rv.test = func(expr2 expression.Expression) (bool, error) {
exprs := expression.Expressions{expr2}
for _, child := range pred.Operands() {
if SargableFor(child, exprs) == 0 {
return false, nil
}
}
return true, nil
}
return rv
}
示例4: VisitOr
func (this *JSConverter) VisitOr(expr *expression.Or) (interface{}, error) {
var buf bytes.Buffer
buf.WriteString("(")
for i, op := range expr.Operands() {
if i > 0 {
buf.WriteString(" || ")
}
buf.WriteString(this.Visit(op))
}
buf.WriteString(")")
return buf.String(), nil
}
示例5: VisitOr
/*
Apply constant folding. Remove any constant terms.
*/
func (this *DNF) VisitOr(expr *expression.Or) (interface{}, error) {
err := expr.MapChildren(this)
if err != nil {
return nil, err
}
// Constant folding
var terms expression.Expressions
for _, term := range expr.Operands() {
val := term.Value()
if val == nil {
if terms == nil {
terms = make(expression.Expressions, 0, len(expr.Operands()))
}
terms = append(terms, term)
continue
}
if val.Truth() {
return expression.TRUE_EXPR, nil
}
}
if len(terms) == 0 {
return expression.FALSE_EXPR, nil
}
if len(terms) < len(expr.Operands()) {
expr = expression.NewOr(terms...)
}
return expr, nil
}