MCPcopy Create free account
hub / github.com/dolthub/doltgresql / writeCache

Method writeCache

core/sequences/collection.go:407–434  ·  view source on GitHub ↗

writeCache writes every Sequence in the cache to the underlying map.

(ctx context.Context)

Source from the content-addressed store, hash-verified

405
406// writeCache writes every Sequence in the cache to the underlying map.
407func (pgs *Collection) writeCache(ctx context.Context) (err error) {
408 if len(pgs.accessedMap) == 0 {
409 return nil
410 }
411 mapEditor := pgs.underlyingMap.Editor()
412 for _, seq := range pgs.accessedMap {
413 data, err := seq.Serialize(ctx)
414 if err != nil {
415 return err
416 }
417 h, err := pgs.ns.WriteBytes(ctx, data)
418 if err != nil {
419 return err
420 }
421 if err = mapEditor.Update(ctx, string(seq.Id), h); err != nil {
422 return err
423 }
424 }
425 // Assign underlyingMap only after the error check. Flush returns a
426 // zero AddressMap on failure, which would corrupt the Collection.
427 flushed, err := mapEditor.Flush(ctx)
428 if err != nil {
429 return err
430 }
431 pgs.underlyingMap = flushed
432 clear(pgs.accessedMap)
433 return nil
434}
435
436// nextValForSequence increments the calling sequence.
437func (sequence *Sequence) nextValForSequence() (int64, error) {

Callers 4

DropSequenceMethod · 0.95
resolveNameMethod · 0.95
iterateIDsMethod · 0.95
MapMethod · 0.95

Calls 4

WriteBytesMethod · 0.80
FlushMethod · 0.80
SerializeMethod · 0.65
UpdateMethod · 0.45

Tested by

no test coverage detected