MCPcopy
hub / github.com/perkeep/perkeep / Flush

Method Flush

pkg/sorted/buffer/buffer.go:57–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57func (kv *KeyValue) Flush() error {
58 kv.mu.Lock()
59 defer kv.mu.Unlock()
60 var (
61 bmback = kv.back.BeginBatch()
62 bmbuf = kv.buf.BeginBatch()
63 commit = false
64 it = kv.buf.Find("", "")
65 )
66 for it.Next() {
67 bmback.Set(it.Key(), it.Value())
68 bmbuf.Delete(it.Key())
69 commit = true
70 }
71 if err := it.Close(); err != nil {
72 return err
73 }
74 if commit {
75 if err := kv.back.CommitBatch(bmback); err != nil {
76 return err
77 }
78 if err := kv.buf.CommitBatch(bmbuf); err != nil {
79 return err
80 }
81 kv.bufMu.Lock()
82 kv.buffered = 0
83 kv.bufMu.Unlock()
84 }
85 return nil
86}
87
88func (kv *KeyValue) Get(key string) (string, error) {
89 kv.mu.RLock()

Callers 4

SetMethod · 0.95
CloseMethod · 0.95
TestBufferFunction · 0.45
serveRestartMethod · 0.45

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 11

LockMethod · 0.80
UnlockMethod · 0.80
BeginBatchMethod · 0.65
FindMethod · 0.65
NextMethod · 0.65
SetMethod · 0.65
KeyMethod · 0.65
ValueMethod · 0.65
DeleteMethod · 0.65
CloseMethod · 0.65
CommitBatchMethod · 0.65

Tested by 1

TestBufferFunction · 0.36