本文整理匯總了Golang中github.com/couchbase/query/value.Value.GetAttachment方法的典型用法代碼示例。如果您正苦於以下問題:Golang Value.GetAttachment方法的具體用法?Golang Value.GetAttachment怎麽用?Golang Value.GetAttachment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbase/query/value.Value
的用法示例。
在下文中一共展示了Value.GetAttachment方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getSet
/*
Retrieve the set for annotated values. If the attachment type
is not a set, then throw an invalid distinct set error and
return.
*/
func getSet(item value.Value) (*value.Set, error) {
switch item := item.(type) {
case value.AnnotatedValue:
ps := item.GetAttachment("set")
switch ps := ps.(type) {
case *value.Set:
return ps, nil
default:
return nil, fmt.Errorf("Invalid DISTINCT set %v of type %T.", ps, ps)
}
default:
return nil, fmt.Errorf("Invalid DISTINCT %v of type %T.", item, item)
}
}
示例2: Evaluate
/*
Directly call the evaluate method for aggregate functions and
passe in the receiver, current item and current context, for
count with an input expression operand. For a count with no
operands (count (*)), get the count from the attachment and
then evaluate.
*/
func (this *Count) Evaluate(item value.Value, context expression.Context) (result value.Value, e error) {
if this.Operand() != nil {
return this.evaluate(this, item, context)
}
// Full keyspace count is short-circuited
switch item := item.(type) {
case value.AnnotatedValue:
count := item.GetAttachment("count")
if count != nil {
return value.NewValue(count), nil
}
}
return this.evaluate(this, item, context)
}