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


Golang Value.Collate方法代碼示例

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


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

示例1: Apply

/*
This method evaluates the less than equal to condition and
returns a value representing if the two operands satisfy the
condition or not. If either of the input operands are
missing, return missing value, and if they are null, then
return null value. For all other types call the Collate
method and check if it is less than equal to 0 for the
two values. If it is, then return true.
*/
func (this *LE) Apply(context Context, first, second value.Value) (value.Value, error) {
	if first.Type() == value.MISSING || second.Type() == value.MISSING {
		return value.MISSING_VALUE, nil
	} else if first.Type() == value.NULL || second.Type() == value.NULL {
		return value.NULL_VALUE, nil
	}

	return value.NewValue(first.Collate(second) <= 0), nil
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:18,代碼來源:comp_le.go

示例2: Apply

/*
This method evaluates the between comparison operation and returns a
value representing if item value is in between low and high. If any of
the input operands are missing, return missing, and if null return null.
For all other types, check if the item is greater in terms of the N1QL
collation order, than the low value and smaller than high value, and return
true. If not return false.
*/
func (this *Between) Apply(context Context, item, low, high value.Value) (value.Value, error) {
	if item.Type() == value.MISSING || low.Type() == value.MISSING || high.Type() == value.MISSING {
		return value.MISSING_VALUE, nil
	} else if item.Type() == value.NULL || low.Type() == value.NULL || high.Type() == value.NULL {
		return value.NULL_VALUE, nil
	}

	return value.NewValue(item.Collate(low) >= 0 && item.Collate(high) <= 0), nil
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:17,代碼來源:comp_between.go

示例3: cumulatePart

/*
Aggregate input partial values into cumulative result value.
If partial result is null return the current cumulative value,
and if the cumulative result is null, return the partial value.
For non null partial and cumulative values, call Collate and
return the smaller value depending on the N1QL collation order.
*/
func (this *Min) cumulatePart(part, cumulative value.Value, context Context) (value.Value, error) {
	if part == value.NULL_VALUE {
		return cumulative, nil
	} else if cumulative == value.NULL_VALUE {
		return part, nil
	} else if part.Collate(cumulative) < 0 {
		return part, nil
	} else {
		return cumulative, nil
	}
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:18,代碼來源:agg_min.go

示例4: Less

func (this *Order) Less(i, j int) bool {
	v1 := this.values[i]
	v2 := this.values[j]

	var ev1, ev2 value.Value
	var c int
	var e error

	for i, term := range this.plan.Terms() {
		s := strconv.Itoa(i)

		sv1 := v1.GetAttachment(s)
		switch sv1 := sv1.(type) {
		case value.Value:
			ev1 = sv1
		default:
			ev1, e = term.Expression().Evaluate(v1, this.context)
			if e != nil {
				this.context.Error(errors.NewError(e, "Error evaluating ORDER BY."))
				return false
			}

			v1.SetAttachment(s, ev1)
		}

		sv2 := v2.GetAttachment(s)
		switch sv2 := sv2.(type) {
		case value.Value:
			ev2 = sv2
		default:
			ev2, e = term.Expression().Evaluate(v2, this.context)
			if e != nil {
				this.context.Error(errors.NewError(e, "Error evaluating ORDER BY."))
				return false
			}

			v2.SetAttachment(s, ev2)
		}

		c = ev1.Collate(ev2)

		if c == 0 {
			continue
		} else if term.Descending() {
			return c > 0
		} else {
			return c < 0
		}
	}

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


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