MCPcopy Create free account
hub / github.com/brimdata/super / Load

Method Load

db/branch.go:50–80  ·  view source on GitHub ↗
(ctx context.Context, sctx *super.Context, r sio.Reader, author, message, meta string)

Source from the content-addressed store, hash-verified

48}
49
50func (b *Branch) Load(ctx context.Context, sctx *super.Context, r sio.Reader, author, message, meta string) (ksuid.KSUID, error) {
51 w, err := NewWriter(ctx, sctx, b.pool)
52 if err != nil {
53 return ksuid.Nil, err
54 }
55 err = sio.CopyWithContext(ctx, w, r)
56 if closeErr := w.Close(); err == nil {
57 err = closeErr
58 }
59 if err != nil {
60 return ksuid.Nil, err
61 }
62 objects := w.Objects()
63 if len(objects) == 0 {
64 return ksuid.Nil, commits.ErrEmptyTransaction
65 }
66 if message == "" {
67 message = loadMessage(objects)
68 }
69 appMeta, err := loadMeta(sctx, meta)
70 if err != nil {
71 return ksuid.Nil, err
72 }
73 // The load operation has only added new objects so we know its
74 // safe to merge at the tip and there can be no conflicts
75 // with other concurrent writers (except for updating the branch pointer
76 // which is handled by Branch.commit)
77 return b.commit(ctx, func(parent *branches.Config, retries int) (*commits.Object, error) {
78 return commits.NewAddsObject(parent.Commit, retries, author, message, appMeta, objects), nil
79 })
80}
81
82func loadMessage(objects []data.Object) string {
83 var b strings.Builder

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
ObjectsMethod · 0.95
commitMethod · 0.95
CopyWithContextFunction · 0.92
NewAddsObjectFunction · 0.92
loadMessageFunction · 0.85
loadMetaFunction · 0.85
NewWriterFunction · 0.70

Tested by

no test coverage detected