MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / Write

Method Write

kayak/wal/mem_wal.go:47–73  ·  view source on GitHub ↗

Write implements Wal.Write.

(l *kt.Log)

Source from the content-addressed store, hash-verified

45
46// Write implements Wal.Write.
47func (p *MemWal) Write(l *kt.Log) (err error) {
48 if atomic.LoadUint32(&p.closed) == 1 {
49 err = ErrWalClosed
50 return
51 }
52
53 if l == nil {
54 err = ErrInvalidLog
55 return
56 }
57
58 p.Lock()
59 defer p.Unlock()
60
61 if _, exists := p.revIndex[l.Index]; exists {
62 err = ErrAlreadyExists
63 return
64 }
65
66 offset := atomic.AddUint64(&p.offset, 1) - 1
67 p.logs = append(p.logs, nil)
68 copy(p.logs[offset+1:], p.logs[offset:])
69 p.logs[offset] = l
70 p.revIndex[l.Index] = int(offset)
71
72 return
73}
74
75// Read implements Wal.Read.
76func (p *MemWal) Read() (l *kt.Log, err error) {

Callers 2

TestMemWal_WriteFunction · 0.95
TestMemWal_Write2Function · 0.95

Calls

no outgoing calls

Tested by 2

TestMemWal_WriteFunction · 0.76
TestMemWal_Write2Function · 0.76