本文整理汇总了Golang中github.com/couchbase/query/value.AnnotatedValue.SetAttachment方法的典型用法代码示例。如果您正苦于以下问题:Golang AnnotatedValue.SetAttachment方法的具体用法?Golang AnnotatedValue.SetAttachment怎么用?Golang AnnotatedValue.SetAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbase/query/value.AnnotatedValue
的用法示例。
在下文中一共展示了AnnotatedValue.SetAttachment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: lessThan
func (this *Order) lessThan(v1 value.AnnotatedValue, v2 value.AnnotatedValue) bool {
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
}
示例2: joinEntry
func (this *IndexJoin) joinEntry(item value.AnnotatedValue,
entry *datastore.IndexEntry, context *Context) (found, ok bool) {
var jv value.AnnotatedValue
covers := this.plan.Covers()
if len(covers) == 0 {
jv, ok = this.fetch(entry, context)
if jv == nil || !ok {
return jv != nil, ok
}
} else {
jv = value.NewAnnotatedValue(nil)
meta := map[string]interface{}{"id": entry.PrimaryKey}
jv.SetAttachment("meta", meta)
for i, c := range covers {
jv.SetCover(c.Text(), entry.EntryKey[i])
}
}
joined := item.Copy().(value.AnnotatedValue)
joined.SetField(this.plan.Term().Alias(), jv)
return true, this.sendItem(joined)
}
示例3: processItem
func (this *Clone) processItem(item value.AnnotatedValue, context *Context) bool {
clone := item.CopyForUpdate()
item.SetAttachment("clone", clone)
return this.sendItem(item)
}