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


Golang Ref.IsEmpty方法代码示例

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


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

示例1: UpdateRoot

func (s *DynamoStore) UpdateRoot(current, last ref.Ref) bool {
	s.requestWg.Wait()

	putArgs := dynamodb.PutItemInput{
		TableName: aws.String(s.table),
		Item: map[string]*dynamodb.AttributeValue{
			refAttr:   {B: s.rootKey},
			chunkAttr: {B: current.DigestSlice()},
			compAttr:  {S: aws.String(noneValue)},
		},
	}

	if last.IsEmpty() {
		putArgs.ConditionExpression = aws.String(valueNotExistsExpression)
	} else {
		putArgs.ConditionExpression = aws.String(valueEqualsExpression)
		putArgs.ExpressionAttributeValues = map[string]*dynamodb.AttributeValue{
			":prev": {B: last.DigestSlice()},
		}
	}

	_, err := s.ddbsvc.PutItem(&putArgs)
	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			if awsErr.Code() == "ConditionalCheckFailedException" {
				return false
			}
			d.Chk.NoError(awsErr)
		} else {
			d.Chk.NoError(err)
		}
	}

	return true
}
开发者ID:arv,项目名称:noms-old,代码行数:35,代码来源:dynamo_store.go

示例2: requestRef

func (h *HTTPStore) requestRef(r ref.Ref, method string, body io.Reader) *http.Response {
	url := *h.host
	url.Path = httprouter.CleanPath(h.host.Path + constants.RefPath)
	if !r.IsEmpty() {
		url.Path = path.Join(url.Path, r.String())
	}

	header := http.Header{}
	if body != nil {
		header.Set("Content-Type", "application/octet-stream")
	}
	req := h.newRequest(method, url.String(), body, header)

	res, err := h.httpClient.Do(req)
	d.Chk.NoError(err)
	return res
}
开发者ID:arv,项目名称:noms-old,代码行数:17,代码来源:http_store.go

示例3: requestRoot

func (h *HTTPStore) requestRoot(method string, current, last ref.Ref) *http.Response {
	u := *h.host
	u.Path = httprouter.CleanPath(h.host.Path + constants.RootPath)
	if method == "POST" {
		d.Exp.False(current.IsEmpty())
		params := url.Values{}
		params.Add("last", last.String())
		params.Add("current", current.String())
		u.RawQuery = params.Encode()
	}

	req := h.newRequest(method, u.String(), nil, nil)

	res, err := h.httpClient.Do(req)
	d.Chk.NoError(err)

	return res
}
开发者ID:arv,项目名称:noms-old,代码行数:18,代码来源:http_store.go

示例4: main

func main() {
	cpuCount := runtime.NumCPU()
	runtime.GOMAXPROCS(cpuCount)

	flag.Parse()

	sourceStore, ok := sourceStoreFlags.CreateDataStore()
	sink := sinkDsFlags.CreateDataset()
	if !ok || sink == nil || *p == 0 || *sourceObject == "" {
		flag.Usage()
		return
	}
	defer sourceStore.Close()
	defer sink.Store().Close()

	err := d.Try(func() {
		if util.MaybeStartCPUProfile() {
			defer util.StopCPUProfile()
		}

		sourceRef := ref.Ref{}
		if r, ok := ref.MaybeParse(*sourceObject); ok {
			if sourceStore.Has(r) {
				sourceRef = r
			}
		} else {
			if c, ok := sourceStore.MaybeHead(*sourceObject); ok {
				sourceRef = c.Ref()
			}
		}
		d.Exp.False(sourceRef.IsEmpty(), "Unknown source object: %s", *sourceObject)

		var err error
		*sink, err = sink.Pull(sourceStore, sourceRef, int(*p))

		util.MaybeWriteMemProfile()
		d.Exp.NoError(err)
	})

	if err != nil {
		log.Fatal(err)
	}
}
开发者ID:arv,项目名称:noms-old,代码行数:43,代码来源:shove.go

示例5: CopyReachableChunksP

// CopyReachableChunksP copies to |sink| all chunks reachable from (and including) |r|, but that are not in the subtree rooted at |exclude|
func CopyReachableChunksP(source, sink DataStore, sourceRef, exclude ref.Ref, concurrency int) {
	excludeRefs := map[ref.Ref]bool{}

	if !exclude.IsEmpty() {
		mu := sync.Mutex{}
		excludeCallback := func(r ref.Ref) bool {
			mu.Lock()
			excludeRefs[r] = true
			mu.Unlock()
			return false
		}

		walk.SomeChunksP(exclude, source, excludeCallback, concurrency)
	}

	copyCallback := func(r ref.Ref) bool {
		return excludeRefs[r]
	}
	copyWorker(source, sink.transitionalChunkSink(), sourceRef, copyCallback, concurrency)
}
开发者ID:arv,项目名称:noms-old,代码行数:21,代码来源:pull.go

示例6: EnsureRef

func EnsureRef(r *ref.Ref, v Value) ref.Ref {
	if r.IsEmpty() {
		*r = getRef(v)
	}
	return *r
}
开发者ID:arv,项目名称:noms-old,代码行数:6,代码来源:get_ref.go


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