func writeFileTree(ctx context.Context, tree *filetree.Map, out table.Proto) error { for corpus, roots := range tree.M { for root, dirs := range roots { for path, dir := range dirs { if err := out.Put(ctx, ftsrv.DirKey(corpus, root, path), dir); err != nil { return err } } } } cr, err := tree.CorpusRoots(ctx, &ftpb.CorpusRootsRequest{}) if err != nil { return err } return out.Put(ctx, ftsrv.CorpusRootsKey, cr) }
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) }