-
Notifications
You must be signed in to change notification settings - Fork 1
/
oec_flat_kv.go
87 lines (74 loc) · 1.64 KB
/
oec_flat_kv.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package iavl
import "fmt"
func (st *Store) getFlatKV(key []byte) []byte {
if st.flatKVStore == nil {
return nil
}
return st.flatKVStore.Get(key)
}
func (st *Store) setFlatKV(key, value []byte) {
if st.flatKVStore == nil {
return
}
st.flatKVStore.Set(key, value)
}
func (st *Store) commitFlatKV(version int64) {
if st.flatKVStore == nil {
return
}
st.flatKVStore.Commit(version)
}
func (st *Store) hasFlatKV(key []byte) bool {
if st.flatKVStore == nil {
return false
}
return st.flatKVStore.Has(key)
}
func (st *Store) deleteFlatKV(key []byte) {
if st.flatKVStore == nil {
return
}
st.flatKVStore.Delete(key)
}
func (st *Store) resetFlatKVCount() {
if st.flatKVStore == nil {
return
}
st.flatKVStore.ResetCount()
}
func (st *Store) GetFlatKVReadTime() int {
if st.flatKVStore == nil {
return 0
}
return st.flatKVStore.GetDBReadTime()
}
func (st *Store) GetFlatKVWriteTime() int {
if st.flatKVStore == nil {
return 0
}
return st.flatKVStore.GetDBWriteTime()
}
func (st *Store) GetFlatKVReadCount() int {
if st.flatKVStore == nil {
return 0
}
return st.flatKVStore.GetDBReadCount()
}
func (st *Store) GetFlatKVWriteCount() int {
if st.flatKVStore == nil {
return 0
}
return st.flatKVStore.GetDBWriteCount()
}
func (st *Store) ValidateFlatVersion() error {
if !st.flatKVStore.Enable() {
return nil
}
treeVersion := st.tree.Version()
flatVersion := st.flatKVStore.GetLatestVersion()
if flatVersion != 0 && flatVersion != treeVersion {
return fmt.Errorf("the version of flat db(%d) does not match the version of iavl tree(%d), you can delete flat.db and restart node",
flatVersion, treeVersion)
}
return nil
}