本文整理匯總了Golang中kythe/io/kythe/go/storage/table.Proto.Buffered方法的典型用法代碼示例。如果您正苦於以下問題:Golang Proto.Buffered方法的具體用法?Golang Proto.Buffered怎麽用?Golang Proto.Buffered使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kythe/io/kythe/go/storage/table.Proto
的用法示例。
在下文中一共展示了Proto.Buffered方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: writePagedEdges
func writePagedEdges(ctx context.Context, edges <-chan *srvpb.Edge, out table.Proto, opts *Options) error {
buffer := out.Buffered()
log.Println("Writing EdgeSets")
esb := &assemble.EdgeSetBuilder{
MaxEdgePageSize: opts.MaxPageSize,
Output: func(ctx context.Context, pes *srvpb.PagedEdgeSet) error {
return buffer.Put(ctx, xsrv.EdgeSetKey(pes.Source.Ticket), pes)
},
OutputPage: func(ctx context.Context, ep *srvpb.EdgePage) error {
return buffer.Put(ctx, xsrv.EdgePageKey(ep.PageKey), ep)
},
}
var grp *srvpb.EdgeGroup
for e := range edges {
if grp != nil && (e.Target == nil || grp.Kind != e.Kind) {
if err := esb.AddGroup(ctx, grp); err != nil {
for range edges {
} // drain input channel
return err
}
grp = nil
}
if e.Target == nil {
// Head-only edge: signals a new set of edges with the same Source
if err := esb.StartEdgeSet(ctx, e.Source); err != nil {
return err
}
} else if grp == nil {
grp = &srvpb.EdgeGroup{
Kind: e.Kind,
Target: []*srvpb.Node{e.Target},
}
} else {
grp.Target = append(grp.Target, e.Target)
}
}
if grp != nil {
if err := esb.AddGroup(ctx, grp); err != nil {
return err
}
}
if err := esb.Flush(ctx); err != nil {
return err
}
return buffer.Flush(ctx)
}
示例2: writeFileTree
func writeFileTree(ctx context.Context, tree *filetree.Map, out table.Proto) error {
buffer := out.Buffered()
for corpus, roots := range tree.M {
for root, dirs := range roots {
for path, dir := range dirs {
if err := buffer.Put(ctx, ftsrv.PrefixedDirKey(corpus, root, path), dir); err != nil {
return err
}
}
}
}
cr, err := tree.CorpusRoots(ctx, &ftpb.CorpusRootsRequest{})
if err != nil {
return err
}
if err := buffer.Put(ctx, ftsrv.CorpusRootsPrefixedKey, cr); err != nil {
return err
}
return buffer.Flush(ctx)
}