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


Golang Expression.Accept方法代碼示例

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


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

示例1: isConstant

func (this *ExpressionSargable) isConstant(e ast.Expression) bool {
	_, err := e.Accept(this.constantChecker)
	if err == nil {
		return true
	}
	return false
}
開發者ID:latinojoel,項目名稱:tuqtng,代碼行數:7,代碼來源:expression_sargable.go

示例2: matchesIndex

func (this *ExpressionSargable) matchesIndex(e ast.Expression) bool {
	_, err := e.Accept(this.equivalenceChecker)
	if err == nil {
		return true
	}
	return false
}
開發者ID:latinojoel,項目名稱:tuqtng,代碼行數:7,代碼來源:expression_sargable.go

示例3: CanIUseThisIndexForThisWhereClause

func CanIUseThisIndexForThisWhereClause(index catalog.RangeIndex, where ast.Expression, bucket string) (bool, plan.ScanRanges, ast.Expression, error) {

	// convert the index key to formal notation
	indexKeyFormal, err := IndexKeyInFormalNotation(index.Key(), bucket)
	if err != nil {
		return false, nil, nil, err
	}

	// put the where clause into conjunctive normal form
	ennf := ast.NewExpressionNNF()
	whereNNF, err := where.Accept(ennf)
	if err != nil {
		return false, nil, nil, err
	}
	ecnf := ast.NewExpressionCNF()
	whereCNF, err := whereNNF.Accept(ecnf)
	if err != nil {
		return false, nil, nil, err
	}

	switch whereCNF := whereCNF.(type) {
	case *ast.AndOperator:
		// this is an and, we can try to satisfy individual operands
		found := false
		rranges := plan.ScanRanges{}
		for _, oper := range whereCNF.Operands {
			// see if the where clause expression is sargable with respect to the index key
			es := NewExpressionSargable(indexKeyFormal[0])
			oper.Accept(es)
			if es.IsSargable() {
				found = true
				for _, ran := range es.ScanRanges() {
					rranges = MergeRanges(rranges, ran)
					clog.To(planner.CHANNEL, "now ranges are: %v", rranges)
				}
			}
		}
		if found {
			return true, rranges, nil, nil
		}
	default:
		// not an and, we must satisfy the whole expression
		// see if the where clause expression is sargable with respect to the index key
		es := NewExpressionSargable(indexKeyFormal[0])
		whereCNF.Accept(es)
		if es.IsSargable() {
			return true, es.ScanRanges(), nil, nil
		}
	}

	// cannot use this index
	return false, nil, nil, nil
}
開發者ID:latinojoel,項目名稱:tuqtng,代碼行數:53,代碼來源:index.go


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