本文整理汇总了Golang中github.com/couchbase/query/expression.Or类的典型用法代码示例。如果您正苦于以下问题:Golang Or类的具体用法?Golang Or怎么用?Golang Or使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Or类的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: 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
}
示例3: 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
}
示例4: 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
}
示例5: 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
}