本文整理汇总了Golang中github.com/couchbase/query/expression.Expression.MapChildren方法的典型用法代码示例。如果您正苦于以下问题:Golang Expression.MapChildren方法的具体用法?Golang Expression.MapChildren怎么用?Golang Expression.MapChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbase/query/expression.Expression
的用法示例。
在下文中一共展示了Expression.MapChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: VisitFunction
func (this *DNF) VisitFunction(expr expression.Function) (interface{}, error) {
var exp expression.Expression = expr
switch expr := expr.(type) {
case *expression.IsBoolean:
exp = expression.NewLE(expr.Operand(), expression.TRUE_EXPR)
case *expression.IsNumber:
exp = expression.NewAnd(
expression.NewGT(expr.Operand(), expression.TRUE_EXPR),
expression.NewLT(expr.Operand(), expression.EMPTY_STRING_EXPR))
case *expression.IsString:
exp = expression.NewAnd(
expression.NewGE(expr.Operand(), expression.EMPTY_STRING_EXPR),
expression.NewLT(expr.Operand(), expression.EMPTY_ARRAY_EXPR))
case *expression.IsArray:
exp = expression.NewAnd(
expression.NewGE(expr.Operand(), expression.EMPTY_ARRAY_EXPR),
expression.NewLT(expr.Operand(), _EMPTY_OBJECT_EXPR))
case *expression.IsObject:
// Not equivalent to IS OBJECT. Includes BINARY values.
exp = expression.NewGE(expr.Operand(), _EMPTY_OBJECT_EXPR)
}
return exp, exp.MapChildren(this)
}
示例2: VisitNot
func (this *DNF) VisitNot(expr *expression.Not) (interface{}, error) {
err := expr.MapChildren(this)
if err != nil {
return nil, err
}
var exp expression.Expression = expr
switch operand := expr.Operand().(type) {
case *expression.Not:
exp = operand.Operand()
case *expression.And:
operands := make(expression.Expressions, len(operand.Operands()))
for i, op := range operand.Operands() {
operands[i] = expression.NewNot(op)
}
exp = expression.NewOr(operands...)
case *expression.Or:
operands := make(expression.Expressions, len(operand.Operands()))
for i, op := range operand.Operands() {
operands[i] = expression.NewNot(op)
}
and := expression.NewAnd(operands...)
return this.VisitAnd(and)
case *expression.Eq:
exp = expression.NewOr(expression.NewLT(operand.First(), operand.Second()),
expression.NewLT(operand.Second(), operand.First()))
case *expression.LT:
exp = expression.NewLE(operand.Second(), operand.First())
case *expression.LE:
exp = expression.NewLT(operand.Second(), operand.First())
default:
return expr, nil
}
return exp, exp.MapChildren(this)
}