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


Golang expression.Expression類代碼示例

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


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

示例1: newSargDefault

func newSargDefault(expr expression.Expression) *sargDefault {
	var spans Spans
	if expr.PropagatesNull() {
		spans = _VALUED_SPANS
	} else if expr.PropagatesMissing() {
		spans = _FULL_SPANS
	}

	rv := &sargDefault{}
	rv.sarg = func(expr2 expression.Expression) (Spans, error) {
		if expr.EquivalentTo(expr2) {
			return _SELF_SPANS, nil
		}

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

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

		return nil, nil
	}

	return rv
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:27,代碼來源:sarg_default.go

示例2: LessThan

func LessThan(expr1, expr2 expression.Expression) bool {
	value1 := expr1.Value()
	value2 := expr2.Value()

	return value1 != nil && value2 != nil &&
		value1.Collate(value2) < 0
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:7,代碼來源:lt.go

示例3: VisitFunction

func (this *NNF) 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)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:25,代碼來源:nnf.go

示例4: Visit

func (this *JSConverter) Visit(expr expression.Expression) string {
	var buf bytes.Buffer
	s, err := expr.Accept(this)
	if err != nil {
		panic(fmt.Sprintf("Unexpected error in JSConverter: %v", err))
	}

	switch s := s.(type) {
	case []byte:
		buf.WriteString(string(s))
		for this.stack.Size() != 0 {
			funcExpr := this.stack.Pop().(*funcExpr)
			buf.WriteString(funcExpr.name)
			if funcExpr.operands.Front() != nil {
				buf.WriteString(writeOperands(funcExpr.operands))
			}
		}

	default:
		buf.WriteString(s.(string))
	}

	// if the stack is not empty, pop the function
	/*
		for this.stack.Size() != 0 {
			funcExpr := this.stack.Pop().(*funcExpr)
			buf.WriteString(funcExpr.name)
			if funcExpr.operands.Front() != nil {
				buf.WriteString(writeOperands(funcExpr.operands))
			}
		}
	*/

	return buf.String()
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:35,代碼來源:jsconverter.go

示例5: NewExecute

/*
The function NewExecute returns a pointer to the Execute
struct with the input argument expressions value as a field.
*/
func NewExecute(prepared expression.Expression) *Execute {
	rv := &Execute{
		prepared: prepared.Value(),
	}

	rv.stmt = rv
	return rv
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:12,代碼來源:execute.go

示例6: newSargableDefault

func newSargableDefault(expr expression.Expression) *sargableDefault {
	rv := &sargableDefault{}
	rv.test = func(expr2 expression.Expression) (bool, error) {
		return expr.EquivalentTo(expr2), nil
	}

	return rv
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:8,代碼來源:sargable_default.go

示例7: SargableFor

func SargableFor(expr1, expr2 expression.Expression) bool {
	if expr2.Value() != nil {
		return false
	}

	s := newSargable(expr1)
	result, _ := expr2.Accept(s)
	return result.(bool)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:9,代碼來源:sargable.go

示例8: SubsetOf

func SubsetOf(expr1, expr2 expression.Expression) bool {
	v2 := expr2.Value()
	if v2 != nil {
		return v2.Truth()
	}

	s := newSubset(expr1)
	result, _ := expr2.Accept(s)
	return result.(bool)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:10,代碼來源:subset.go

示例9: SargFor

func SargFor(expr1, expr2 expression.Expression) Spans {
	if expr2.Value() != nil {
		return nil
	}

	s := newSarg(expr1)
	result, _ := expr2.Accept(s)
	if result != nil {
		return result.(Spans)
	}

	return nil
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:13,代碼來源:sarg.go

示例10: NewPair

/*
Create a key value pair using the operands of the input
expression Array construct and return.
*/
func NewPair(expr expression.Expression) (*Pair, error) {
	array, ok := expr.(*expression.ArrayConstruct)
	if !ok {
		return nil, fmt.Errorf("Invalid VALUES expression %s", expr.String())
	}

	operands := array.Operands()
	if len(operands) != 2 {
		return nil, fmt.Errorf("Invalid VALUES expression %s", expr.String())
	}

	pair := &Pair{
		Key:   operands[0],
		Value: operands[1],
	}

	return pair, nil
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:22,代碼來源:pair.go

示例11: VisitNot

func (this *NNF) 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)
		}

		exp = expression.NewAnd(operands...)
	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())
	}

	return exp, exp.MapChildren(this)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:36,代碼來源:nnf.go

示例12: LessThanOrEquals

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

示例13: newSarg

func newSarg(expr expression.Expression) expression.Visitor {
	s, _ := expr.Accept(_SARG_FACTORY)
	return s.(expression.Visitor)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:4,代碼來源:sarg.go

示例14: 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:amarantha-k,項目名稱:query,代碼行數:45,代碼來源:subset_default.go

示例15: newSubset

func newSubset(expr expression.Expression) expression.Visitor {
	s, _ := expr.Accept(_SUBSET_FACTORY)
	return s.(expression.Visitor)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:4,代碼來源:subset.go


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