github.com/cockroachdb/pebble@v1.1.2/testdata/external_iterator (about)

     1  build 1
     2  set b b
     3  set c c
     4  ----
     5  
     6  build 2
     7  del-range c z
     8  ----
     9  
    10  # Test that a delete range in a more recent file shadows keys in an
    11  # earlier file.
    12  
    13  iter files=(1)
    14  first
    15  next
    16  next
    17  ----
    18  b: (b, .)
    19  c: (c, .)
    20  .
    21  
    22  iter files=(1)
    23  seek-ge bb
    24  next
    25  ----
    26  c: (c, .)
    27  .
    28  
    29  iter files=(2, 1) fwd-only
    30  first
    31  next
    32  ----
    33  b: (b, .)
    34  .
    35  
    36  build 3
    37  set a a
    38  set f f
    39  ----
    40  
    41  # Test including an even more recent file with point keys overlapping
    42  # the rangedel. Since the point keys are assigned a higher sequence
    43  # number, they should NOT be shadowed by the rangedel.
    44  
    45  iter files=(3, 2, 1) fwd-only
    46  first
    47  next
    48  next
    49  next
    50  ----
    51  a: (a, .)
    52  b: (b, .)
    53  f: (f, .)
    54  .
    55  
    56  # Test including range keys, and merging the range key state across
    57  # files. Range keys should be interleaved.
    58  
    59  build 4
    60  range-key-set a c @2 foo
    61  range-key-set c e @3 bar
    62  ----
    63  
    64  build 5
    65  range-key-del b d
    66  ----
    67  
    68  iter files=(5, 4, 3, 2, 1) fwd-only
    69  first
    70  next
    71  next
    72  next
    73  next
    74  ----
    75  a: (a, [a-b) @2=foo UPDATED)
    76  b: (b, . UPDATED)
    77  d: (., [d-e) @3=bar UPDATED)
    78  f: (f, . UPDATED)
    79  .
    80  
    81  # Test including range keys with empty spans and a merge in between. At no point
    82  # should an empty span be returned.
    83  
    84  build 6
    85  merge bb ac
    86  ----
    87  
    88  iter files=(6, 5, 4, 3, 2, 1)
    89  seek-lt c
    90  prev
    91  next
    92  next
    93  ----
    94  bb: (ac, .)
    95  b: (b, .)
    96  bb: (ac, .)
    97  d: (., [d-e) @3=bar UPDATED)
    98  
    99  iter files=(6, 5, 4, 3, 2, 1)
   100  seek-ge b
   101  next
   102  prev
   103  prev
   104  next
   105  next
   106  next
   107  ----
   108  b: (b, .)
   109  bb: (ac, .)
   110  b: (b, .)
   111  a: (a, [a-b) @2=foo UPDATED)
   112  b: (b, . UPDATED)
   113  bb: (ac, .)
   114  d: (., [d-e) @3=bar UPDATED)
   115  
   116  # Test range keys that overlap each other with identical state. These
   117  # should be defragmented and exposed as a single range key.
   118  
   119  reset
   120  ----
   121  
   122  build ag
   123  range-key-set a g @5 foo
   124  ----
   125  
   126  build ek
   127  range-key-set e k @5 foo
   128  ----
   129  
   130  iter files=(ag, ek) fwd-only
   131  first
   132  next
   133  ----
   134  a: (., [a-k) @5=foo UPDATED)
   135  .
   136  
   137  # Test range-key masking by creating points, some with suffixes above
   138  # the range key's suffix, some with suffixes below the range key's
   139  # suffix.
   140  
   141  build points
   142  set a@4 v
   143  set c@2 v
   144  set d@9 v
   145  set e@5 v
   146  set k@3 v
   147  set p@4 v
   148  ----
   149  
   150  iter files=(points, ag, ek) mask-suffix=@7 fwd-only
   151  first
   152  next
   153  next
   154  next
   155  next
   156  next
   157  ----
   158  a: (., [a-k) @5=foo UPDATED)
   159  d@9: (v, [a-k) @5=foo)
   160  e@5: (v, [a-k) @5=foo)
   161  k@3: (v, . UPDATED)
   162  p@4: (v, .)
   163  .
   164  
   165  # Test that 'stacked' range keys (eg, multiple defined over the same keyspan at
   166  # varying suffixes) work  as expected.
   167  
   168  build stacked
   169  range-key-set a k @4 bar
   170  range-key-set a k @1 bax
   171  ----
   172  
   173  iter files=(points, ag, ek, stacked) fwd-only
   174  first
   175  next
   176  ----
   177  a: (., [a-k) @5=foo, @4=bar, @1=bax UPDATED)
   178  a@4: (v, [a-k) @5=foo, @4=bar, @1=bax)
   179  
   180  # Test mutating the external iterator's options through SetOptions.
   181  
   182  iter files=(points, ag, ek) fwd-only
   183  set-options key-types=point
   184  first
   185  next
   186  set-options lower=e upper=p
   187  first
   188  next
   189  ----
   190  .
   191  a@4: (v, .)
   192  c@2: (v, .)
   193  .
   194  e@5: (v, .)
   195  k@3: (v, .)
   196  
   197  # Test the TrySeekUsingNext optimization that's enabled only for fwd-only
   198  # external iterators. Seed the database with keys like 'a', 'aa', 'aaa', etc so
   199  # that the index block uses a final separator that's beyond all the other live
   200  # keys.
   201  
   202  reset
   203  ----
   204  
   205  build a
   206  set a@3 a@3
   207  set a@1 a@1
   208  ----
   209  
   210  build aa
   211  set aa@3 aa@3
   212  set aa@1 aa@1
   213  ----
   214  
   215  build aaa
   216  set aaa@3 aaa@3
   217  set aaa@1 aaa@1
   218  ----
   219  
   220  build aaaa
   221  set aaaa@3 aaaa@3
   222  set aaaa@1 aaaa@1
   223  ----
   224  
   225  build aaaaa
   226  set aaaaa@3 aaaaa@3
   227  set aaaaa@1 aaaaa@1
   228  ----
   229  
   230  # Note the absence of fwd-only. This iterator will not use the TrySeekUsingNext
   231  # optimization.
   232  
   233  iter files=(a, aa, aaa, aaaa, aaaaa)
   234  seek-ge a
   235  next
   236  seek-ge aa
   237  next
   238  seek-ge aaa
   239  next
   240  seek-ge aaaa
   241  next
   242  seek-ge aaaaa
   243  next
   244  stats
   245  ----
   246  a@3: (a@3, .)
   247  a@1: (a@1, .)
   248  aa@3: (aa@3, .)
   249  aa@1: (aa@1, .)
   250  aaa@3: (aaa@3, .)
   251  aaa@1: (aaa@1, .)
   252  aaaa@3: (aaaa@3, .)
   253  aaaa@1: (aaaa@1, .)
   254  aaaaa@3: (aaaaa@3, .)
   255  aaaaa@1: (aaaaa@1, .)
   256  stats: seeked 5 times (5 internal); stepped 5 times (5 internal); blocks: 0B cached, 475B not cached (read time: 0s); points: 10 (50B keys, 50B values)
   257  
   258  # Note the inclusion of fwd-only. This iterator will use the TrySeekUsingNext
   259  # optimization and loads ~half the block-bytes as a result.
   260  
   261  iter files=(a, aa, aaa, aaaa, aaaaa) fwd-only
   262  seek-ge a
   263  next
   264  seek-ge aa
   265  next
   266  seek-ge aaa
   267  next
   268  seek-ge aaaa
   269  next
   270  seek-ge aaaaa
   271  next
   272  stats
   273  ----
   274  a@3: (a@3, .)
   275  a@1: (a@1, .)
   276  aa@3: (aa@3, .)
   277  aa@1: (aa@1, .)
   278  aaa@3: (aaa@3, .)
   279  aaa@1: (aaa@1, .)
   280  aaaa@3: (aaaa@3, .)
   281  aaaa@1: (aaaa@1, .)
   282  aaaaa@3: (aaaaa@3, .)
   283  aaaaa@1: (aaaaa@1, .)
   284  stats: seeked 5 times (5 internal); stepped 5 times (5 internal); blocks: 0B cached, 281B not cached (read time: 0s); points: 10 (50B keys, 50B values)