OLD | NEW |
1 package main | 1 package main |
2 | 2 |
3 // Test integration of gkvlite with go-slab, using gkvlite's optional | 3 // Test integration of gkvlite with go-slab, using gkvlite's optional |
4 // ItemAddRef/ItemDecRef() callbacks to integrate with a slab memory | 4 // ItemAddRef/ItemDecRef() callbacks to integrate with a slab memory |
5 // allocator. | 5 // allocator. |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 "math/rand" | 10 "math/rand" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if scb.ItemValLength(x, i) != kr4 { | 142 if scb.ItemValLength(x, i) != kr4 { |
143 t.Errorf("expected len: %d, got
%d", | 143 t.Errorf("expected len: %d, got
%d", |
144 kr4, scb.ItemValLength(x
, i)) | 144 kr4, scb.ItemValLength(x
, i)) |
145 } | 145 } |
146 s.ItemDecRef(x, i) | 146 s.ItemDecRef(x, i) |
147 } | 147 } |
148 } else if r < 60 { | 148 } else if r < 60 { |
149 numSets++ | 149 numSets++ |
150 b := arena.Alloc(kr * kr * kr * kr) | 150 b := arena.Alloc(kr * kr * kr * kr) |
151 pri := rand.Int31() | 151 pri := rand.Int31() |
152 » » » » it := scb.ItemAlloc(x, uint16(len(k))) | 152 » » » » it := scb.ItemAlloc(x, uint32(len(k))) |
153 copy(it.Key, k) | 153 copy(it.Key, k) |
154 it.Val = b | 154 it.Val = b |
155 it.Priority = pri | 155 it.Priority = pri |
156 err := x.SetItem(it) | 156 err := x.SetItem(it) |
157 if err != nil { | 157 if err != nil { |
158 t.Errorf("expected nil error, got: %v",
err) | 158 t.Errorf("expected nil error, got: %v",
err) |
159 } | 159 } |
160 scb.ItemDecRef(x, it) | 160 scb.ItemDecRef(x, it) |
161 } else if r < 80 { | 161 } else if r < 80 { |
162 _, err := x.Delete(k) | 162 _, err := x.Delete(k) |
(...skipping 11 matching lines...) Expand all Loading... |
174 } | 174 } |
175 x.EvictSomeItems() | 175 x.EvictSomeItems() |
176 for k := 0; k < numKeys; k++ { | 176 for k := 0; k < numKeys; k++ { |
177 _, err := x.Delete([]byte(fmt.Sprintf("%03d", k))) | 177 _, err := x.Delete([]byte(fmt.Sprintf("%03d", k))) |
178 if err != nil { | 178 if err != nil { |
179 t.Fatalf("expected nil error, got: %v", err) | 179 t.Fatalf("expected nil error, got: %v", err) |
180 } | 180 } |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
OLD | NEW |