github.com/cockroachdb/pebble@v1.1.1-0.20240513155919-3622ade60459/testdata/iterator_read_sampling (about) 1 # Test with overlapping keys across levels, should pick top level to compact after allowed-seeks goes to 0 2 # Verify that Iterator.First(), Iterator.SeekGE() and Iterator.Next() call maybe sample read. 3 define auto-compactions=off 4 L0 5 a.SET.4:4 6 L1 7 a.SET.3:3 8 L2 9 d.SET.2:2 10 L3 11 d.SET.1:1 12 ---- 13 0.0: 14 000004:[a#4,SET-a#4,SET] 15 1: 16 000005:[a#3,SET-a#3,SET] 17 2: 18 000006:[d#2,SET-d#2,SET] 19 3: 20 000007:[d#1,SET-d#1,SET] 21 22 set allowed-seeks=2 23 ---- 24 25 26 iter 27 first 28 ---- 29 a: (4, .) 30 31 iter-read-compactions 32 ---- 33 (none) 34 35 iter 36 first 37 ---- 38 a: (4, .) 39 40 iter-read-compactions 41 ---- 42 (level: 0, start: a, end: a) 43 44 read-compactions 45 ---- 46 (none) 47 48 close-iter 49 ---- 50 51 read-compactions 52 ---- 53 (level: 0, start: a, end: a) 54 55 iter 56 seek-ge d 57 ---- 58 d: (2, .) 59 60 iter 61 prev 62 ---- 63 a: (4, .) 64 65 iter 66 next 67 ---- 68 d: (2, .) 69 70 iter-read-compactions 71 ---- 72 (level: 2, start: d, end: d) 73 74 close-iter 75 ---- 76 77 read-compactions 78 ---- 79 (level: 0, start: a, end: a) 80 (level: 2, start: d, end: d) 81 82 83 84 # Verify that Iterator.Last(), Iterator.SeekLT() and Iterator.Prev() call maybe sample read. 85 define auto-compactions=off 86 L0 87 a.SET.4:4 88 c.SET.8:8 89 L1 90 a.SET.3:3 91 c.SET.9:9 92 L2 93 d.SET.2:2 94 l.SET.7:7 95 L3 96 d.SET.1:1 97 l.SET.8:8 98 ---- 99 0.0: 100 000004:[a#4,SET-c#8,SET] 101 1: 102 000005:[a#3,SET-c#9,SET] 103 2: 104 000006:[d#2,SET-l#7,SET] 105 3: 106 000007:[d#1,SET-l#8,SET] 107 108 set allowed-seeks=2 109 ---- 110 111 112 iter 113 last 114 ---- 115 l: (8, .) 116 117 iter-read-compactions 118 ---- 119 (none) 120 121 iter 122 last 123 ---- 124 l: (8, .) 125 126 iter-read-compactions 127 ---- 128 (level: 2, start: d, end: l) 129 130 read-compactions 131 ---- 132 (none) 133 134 close-iter 135 ---- 136 137 read-compactions 138 ---- 139 (level: 2, start: d, end: l) 140 141 iter 142 seek-lt d 143 ---- 144 c: (9, .) 145 146 iter 147 next 148 ---- 149 d: (2, .) 150 151 iter 152 prev 153 ---- 154 c: (9, .) 155 156 iter-read-compactions 157 ---- 158 (level: 0, start: a, end: c) 159 160 close-iter 161 ---- 162 163 read-compactions 164 ---- 165 (level: 2, start: d, end: l) 166 (level: 0, start: a, end: c) 167 168 169 # For Iterator.Last(), Iterator.SeekLT() and Iterator.Prev(), if the key is the first key of the file or 170 # the only key, sampling skips it because the iterator has already moved past it. 171 define auto-compactions=off 172 L0 173 a.SET.4:4 174 L1 175 a.SET.3:3 176 L2 177 d.SET.2:2 178 L3 179 d.SET.1:1 180 ---- 181 0.0: 182 000004:[a#4,SET-a#4,SET] 183 1: 184 000005:[a#3,SET-a#3,SET] 185 2: 186 000006:[d#2,SET-d#2,SET] 187 3: 188 000007:[d#1,SET-d#1,SET] 189 190 set allowed-seeks=2 191 ---- 192 193 194 iter 195 last 196 ---- 197 d: (2, .) 198 199 iter-read-compactions 200 ---- 201 (none) 202 203 iter 204 last 205 ---- 206 d: (2, .) 207 208 iter-read-compactions 209 ---- 210 (none) 211 212 read-compactions 213 ---- 214 (none) 215 216 close-iter 217 ---- 218 219 read-compactions 220 ---- 221 (none) 222 223 iter 224 seek-lt d 225 ---- 226 a: (4, .) 227 228 iter 229 next 230 ---- 231 d: (2, .) 232 233 iter 234 prev 235 ---- 236 a: (4, .) 237 238 iter-read-compactions 239 ---- 240 (none) 241 242 close-iter 243 ---- 244 245 read-compactions 246 ---- 247 (none) 248 249 250 251 252 # Test with no overlapping keys across levels, should not pick any compaction 253 define auto-compactions=off 254 L0 255 a.SET.4:4 256 L1 257 b.SET.3:3 258 L2 259 c.SET.2:2 260 L3 261 d.SET.1:1 262 ---- 263 0.0: 264 000004:[a#4,SET-a#4,SET] 265 1: 266 000005:[b#3,SET-b#3,SET] 267 2: 268 000006:[c#2,SET-c#2,SET] 269 3: 270 000007:[d#1,SET-d#1,SET] 271 272 set allowed-seeks=3 273 ---- 274 275 iter 276 first 277 ---- 278 a: (4, .) 279 280 iter 281 first 282 ---- 283 a: (4, .) 284 285 iter 286 first 287 ---- 288 a: (4, .) 289 290 iter-read-compactions 291 ---- 292 (none) 293 294 close-iter 295 ---- 296 297 read-compactions 298 ---- 299 (none) 300 301 # Test to see if the allowedSeeks associated with a file 302 # is reset once it hits 0. 303 define auto-compactions=off 304 L0 305 a.SET.4:4 306 c.SET.8:8 307 L1 308 a.SET.3:3 309 c.SET.9:9 310 L2 311 d.SET.2:2 312 l.SET.7:7 313 L3 314 d.SET.1:1 315 l.SET.8:8 316 ---- 317 0.0: 318 000004:[a#4,SET-c#8,SET] 319 1: 320 000005:[a#3,SET-c#9,SET] 321 2: 322 000006:[d#2,SET-l#7,SET] 323 3: 324 000007:[d#1,SET-l#8,SET] 325 326 set allowed-seeks=1 327 ---- 328 329 iter 330 last 331 ---- 332 l: (8, .) 333 334 iter-read-compactions 335 ---- 336 (level: 2, start: d, end: l) 337 338 close-iter 339 ---- 340 341 read-compactions 342 ---- 343 (level: 2, start: d, end: l) 344 345 # The allowedSeeks on this file should have been reset. 346 # Since the value of allowedSeeks determined 347 # by the code is 100, we check if allowed-seeks has been 348 # reset to 100. 349 show allowed-seeks=(000006,) 350 ---- 351 100