github.com/cockroachdb/pebble@v1.1.2/internal/keyspan/testdata/level_iter (about) 1 2 # Simple case. 3 4 define 5 file 6 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 7 file 8 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 9 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 10 ---- 11 12 iter 13 seek-ge a 14 seek-ge apple 15 seek-ge b 16 seek-ge banana 17 seek-ge c 18 seek-ge cantalope 19 seek-ge d 20 seek-ge dragonfruit 21 ---- 22 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 23 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 24 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 25 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 26 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 27 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 28 . 29 . 30 31 iter 32 seek-lt a 33 seek-lt apple 34 seek-lt b 35 seek-lt banana 36 seek-lt c 37 seek-lt cantalope 38 seek-lt d 39 seek-lt dragonfruit 40 prev 41 ---- 42 . 43 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 44 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 45 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 46 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 47 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 48 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 49 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 50 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 51 52 iter 53 seek-ge a 54 prev 55 seek-lt d 56 next 57 ---- 58 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 59 . 60 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 61 . 62 63 iter 64 first 65 next 66 next 67 next 68 ---- 69 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 70 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 71 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 72 . 73 74 iter 75 last 76 prev 77 prev 78 prev 79 ---- 80 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 81 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 82 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 83 . 84 85 # Set some bounds 86 87 iter 88 seek-ge a 89 seek-ge b 90 seek-ge c 91 seek-ge d 92 seek-lt a 93 seek-lt b 94 seek-lt c 95 seek-lt d 96 ---- 97 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 98 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 99 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 100 . 101 . 102 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 103 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 104 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 105 106 107 iter 108 seek-lt cc 109 prev 110 prev 111 prev 112 ---- 113 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 114 b-c:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 115 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 116 . 117 118 # Test skipping over empty/point-key-only files in both directions. 119 120 define 121 file 122 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 123 file 124 point:b.SET.1:foo 125 file 126 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 127 d-e:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 128 ---- 129 130 num-files 131 ---- 132 3 133 134 iter 135 first 136 next 137 next 138 next 139 ---- 140 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 141 b-c:{} (file = 000001.sst) 142 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 143 d-e:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 144 145 iter 146 last 147 prev 148 prev 149 prev 150 ---- 151 d-e:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 152 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 153 b-c:{} (file = 000003.sst) 154 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 155 156 # Test straddle keys between files. 157 158 define 159 file 160 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 161 file 162 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 163 file 164 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 165 file 166 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 167 ---- 168 169 iter 170 first 171 next 172 next 173 next 174 next 175 next 176 next 177 next 178 ---- 179 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 180 b-c:{} (file = 000001.sst) 181 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 182 d-e:{} (file = 000002.sst) 183 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 184 f-g:{} (file = 000003.sst) 185 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000004.sst) 186 . 187 188 iter 189 last 190 prev 191 prev 192 prev 193 prev 194 prev 195 prev 196 prev 197 ---- 198 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000004.sst) 199 f-g:{} (file = 000004.sst) 200 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 201 d-e:{} (file = 000003.sst) 202 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 203 b-c:{} (file = 000002.sst) 204 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 205 . 206 207 # The below case seeks into a file straddle, then iterates forward and back to 208 # it, and confirms that changing iterator directions on a straddle does the 209 # right thing. 210 211 iter 212 seek-ge bb 213 next 214 prev 215 next 216 prev 217 prev 218 ---- 219 b-c:{} (file = 000001.sst) 220 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 221 b-c:{} (file = 000002.sst) 222 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 223 b-c:{} (file = 000002.sst) 224 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 225 226 # The same case as above, but with inverted directions. 227 228 iter 229 seek-lt dd 230 prev 231 next 232 prev 233 next 234 next 235 ---- 236 d-e:{} (file = 000001.sst) 237 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 238 d-e:{} (file = 000002.sst) 239 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 240 d-e:{} (file = 000002.sst) 241 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 242 243 iter 244 seek-lt dd 245 prev 246 next 247 prev 248 next 249 next 250 ---- 251 d-e:{} (file = 000003.sst) 252 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 253 d-e:{} (file = 000002.sst) 254 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 255 d-e:{} (file = 000002.sst) 256 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 257 258 # Seeks right at the bound should return nothing. 259 260 iter 261 seek-lt bb 262 ---- 263 b-c:{} (file = 000003.sst) 264 265 iter 266 seek-ge dd 267 ---- 268 d-e:{} (file = 000003.sst) 269 270 iter 271 seek-lt d 272 prev 273 next 274 prev 275 prev 276 prev 277 next 278 next 279 ---- 280 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 281 b-c:{} (file = 000002.sst) 282 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 283 b-c:{} (file = 000002.sst) 284 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 285 . 286 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 287 b-c:{} (file = 000001.sst) 288 289 # A bunch of files with point keys only should not fragment straddles. 290 291 define 292 file 293 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 294 file 295 point:c.SET.1:foo 296 file 297 point:d.SET.1:foo 298 file 299 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 300 file 301 point:g.SET.1:foo 302 file 303 h-i:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 304 ---- 305 306 iter 307 first 308 next 309 next 310 next 311 next 312 next 313 ---- 314 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 315 b-e:{} (file = 000001.sst) 316 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000004.sst) 317 f-h:{} (file = 000004.sst) 318 h-i:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000006.sst) 319 . 320 321 iter 322 last 323 prev 324 prev 325 prev 326 prev 327 prev 328 ---- 329 h-i:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000006.sst) 330 f-h:{} (file = 000006.sst) 331 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000004.sst) 332 b-e:{} (file = 000004.sst) 333 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 334 . 335 336 # Test files with range keys and rangedels 337 338 define 339 file 340 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 341 point:a.SET.1:foo 342 point:b.SET.1:foo 343 file 344 c-e:{(#3,RANGEKEYSET,@3,baz) (#3,RANGEKEYSET,@1,bar)} 345 point:c.RANGEDEL.2:f 346 point:d.SET.1:foo 347 file 348 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 349 i-j:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 350 point:f.RANGEDEL.2:g 351 ---- 352 353 iter rangedel 354 first 355 next 356 next 357 next 358 ---- 359 c-f:{(#2,RANGEDEL)} (file = 000002.sst) 360 f-g:{(#2,RANGEDEL)} (file = 000003.sst) 361 . 362 . 363 364 iter rangedel 365 last 366 prev 367 prev 368 prev 369 ---- 370 f-g:{(#2,RANGEDEL)} (file = 000003.sst) 371 c-f:{(#2,RANGEDEL)} (file = 000002.sst) 372 . 373 . 374 375 iter rangedel 376 seek-ge c 377 next 378 next 379 ---- 380 c-f:{(#2,RANGEDEL)} (file = 000002.sst) 381 f-g:{(#2,RANGEDEL)} (file = 000003.sst) 382 . 383 384 iter rangedel 385 seek-lt ff 386 prev 387 next 388 prev 389 prev 390 ---- 391 f-g:{(#2,RANGEDEL)} (file = 000003.sst) 392 c-f:{(#2,RANGEDEL)} (file = 000002.sst) 393 f-g:{(#2,RANGEDEL)} (file = 000003.sst) 394 c-f:{(#2,RANGEDEL)} (file = 000002.sst) 395 . 396 397 close-iter 398 ---- 399 ok 400 401 # Test that a regular LevelIter ignores rangedels and emits straddle spans. 402 403 iter 404 first 405 next 406 next 407 next 408 next 409 next 410 ---- 411 a-b:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 412 b-c:{} (file = 000001.sst) 413 c-e:{(#3,RANGEKEYSET,@3,baz) (#3,RANGEKEYSET,@1,bar)} (file = 000002.sst) 414 e-g:{} (file = 000002.sst) 415 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 416 i-j:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 417 418 iter 419 seek-ge c 420 next 421 next 422 next 423 next 424 ---- 425 c-e:{(#3,RANGEKEYSET,@3,baz) (#3,RANGEKEYSET,@1,bar)} (file = 000002.sst) 426 e-g:{} (file = 000002.sst) 427 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 428 i-j:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 429 . 430 431 # Test seeking outside of bounds with straddles. 432 433 define 434 file 435 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 436 file 437 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 438 file 439 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} 440 ---- 441 442 iter 443 seek-lt j 444 next 445 prev 446 prev 447 ---- 448 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 449 . 450 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 451 f-g:{} (file = 000003.sst) 452 453 iter 454 seek-lt j 455 prev 456 prev 457 next 458 next 459 ---- 460 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 461 f-g:{} (file = 000003.sst) 462 e-f:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000002.sst) 463 f-g:{} (file = 000002.sst) 464 g-h:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000003.sst) 465 466 iter 467 seek-ge a 468 prev 469 next 470 next 471 ---- 472 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 473 . 474 c-d:{(#2,RANGEKEYSET,@3,foo) (#1,RANGEKEYSET,@1,bar)} (file = 000001.sst) 475 d-e:{} (file = 000001.sst)