本文整理匯總了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)
}