MCPcopy Create free account
hub / github.com/Johonsoy/SmartStashDB / commit

Method commit

storage/batch.go:86–118  ·  view source on GitHub ↗
(w *WriteOptions)

Source from the content-addressed store, hash-verified

84}
85
86func (batch *Batch) commit(w *WriteOptions) error {
87 if w == nil {
88 w = &WriteOptions{
89 Sync: false,
90 DisableWal: false,
91 }
92 }
93 defer batch.unLock()
94 if batch.db.Closed {
95 return _const.ErrorDBClosed
96 }
97
98 if batch.options.ReadOnly || len(batch.pendingWrites) == 0 {
99 return nil
100 }
101
102 batch.m.Lock()
103 defer batch.m.Unlock()
104 if batch.commited {
105 return _const.ErrorBatchCommited
106 }
107
108 if err := batch.db.waitMemTableSpace(); err != nil {
109 return err
110 }
111
112 batchId := batch.batchId.Generate()
113 if err := batch.db.activeMem.putBatch(batch.pendingWrites, batchId, w); err != nil {
114 return err
115 }
116 batch.commited = true
117 return nil
118}
119
120func (batch *Batch) Get(key []byte) ([]byte, error) {
121 if len(key) == 0 {

Callers 3

PutMethod · 0.80
GetMethod · 0.80
DeleteMethod · 0.80

Calls 3

unLockMethod · 0.95
waitMemTableSpaceMethod · 0.80
putBatchMethod · 0.80

Tested by

no test coverage detected