本文整理汇总了Golang中kythe/io/kythe/go/storage/table.KVProto.ScanPrefix方法的典型用法代码示例。如果您正苦于以下问题:Golang KVProto.ScanPrefix方法的具体用法?Golang KVProto.ScanPrefix怎么用?Golang KVProto.ScanPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kythe/io/kythe/go/storage/table.KVProto
的用法示例。
在下文中一共展示了KVProto.ScanPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: writeEdgePages
func writeEdgePages(ctx context.Context, t table.Proto, edgeGroups *table.KVProto, maxEdgePageSize int) error {
// TODO(schroederc): spill large PagedEdgeSets into EdgePages
it, err := edgeGroups.ScanPrefix(nil, &keyvalue.Options{LargeRead: true})
if err != nil {
return err
}
defer it.Close()
log.Println("Writing EdgeSets")
esb := &assemble.EdgeSetBuilder{
MaxEdgePageSize: maxEdgePageSize,
Output: func(ctx context.Context, pes *srvpb.PagedEdgeSet) error {
return t.Put(ctx, xrefs.EdgeSetKey(pes.EdgeSet.SourceTicket), pes)
},
OutputPage: func(ctx context.Context, ep *srvpb.EdgePage) error {
return t.Put(ctx, xrefs.EdgePageKey(ep.PageKey), ep)
},
}
for {
k, v, err := it.Next()
if err == io.EOF {
break
} else if err != nil {
return fmt.Errorf("error scanning edge groups table: %v", err)
}
ss := strings.Split(string(k), tempTableKeySep)
if len(ss) != 3 {
return fmt.Errorf("invalid edge groups table key: %q", string(k))
}
src := ss[0]
var eg srvpb.EdgeSet_Group
if err := proto.Unmarshal(v, &eg); err != nil {
return fmt.Errorf("invalid edge groups table value: %v", err)
}
if err := esb.AddGroup(ctx, src, &eg); err != nil {
return err
}
}
return esb.Flush(ctx)
}
示例2: readCompletedEdges
func readCompletedEdges(ctx context.Context, edges *table.KVProto, outs ...chan<- *srvpb.Edge) error {
defer func() {
for _, out := range outs {
close(out)
}
}()
snapshot := edges.NewSnapshot()
defer snapshot.Close()
it, err := edges.ScanPrefix(nil, &keyvalue.Options{
LargeRead: true,
Snapshot: snapshot,
})
if err != nil {
return err
}
defer it.Close()
for {
_, v, err := it.Next()
if err == io.EOF {
break
} else if err != nil {
return fmt.Errorf("error scanning edges table: %v", err)
}
var e srvpb.Edge
if err := proto.Unmarshal(v, &e); err != nil {
return fmt.Errorf("invalid edge table value: %v", err)
}
for _, out := range outs {
out <- &e
}
}
return nil
}