github.com/cockroachdb/pebble@v1.1.2/testdata/iterator_bounds_lifetimes (about) 1 new-iter label=first lower=bar upper=foo 2 ---- 3 first: ("bar", "foo") boundsBufIdx=1 4 5 iter label=first 6 first 7 next 8 ---- 9 bb@29: (bb@29, .) 10 bc@30: (bc@30, .) 11 12 # Clone an iterator from the original iterator. The clone should have its own 13 # copy of the bounds. 14 15 clone from=first to=second 16 ---- 17 first: ("bar", "foo") boundsBufIdx=1 18 second: ("bar", "foo") boundsBufIdx=1 19 20 iter label=second 21 last 22 prev 23 ---- 24 fo@150: (fo@150, .) 25 fn@149: (fn@149, .) 26 27 # Changing the bounds on the original should leave the clone's bounds unchanged. 28 29 set-bounds label=first lower=boop 30 ---- 31 first: ("boop", <nil>) boundsBufIdx=0 32 second: ("bar", "foo") boundsBufIdx=1 33 34 iter label=first 35 seek-ge goop 36 ---- 37 gp@178: (gp@178, .) 38 39 iter label=second 40 prev 41 ---- 42 fm@148: (fm@148, .) 43 44 set-bounds label=first lower=boop upper=bop 45 ---- 46 first: ("boop", "bop") boundsBufIdx=1 47 second: ("bar", "foo") boundsBufIdx=1 48 49 # Changing the bounds on the clone should leave the original's bounds unchanged. 50 51 set-options label=second lower=a upper=z 52 ---- 53 first: ("boop", "bop") boundsBufIdx=1 54 second: ("a", "z") boundsBufIdx=0 55 56 # Test no-op set-options. The boundsBufIdx should remain unchanged, reflecting 57 # that the bounds were not copied again. 58 59 set-options label=second lower=a upper=z 60 ---- 61 first: ("boop", "bop") boundsBufIdx=1 62 second: ("a", "z") boundsBufIdx=0 63 64 # Test SetOptions with unchanged bounds but changes to other options. SetOptions 65 # should hold onto the existing bounds buffers. The boundsBufIdx should still 66 # remain unchanged, reflecting that the bounds were not copied. 67 68 set-options label=second lower=a upper=z key-types=both 69 ---- 70 first: ("boop", "bop") boundsBufIdx=1 71 second: ("a", "z") boundsBufIdx=0 72 73 iter label=second 74 seek-ge foo 75 ---- 76 fp@151: (fp@151, .) 77 78 close label=first 79 ---- 80 second: ("a", "z") boundsBufIdx=0 81 82 close label=second 83 ----