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

Method Write

db/writer.go:193–229  ·  view source on GitHub ↗
(val super.Value)

Source from the content-addressed store, hash-verified

191}
192
193func (w *SortedWriter) Write(val super.Value) error {
194 key := val.DerefPath(w.sortKey.Key).MissingAsNull()
195again:
196 if w.writer == nil {
197 if err := w.newWriter(); err != nil {
198 w.Abort()
199 return err
200 }
201 }
202 if w.writer.BytesWritten() >= w.pool.Threshold &&
203 w.comparator.Compare(w.lastKey, key) != 0 {
204 if err := w.Close(); err != nil {
205 w.Abort()
206 return err
207 }
208 w.writer, w.vectorWriter = nil, nil
209 goto again
210 }
211 if err := w.writer.WriteWithKey(key, val); err != nil {
212 w.Abort()
213 return err
214 }
215
216 if w.vectorWriter != nil {
217 // XXX TBD: this is slow and creates a vector per value when writing vectors
218 // to a database. This will change when we convert the database from
219 // mixed BSUP/CSUP to CSUP only.
220 builder := vector.NewBuilder(val.Type())
221 builder.Write(val.Bytes())
222 if err := w.vectorWriter.Push(builder.Build(w.sctx)); err != nil {
223 w.Abort()
224 return err
225 }
226 }
227 w.lastKey.CopyFrom(key)
228 return nil
229}
230
231func (w *SortedWriter) Abort() {
232 if w.writer != nil {

Callers

nothing calls this directly

Calls 15

newWriterMethod · 0.95
AbortMethod · 0.95
CloseMethod · 0.95
WriteMethod · 0.95
BuildMethod · 0.95
NewBuilderFunction · 0.92
MissingAsNullMethod · 0.80
DerefPathMethod · 0.80
BytesWrittenMethod · 0.80
WriteWithKeyMethod · 0.80
CopyFromMethod · 0.80
TypeMethod · 0.65

Tested by

no test coverage detected