github.com/cockroachdb/pebble@v1.1.2/internal/keyspan/testdata/merging_iter (about) 1 # Test a single level. 2 3 define 4 a-c:{(#10,RANGEKEYSET,@5,apples) (#10,RANGEKEYDEL) (#8,RANGEKEYUNSET,@1) (#4,RANGEKEYSET,@3,bananas)} 5 c-d:{(#4,RANGEKEYSET,@3,coconut)} 6 e-f:{(#20,RANGEKEYSET,@5,pineapple) (#20,RANGEKEYSET,@3,guava)} 7 h-j:{(#22,RANGEKEYDEL) (#21,RANGEKEYSET,@5,peaches) (#21,RANGEKEYSET,@3,starfruit)} 8 l-m:{(#2,RANGEKEYUNSET,@9) (#2,RANGEKEYUNSET,@5)} 9 q-z:{(#14,RANGEKEYSET,@9,mangos)} 10 ---- 11 1 levels 12 13 iter 14 first 15 next 16 next 17 next 18 next 19 next 20 next 21 ---- 22 a-c:{(#10,RANGEKEYSET,@5,apples) (#10,RANGEKEYDEL) (#8,RANGEKEYUNSET,@1) (#4,RANGEKEYSET,@3,bananas)} 23 c-d:{(#4,RANGEKEYSET,@3,coconut)} 24 e-f:{(#20,RANGEKEYSET,@5,pineapple) (#20,RANGEKEYSET,@3,guava)} 25 h-j:{(#22,RANGEKEYDEL) (#21,RANGEKEYSET,@5,peaches) (#21,RANGEKEYSET,@3,starfruit)} 26 l-m:{(#2,RANGEKEYUNSET,@9) (#2,RANGEKEYUNSET,@5)} 27 q-z:{(#14,RANGEKEYSET,@9,mangos)} 28 <nil> 29 30 # Test snapshot filtering. 31 32 define snapshot=12 33 a-c:{(#10,RANGEKEYSET,@5,apples) (#10,RANGEKEYDEL) (#8,RANGEKEYUNSET,@1) (#4,RANGEKEYSET,@3,bananas)} 34 c-d:{(#4,RANGEKEYSET,@3,coconut)} 35 e-f:{(#20,RANGEKEYSET,@5,pineapple) (#20,RANGEKEYSET,@3,guava)} 36 h-j:{(#22,RANGEKEYDEL) (#21,RANGEKEYSET,@5,peaches) (#21,RANGEKEYSET,@3,starfruit)} 37 l-m:{(#2,RANGEKEYUNSET,@9) (#2,RANGEKEYUNSET,@5)} 38 q-z:{(#14,RANGEKEYSET,@9,mangos)} 39 ---- 40 1 levels 41 42 iter 43 first 44 next 45 next 46 next 47 next 48 next 49 next 50 ---- 51 a-c:{(#10,RANGEKEYSET,@5,apples) (#10,RANGEKEYDEL) (#8,RANGEKEYUNSET,@1) (#4,RANGEKEYSET,@3,bananas)} 52 c-d:{(#4,RANGEKEYSET,@3,coconut)} 53 e-f:{} 54 h-j:{} 55 l-m:{(#2,RANGEKEYUNSET,@9) (#2,RANGEKEYUNSET,@5)} 56 q-z:{} 57 <nil> 58 59 define 60 b-d:{#10,RANGEKEYSET,@1,apples} 61 e-h:{#8,RANGEKEYDEL} 62 -- 63 a-c:{#3,RANGEKEYUNSET,@1} 64 h-k:{#5,RANGEKEYDEL} 65 ---- 66 2 levels 67 68 iter 69 first 70 next 71 next 72 next 73 next 74 next 75 ---- 76 a-b:{(#3,RANGEKEYUNSET,@1)} 77 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 78 c-d:{(#10,RANGEKEYSET,@1,apples)} 79 e-h:{(#8,RANGEKEYDEL)} 80 h-k:{(#5,RANGEKEYDEL)} 81 <nil> 82 83 iter 84 last 85 prev 86 prev 87 prev 88 prev 89 prev 90 ---- 91 h-k:{(#5,RANGEKEYDEL)} 92 e-h:{(#8,RANGEKEYDEL)} 93 c-d:{(#10,RANGEKEYSET,@1,apples)} 94 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 95 a-b:{(#3,RANGEKEYUNSET,@1)} 96 <nil> 97 98 # Test changing directions at each iterator position, reverse to forward. 99 iter 100 last 101 next 102 last 103 prev 104 next 105 ---- 106 h-k:{(#5,RANGEKEYDEL)} 107 <nil> 108 h-k:{(#5,RANGEKEYDEL)} 109 e-h:{(#8,RANGEKEYDEL)} 110 h-k:{(#5,RANGEKEYDEL)} 111 112 iter 113 last 114 prev 115 prev 116 next 117 ---- 118 h-k:{(#5,RANGEKEYDEL)} 119 e-h:{(#8,RANGEKEYDEL)} 120 c-d:{(#10,RANGEKEYSET,@1,apples)} 121 e-h:{(#8,RANGEKEYDEL)} 122 123 iter 124 last 125 prev 126 prev 127 prev 128 next 129 ---- 130 h-k:{(#5,RANGEKEYDEL)} 131 e-h:{(#8,RANGEKEYDEL)} 132 c-d:{(#10,RANGEKEYSET,@1,apples)} 133 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 134 c-d:{(#10,RANGEKEYSET,@1,apples)} 135 136 iter 137 last 138 prev 139 prev 140 prev 141 prev 142 next 143 ---- 144 h-k:{(#5,RANGEKEYDEL)} 145 e-h:{(#8,RANGEKEYDEL)} 146 c-d:{(#10,RANGEKEYSET,@1,apples)} 147 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 148 a-b:{(#3,RANGEKEYUNSET,@1)} 149 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 150 151 iter 152 last 153 prev 154 prev 155 prev 156 prev 157 prev 158 next 159 ---- 160 h-k:{(#5,RANGEKEYDEL)} 161 e-h:{(#8,RANGEKEYDEL)} 162 c-d:{(#10,RANGEKEYSET,@1,apples)} 163 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 164 a-b:{(#3,RANGEKEYUNSET,@1)} 165 <nil> 166 a-b:{(#3,RANGEKEYUNSET,@1)} 167 168 # Test changing directions at each iterator position, forward to reverse. 169 170 iter 171 first 172 prev 173 first 174 next 175 prev 176 ---- 177 a-b:{(#3,RANGEKEYUNSET,@1)} 178 <nil> 179 a-b:{(#3,RANGEKEYUNSET,@1)} 180 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 181 a-b:{(#3,RANGEKEYUNSET,@1)} 182 183 iter 184 first 185 next 186 next 187 prev 188 ---- 189 a-b:{(#3,RANGEKEYUNSET,@1)} 190 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 191 c-d:{(#10,RANGEKEYSET,@1,apples)} 192 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 193 194 iter 195 first 196 next 197 next 198 next 199 prev 200 ---- 201 a-b:{(#3,RANGEKEYUNSET,@1)} 202 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 203 c-d:{(#10,RANGEKEYSET,@1,apples)} 204 e-h:{(#8,RANGEKEYDEL)} 205 c-d:{(#10,RANGEKEYSET,@1,apples)} 206 207 iter 208 first 209 next 210 next 211 next 212 next 213 next 214 prev 215 ---- 216 a-b:{(#3,RANGEKEYUNSET,@1)} 217 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 218 c-d:{(#10,RANGEKEYSET,@1,apples)} 219 e-h:{(#8,RANGEKEYDEL)} 220 h-k:{(#5,RANGEKEYDEL)} 221 <nil> 222 h-k:{(#5,RANGEKEYDEL)} 223 224 iter 225 first 226 next 227 next 228 next 229 next 230 prev 231 ---- 232 a-b:{(#3,RANGEKEYUNSET,@1)} 233 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 234 c-d:{(#10,RANGEKEYSET,@1,apples)} 235 e-h:{(#8,RANGEKEYDEL)} 236 h-k:{(#5,RANGEKEYDEL)} 237 e-h:{(#8,RANGEKEYDEL)} 238 239 # Test SeekGE. Note that MergingIter's SeekGE implements the FragmentIterator's 240 # SeekGE semantics. It returns the first fragment that covers a key ≥ the search 241 # key. 242 243 iter 244 seek-ge cc 245 ---- 246 c-d:{(#10,RANGEKEYSET,@1,apples)} 247 248 iter 249 seek-ge 1 250 seek-ge a 251 seek-ge b 252 seek-ge bb 253 ---- 254 a-b:{(#3,RANGEKEYUNSET,@1)} 255 a-b:{(#3,RANGEKEYUNSET,@1)} 256 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 257 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 258 259 iter 260 seek-ge c 261 seek-ge cc 262 seek-ge e 263 seek-ge f 264 ---- 265 c-d:{(#10,RANGEKEYSET,@1,apples)} 266 c-d:{(#10,RANGEKEYSET,@1,apples)} 267 e-h:{(#8,RANGEKEYDEL)} 268 e-h:{(#8,RANGEKEYDEL)} 269 270 iter 271 seek-ge h 272 seek-ge i 273 seek-ge k 274 seek-ge l 275 ---- 276 h-k:{(#5,RANGEKEYDEL)} 277 h-k:{(#5,RANGEKEYDEL)} 278 <nil> 279 <nil> 280 281 # Test SeekLT. Note that MergingIter's SeekLT implements the FragmentIterator's 282 # SeekLT semantics. It returns the first fragment with a Start key < the search 283 # key, NOT the first fragment that covers a key < the search key. 284 # 285 # NB: seek-lt bb finds b-c#3.RANGEKEYUNSET (the last fragment with the bounds 286 # [b,c), unlike the above seek-ge b which finds the first). 287 288 iter 289 seek-lt b 290 ---- 291 a-b:{(#3,RANGEKEYUNSET,@1)} 292 293 iter 294 seek-lt 1 295 seek-lt a 296 seek-lt aa 297 seek-lt b 298 seek-lt bb 299 seek-lt c 300 ---- 301 <nil> 302 <nil> 303 a-b:{(#3,RANGEKEYUNSET,@1)} 304 a-b:{(#3,RANGEKEYUNSET,@1)} 305 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 306 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 307 308 iter 309 seek-lt cc 310 seek-lt d 311 seek-lt dd 312 seek-lt e 313 seek-lt ee 314 seek-lt h 315 seek-lt hh 316 seek-lt k 317 seek-lt z 318 ---- 319 c-d:{(#10,RANGEKEYSET,@1,apples)} 320 c-d:{(#10,RANGEKEYSET,@1,apples)} 321 c-d:{(#10,RANGEKEYSET,@1,apples)} 322 c-d:{(#10,RANGEKEYSET,@1,apples)} 323 e-h:{(#8,RANGEKEYDEL)} 324 e-h:{(#8,RANGEKEYDEL)} 325 h-k:{(#5,RANGEKEYDEL)} 326 h-k:{(#5,RANGEKEYDEL)} 327 h-k:{(#5,RANGEKEYDEL)} 328 329 define 330 a-f:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL)} 331 k-s:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL)} 332 ---- 333 1 levels 334 335 iter 336 first 337 prev 338 next 339 ---- 340 a-f:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL)} 341 <nil> 342 a-f:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL)} 343 344 iter 345 last 346 next 347 prev 348 ---- 349 k-s:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL)} 350 <nil> 351 k-s:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL)} 352 353 define 354 w-x:{(#5,RANGEKEYDEL) (#3,RANGEKEYDEL)} 355 x-z:{(#5,RANGEKEYDEL)} 356 -- 357 w-y:{(#4,RANGEKEYDEL) (#1,RANGEKEYDEL)} 358 ---- 359 2 levels 360 361 iter 362 last 363 next 364 prev 365 first 366 prev 367 next 368 ---- 369 y-z:{(#5,RANGEKEYDEL)} 370 <nil> 371 y-z:{(#5,RANGEKEYDEL)} 372 w-x:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL) (#3,RANGEKEYDEL) (#1,RANGEKEYDEL)} 373 <nil> 374 w-x:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL) (#3,RANGEKEYDEL) (#1,RANGEKEYDEL)} 375 376 iter 377 seek-ge x 378 prev 379 seek-ge xray 380 prev 381 ---- 382 x-y:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL) (#1,RANGEKEYDEL)} 383 w-x:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL) (#3,RANGEKEYDEL) (#1,RANGEKEYDEL)} 384 x-y:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL) (#1,RANGEKEYDEL)} 385 w-x:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL) (#3,RANGEKEYDEL) (#1,RANGEKEYDEL)} 386 387 define 388 il-qb:{(#10,RANGEKEYDEL)} 389 sn-wn:{(#10,RANGEKEYDEL)} 390 -- 391 qt-kh:{(#9,RANGEKEYDEL) (#8,RANGEKEYDEL) (#7,RANGEKEYDEL)} 392 ky-sv:{(#8,RANGEKEYDEL) (#7,RANGEKEYDEL)} 393 -- 394 as-fz:{(#5,RANGEKEYDEL) (#4,RANGEKEYDEL)} 395 hh-ir:{(#4,RANGEKEYDEL)} 396 rf-yx:{(#4,RANGEKEYDEL)} 397 ---- 398 3 levels 399 400 iter 401 seek-ge qp 402 next 403 next 404 next 405 next 406 next 407 seek-ge yz 408 prev 409 ---- 410 qb-rf:{(#8,RANGEKEYDEL) (#7,RANGEKEYDEL)} 411 rf-sn:{(#8,RANGEKEYDEL) (#7,RANGEKEYDEL) (#4,RANGEKEYDEL)} 412 sn-sv:{(#10,RANGEKEYDEL) (#8,RANGEKEYDEL) (#7,RANGEKEYDEL) (#4,RANGEKEYDEL)} 413 sv-wn:{(#10,RANGEKEYDEL) (#4,RANGEKEYDEL)} 414 wn-yx:{(#4,RANGEKEYDEL)} 415 <nil> 416 <nil> 417 wn-yx:{(#4,RANGEKEYDEL)} 418 419 # Test that empty spans from child iterators are preserved 420 define 421 b-d:{#10,RANGEKEYSET,@1,apples} 422 e-f:{} 423 g-h:{#8,RANGEKEYDEL} 424 -- 425 a-c:{#3,RANGEKEYUNSET,@1} 426 h-k:{#5,RANGEKEYDEL} 427 k-m:{} 428 ---- 429 2 levels 430 431 iter 432 first 433 next 434 next 435 next 436 next 437 next 438 next 439 next 440 ---- 441 a-b:{(#3,RANGEKEYUNSET,@1)} 442 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 443 c-d:{(#10,RANGEKEYSET,@1,apples)} 444 e-f:{} 445 g-h:{(#8,RANGEKEYDEL)} 446 h-k:{(#5,RANGEKEYDEL)} 447 k-m:{} 448 <nil> 449 450 iter 451 last 452 prev 453 prev 454 prev 455 prev 456 prev 457 prev 458 prev 459 ---- 460 k-m:{} 461 h-k:{(#5,RANGEKEYDEL)} 462 g-h:{(#8,RANGEKEYDEL)} 463 e-f:{} 464 c-d:{(#10,RANGEKEYSET,@1,apples)} 465 b-c:{(#10,RANGEKEYSET,@1,apples) (#3,RANGEKEYUNSET,@1)} 466 a-b:{(#3,RANGEKEYUNSET,@1)} 467 <nil>