本文整理汇总了Golang中github.com/couchbase/query/value.Value.Collate方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.Collate方法的具体用法?Golang Value.Collate怎么用?Golang Value.Collate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbase/query/value.Value
的用法示例。
在下文中一共展示了Value.Collate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testObjectRemove
func testObjectRemove(e1, e2 Expression, er value.Value, t *testing.T) {
eop := NewObjectRemove(e1, e2)
rv, err := eop.Evaluate(nil, nil)
if err != nil {
t.Errorf("received error %v", err)
}
if er.Collate(rv) != 0 {
t.Errorf("mismatch received %v expected %v", rv.Actual(), er.Actual())
}
}
示例2: testArrayInsert_eval
func testArrayInsert_eval(e1, e2, e3 Expression, er value.Value, t *testing.T) {
eai := NewArrayInsert(e1, e2, e3)
rv, err := eai.Evaluate(nil, nil)
if err != nil {
t.Errorf("received error %v", err)
}
if er.Collate(rv) != 0 {
t.Errorf("mismatch received %v expected %v", rv.Actual(), er.Actual())
}
}
示例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
}
}
示例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 := this.terms[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.NewEvaluationError(e, "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.NewEvaluationError(e, "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
}
示例5: testObjectAdd
func testObjectAdd(e1, e2, e3 Expression, er value.Value, fail bool, t *testing.T) {
eop := NewObjectAdd(e1, e2, e3)
rv, err := eop.Evaluate(nil, nil)
if err != nil {
if fail && rv.Actual() == nil {
return
}
t.Errorf("received error %v", err)
} else if fail {
t.Errorf("error expected, received success")
}
if er.Collate(rv) != 0 {
t.Errorf("mismatch received %v expected %v", rv.Actual(), er.Actual())
}
}