本文整理汇总了Golang中github.com/janelia-flyem/dvid/datastore.VersionedCtx.GetOrderedKeyValueDB方法的典型用法代码示例。如果您正苦于以下问题:Golang VersionedCtx.GetOrderedKeyValueDB方法的具体用法?Golang VersionedCtx.GetOrderedKeyValueDB怎么用?Golang VersionedCtx.GetOrderedKeyValueDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/janelia-flyem/dvid/datastore.VersionedCtx
的用法示例。
在下文中一共展示了VersionedCtx.GetOrderedKeyValueDB方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getSpans
// Returns all (z, y, x0, x1) Spans in sorted order: z, then y, then x0.
func getSpans(ctx *datastore.VersionedCtx, minIndex, maxIndex indexRLE) ([]dvid.Span, error) {
db, err := ctx.GetOrderedKeyValueDB()
if err != nil {
return nil, err
}
spans := []dvid.Span{}
var f storage.ChunkFunc = func(chunk *storage.Chunk) error {
ibytes, err := chunk.K.ClassBytes(keyROI)
if err != nil {
return err
}
index := new(indexRLE)
if err = index.IndexFromBytes(ibytes); err != nil {
return fmt.Errorf("Unable to get indexRLE out of []byte encoding: %v\n", err)
}
z := index.start.Value(2)
y := index.start.Value(1)
x0 := index.start.Value(0)
x1 := x0 + int32(index.span) - 1
spans = append(spans, dvid.Span{z, y, x0, x1})
return nil
}
mintk := storage.NewTKey(keyROI, minIndex.Bytes())
maxtk := storage.NewTKey(keyROI, maxIndex.Bytes())
err = db.ProcessRange(ctx, mintk, maxtk, &storage.ChunkOp{}, f)
return spans, err
}
示例2: putElements
func putElements(ctx *datastore.VersionedCtx, tk storage.TKey, elems interface{}) error {
val, err := json.Marshal(elems)
if err != nil {
return err
}
store, err := ctx.GetOrderedKeyValueDB()
if err != nil {
return err
}
if err := store.Put(ctx, tk, val); err != nil {
return err
}
return nil
}
示例3: getElementsNR
// makes sure that no relationships are returned since they could be out of date.
func getElementsNR(ctx *datastore.VersionedCtx, tk storage.TKey) (ElementsNR, error) {
store, err := ctx.GetOrderedKeyValueDB()
if err != nil {
return nil, err
}
val, err := store.Get(ctx, tk)
if err != nil {
return nil, err
}
if val == nil {
return nil, nil
}
var elems ElementsNR
if err := json.Unmarshal(val, &elems); err != nil {
return nil, err
}
return elems, nil
}