本文整理汇总了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)
}