本文整理匯總了Golang中github.com/couchbaselabs/query/value.AnnotatedValue.Attachments方法的典型用法代碼示例。如果您正苦於以下問題:Golang AnnotatedValue.Attachments方法的具體用法?Golang AnnotatedValue.Attachments怎麽用?Golang AnnotatedValue.Attachments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbaselabs/query/value.AnnotatedValue
的用法示例。
在下文中一共展示了AnnotatedValue.Attachments方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: processTerms
func (this *InitialProject) processTerms(item value.AnnotatedValue, context *Context) bool {
n := len(this.plan.Terms())
var f map[string]interface{}
if item.Type() == value.OBJECT {
f = item.Copy().Fields()
}
if f == nil {
f = make(map[string]interface{}, n)
}
pv := value.NewAnnotatedValue(f)
pv.SetAttachments(item.Attachments())
p := value.NewValue(make(map[string]interface{}, n+32))
pv.SetAttachment("projection", p)
for _, term := range this.plan.Terms() {
if term.Result().Alias() != "" {
v, err := term.Result().Expression().Evaluate(item, context)
if err != nil {
context.Error(errors.NewError(err, "Error evaluating projection."))
return false
}
p.SetField(term.Result().Alias(), v)
// Explicit aliases override data
if term.Result().As() != "" {
pv.SetField(term.Result().As(), v)
}
} else {
// Star
starval := item.GetValue()
if term.Result().Expression() != nil {
var err error
starval, err = term.Result().Expression().Evaluate(item, context)
if err != nil {
context.Error(errors.NewError(err, "Error evaluating projection."))
return false
}
}
// Latest star overwrites previous star
switch sa := starval.Actual().(type) {
case map[string]interface{}:
for k, v := range sa {
p.SetField(k, v)
}
}
}
}
return this.sendItem(pv)
}
示例2: processItem
func (this *Let) processItem(item value.AnnotatedValue, context *Context) bool {
n := len(this.plan.Bindings())
cv := value.NewScopeValue(make(map[string]interface{}, n), item)
lv := value.NewAnnotatedValue(cv)
lv.SetAttachments(item.Attachments())
for _, b := range this.plan.Bindings() {
v, e := b.Expression().Evaluate(item, context)
if e != nil {
context.Error(errors.NewError(e, "Error evaluating LET."))
return false
}
lv.SetField(b.Variable(), v)
}
return this.sendItem(lv)
}
示例3: setPath
func setPath(t *algebra.SetTerm, clone, item value.AnnotatedValue, context *Context) (value.AnnotatedValue, error) {
if t.UpdateFor() != nil {
return setFor(t, clone, item, context)
}
v, err := t.Value().Evaluate(item, context)
if err != nil {
return nil, err
}
if v.Type() == value.MISSING {
}
if t.Path() != nil {
t.Path().Set(clone, v, context)
return clone, nil
} else {
av := value.NewAnnotatedValue(v)
av.SetAttachments(clone.Attachments())
return av, nil
}
}
示例4: processItem
func (this *Alias) processItem(item value.AnnotatedValue, context *Context) bool {
av := value.NewAnnotatedValue(make(map[string]interface{}))
av.SetAttachments(item.Attachments())
av.SetField(this.plan.Alias(), item)
return this.sendItem(av)
}