本文整理汇总了Golang中github.com/couchbaselabs/dparval.Value.GetAttachment方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.GetAttachment方法的具体用法?Golang Value.GetAttachment怎么用?Golang Value.GetAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbaselabs/dparval.Value
的用法示例。
在下文中一共展示了Value.GetAttachment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: processItem
func (this *InterpretedExecutor) processItem(q network.Query, item *dparval.Value) bool {
projection := item.GetAttachment("projection")
switch projection := projection.(type) {
case *dparval.Value:
result := projection.Value()
q.Response().SendResult(result)
}
return true
}
示例2: setAggregateValue
func setAggregateValue(item *dparval.Value, key string, val *dparval.Value) {
aggregates := item.GetAttachment("aggregates")
aggregatesMap, ok := aggregates.(map[string]interface{})
if !ok {
// create a new aggregates map
aggregatesMap = map[string]interface{}{}
item.SetAttachment("aggregates", aggregatesMap)
}
aggregatesMap[key] = val
}
示例3: Evaluate
func (this *FunctionCallNowMillis) Evaluate(item *dparval.Value) (*dparval.Value, error) {
// first retrieve the query object
q := item.GetAttachment("query")
query, ok := q.(network.Query)
if !ok {
return dparval.NewValue(nil), nil
}
return dparval.NewValue(timeToMillis(query.StartTime())), nil
}
示例4: processItem
func (this *EliminateDuplicates) processItem(item *dparval.Value) bool {
projection, _ := item.GetAttachment("projection").(*dparval.Value)
if projection != nil {
hashval := fmt.Sprintf("%s", projection.Value())
found := this.uniqueBuffer[hashval]
if found == nil {
this.uniqueBuffer[hashval] = item
}
}
return true
}
示例5: aggregateValue
// lookup the current value of the aggregate stored
// at the specified key
func aggregateValue(item *dparval.Value, key string) (*dparval.Value, error) {
aggregates := item.GetAttachment("aggregates")
aggregatesMap, ok := aggregates.(map[string]interface{})
if ok {
value := aggregatesMap[key]
valuedparval, ok := value.(*dparval.Value)
if ok {
return valuedparval, nil
}
}
return nil, fmt.Errorf("Unable to find aggregate %s", key)
}
示例6: processItem
func (this *Order) processItem(item *dparval.Value) bool {
if this.explicitAliases != nil {
projection := item.GetAttachment("projection")
projectionValue, ok := projection.(*dparval.Value)
if ok {
for _, explicitAlias := range this.explicitAliases {
// put the explicit alias values from the projection into the item
aliasedProjectedValue, err := projectionValue.Path(explicitAlias)
if err == nil {
item.SetPath(explicitAlias, aliasedProjectedValue)
}
}
}
}
this.buffer = append(this.buffer, item)
return true
}