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

Method NewWriter

db/data/writer.go:35–58  ·  view source on GitHub ↗

NewWriter returns a writer for writing the data of a BSUP object as well as optionally creating a seek index for the row object when the seekIndexStride is non-zero. We assume all records are non-volatile until Close as super.Values from the various record bodies are referenced across calls to Writ

(ctx context.Context, engine storage.Engine, path *storage.URI, sortKey order.SortKey, seekIndexStride int)

Source from the content-addressed store, hash-verified

33// Close as super.Values from the various record bodies are referenced across
34// calls to Write.
35func (o *Object) NewWriter(ctx context.Context, engine storage.Engine, path *storage.URI, sortKey order.SortKey, seekIndexStride int) (*Writer, error) {
36 out, err := engine.Put(ctx, o.SequenceURI(path))
37 if err != nil {
38 return nil, err
39 }
40 counter := &writeCounter{bufwriter.New(out), 0}
41 w := &Writer{
42 object: o,
43 byteCounter: counter,
44 writer: bsupio.NewWriter(counter),
45 sortKey: sortKey,
46 first: true,
47 }
48 if seekIndexStride == 0 {
49 seekIndexStride = DefaultSeekStride
50 }
51 w.seekIndexStride = seekIndexStride
52 seekOut, err := engine.Put(ctx, o.SeekIndexURI(path))
53 if err != nil {
54 return nil, err
55 }
56 w.seekIndex = seekindex.NewWriter(bsupio.NewWriter(bufwriter.New(seekOut)))
57 return w, nil
58}
59
60func (w *Writer) Write(val super.Value) error {
61 key := val.DerefPath(w.sortKey.Key).MissingAsNull()

Callers 8

newWriterMethod · 0.95
NewFunction · 0.80
writeObjectMethod · 0.80
NewWriterFunction · 0.80
NewWriterFunction · 0.80
NewWriterFunction · 0.80
NewWriterFunction · 0.80

Calls 6

SequenceURIMethod · 0.95
SeekIndexURIMethod · 0.95
NewFunction · 0.92
NewWriterFunction · 0.92
NewWriterFunction · 0.92
PutMethod · 0.65

Tested by 1