本文整理汇总了Golang中github.com/couchbaselabs/query/value.AnnotatedValue.GetAttachment方法的典型用法代码示例。如果您正苦于以下问题:Golang AnnotatedValue.GetAttachment方法的具体用法?Golang AnnotatedValue.GetAttachment怎么用?Golang AnnotatedValue.GetAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbaselabs/query/value.AnnotatedValue
的用法示例。
在下文中一共展示了AnnotatedValue.GetAttachment方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: processKey
func (this *IntersectScan) processKey(item value.AnnotatedValue, context *Context) bool {
m := item.GetAttachment("meta")
meta, ok := m.(map[string]interface{})
if !ok {
context.Error(errors.NewError(nil,
fmt.Sprintf("Missing or invalid meta %v of type %T.", m, m)))
return false
}
k := meta["id"]
key, ok := k.(string)
if !ok {
context.Error(errors.NewError(nil,
fmt.Sprintf("Missing or invalid primary key %v of type %T.", k, k)))
return false
}
count := this.counts[key]
this.counts[key] = count + 1
if count+1 == len(this.scans) {
delete(this.values, key)
return this.sendItem(item)
}
if count == 0 {
this.values[key] = item
}
return true
}
示例2: processItem
func (this *Distinct) processItem(item value.AnnotatedValue, context *Context) bool {
p := item.GetAttachment("projection")
if p == nil {
p = item
}
this.set.Put(p.(value.Value), item)
return true
}
示例3: processItem
func (this *Clone) processItem(item value.AnnotatedValue, context *Context) bool {
target, ok := item.GetAttachment("target").(value.Value)
if !ok {
target = item
}
item.SetAttachment("clone", target.CopyForUpdate())
return this.sendItem(item)
}
示例4: processItem
func (this *FinalProject) processItem(item value.AnnotatedValue, context *Context) bool {
pv := item.GetAttachment("projection")
if pv != nil {
v := pv.(value.Value)
return this.sendItem(value.NewAnnotatedValue(v))
}
return this.sendItem(item)
}
示例5: processItem
func (this *Unset) processItem(item value.AnnotatedValue, context *Context) bool {
clone, ok := item.GetAttachment("clone").(value.AnnotatedValue)
if !ok {
context.Error(errors.NewError(nil,
fmt.Sprintf("Invalid UPDATE clone of type %T.", clone)))
return false
}
for _, t := range this.plan.Node().Terms() {
unsetPath(t, clone, context)
}
return this.sendItem(item)
}
示例6: processItem
func (this *Set) processItem(item value.AnnotatedValue, context *Context) bool {
clone, ok := item.GetAttachment("clone").(value.AnnotatedValue)
if !ok {
context.Error(errors.NewError(nil,
fmt.Sprintf("Invalid UPDATE clone of type %T.", clone)))
return false
}
var e error
for _, t := range this.plan.Node().Terms() {
clone, e = setPath(t, clone, item, context)
if e != nil {
context.Error(errors.NewError(e, "Error evaluating SET clause."))
return false
}
}
item.SetAttachment("clone", clone)
return this.sendItem(item)
}
示例7: processKey
func (this *UnionScan) processKey(item value.AnnotatedValue, context *Context) bool {
m := item.GetAttachment("meta")
meta, ok := m.(map[string]interface{})
if !ok {
context.Error(errors.NewError(nil,
fmt.Sprintf("Missing or invalid meta %v of type %T.", m, m)))
return false
}
k := meta["id"]
key, ok := k.(string)
if !ok {
context.Error(errors.NewError(nil,
fmt.Sprintf("Missing or invalid primary key %v of type %T.", k, k)))
return false
}
if this.values[key] != nil {
return true
}
this.values[key] = item
return this.sendItem(item)
}
示例8: requireKey
func (this *base) requireKey(item value.AnnotatedValue, context *Context) (string, bool) {
mv := item.GetAttachment("meta")
if mv == nil {
context.Error(errors.NewError(nil, "Unable to find meta."))
return "", false
}
meta := mv.(map[string]interface{})
key, ok := meta["id"]
if !ok {
context.Error(errors.NewError(nil, "Unable to find key."))
return "", false
}
act := value.NewValue(key).Actual()
switch act := act.(type) {
case string:
return act, true
default:
e := errors.NewError(nil, fmt.Sprintf("Unable to process non-string key %v of type %T.", act, act))
context.Error(e)
return "", false
}
}