MCPcopy Index your code
hub / github.com/perkeep/perkeep / CommitBatch

Method CommitBatch

pkg/sorted/buffer/buffer.go:144–181  ·  view source on GitHub ↗
(bm sorted.BatchMutation)

Source from the content-addressed store, hash-verified

142}
143
144func (kv *KeyValue) CommitBatch(bm sorted.BatchMutation) error {
145 kv.mu.RLock()
146 defer kv.mu.RUnlock()
147 b, ok := bm.(*batch)
148 if !ok {
149 return fmt.Errorf("unexpected BatchMutation type %T", bm)
150 }
151 var (
152 // A batch mutation for applying this mutation to the buffer.
153 bmbuf = kv.buf.BeginBatch()
154 // A lazily created batch mutation for deleting from the backing
155 // storage; this should be rare. (See Delete above.)
156 bmback sorted.BatchMutation
157 )
158 for _, m := range b.mods {
159 if m.isDelete {
160 bmbuf.Delete(m.key)
161 if bmback == nil {
162 bmback = kv.back.BeginBatch()
163 }
164 bmback.Delete(m.key)
165 continue
166 } else {
167 if err := sorted.CheckSizes(m.key, m.value); err != nil {
168 log.Printf("Skipping storing (%q:%q): %v", m.key, m.value, err)
169 continue
170 }
171 }
172 bmbuf.Set(m.key, m.value)
173 }
174 if err := kv.buf.CommitBatch(bmbuf); err != nil {
175 return err
176 }
177 if bmback != nil {
178 return kv.back.CommitBatch(bmback)
179 }
180 return nil
181}
182
183func (kv *KeyValue) Close() error {
184 if err := kv.Flush(); err != nil {

Callers

nothing calls this directly

Implementers 6

memKeyspkg/sorted/mem.go
kvispkg/sorted/kvfile/kvfile.go
keyValuepkg/sorted/mongo/mongokv.go
KeyValuepkg/sorted/buffer/buffer.go
KeyValuepkg/sorted/sqlkv/sqlkv.go
kvispkg/sorted/leveldb/leveldb.go

Calls 8

CheckSizesFunction · 0.92
PrintfMethod · 0.80
RLockMethod · 0.65
RUnlockMethod · 0.65
BeginBatchMethod · 0.65
DeleteMethod · 0.65
SetMethod · 0.65
CommitBatchMethod · 0.65

Tested by

no test coverage detected