當前位置: 首頁>>代碼示例>>Golang>>正文


Golang AnnotatedValue.GetAttachment方法代碼示例

本文整理匯總了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
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:31,代碼來源:scan_intersect.go

示例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
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:9,代碼來源:distinct.go

示例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)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:9,代碼來源:update_clone.go

示例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)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:9,代碼來源:project_final.go

示例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)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:14,代碼來源:update_unset.go

示例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)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:20,代碼來源:update_set.go

示例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)
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:24,代碼來源:scan_union.go

示例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
	}
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:24,代碼來源:base.go


注:本文中的github.com/couchbaselabs/query/value.AnnotatedValue.GetAttachment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。