当前位置: 首页>>代码示例>>Golang>>正文


Golang Value.GetAttachment方法代码示例

本文整理汇总了Golang中github.com/couchbaselabs/query/value.Value.GetAttachment方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.GetAttachment方法的具体用法?Golang Value.GetAttachment怎么用?Golang Value.GetAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/couchbaselabs/query/value.Value的用法示例。


在下文中一共展示了Value.GetAttachment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Apply

/*
This method takes in an operand value and context and returns a value.
If the type of operand is missing then return it. If the operand
type is AnnotatedValue then we call NewValue using the GetAttachment
method on the operand with input string meta. In the event the there
is no attachment present, the default case is to return a NULL value.
*/
func (this *Meta) Apply(context Context, operand value.Value) (value.Value, error) {
	if operand.Type() == value.MISSING {
		return operand, nil
	}

	switch operand := operand.(type) {
	case value.AnnotatedValue:
		return value.NewValue(operand.GetAttachment("meta")), nil
	default:
		return value.NULL_VALUE, nil
	}
}
开发者ID:amarantha-k,项目名称:query,代码行数:19,代码来源:func_meta.go

示例2: 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)
	}
}
开发者ID:amarantha-k,项目名称:query,代码行数:19,代码来源:agg_util.go

示例3: 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)
}
开发者ID:amarantha-k,项目名称:query,代码行数:23,代码来源:agg_count.go


注:本文中的github.com/couchbaselabs/query/value.Value.GetAttachment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。