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

     1  reset
     2  ----
     3  
     4  # Use the key string as the value so that it's easy to tell when we surface the
     5  # wrong value.
     6  
     7  batch commit
     8  set a a
     9  set b b
    10  set c c
    11  set d d
    12  range-key-set b   c   @5 boop
    13  range-key-set cat dog @3 beep
    14  ----
    15  committed 6 keys
    16  
    17  # Scan forward
    18  
    19  combined-iter
    20  seek-ge a
    21  next
    22  next
    23  next
    24  next
    25  next
    26  ----
    27  a: (a, .)
    28  b: (b, [b-c) @5=boop UPDATED)
    29  c: (c, . UPDATED)
    30  cat: (., [cat-dog) @3=beep UPDATED)
    31  d: (d, [cat-dog) @3=beep)
    32  .
    33  
    34  # Do the above forward iteration but with a mask suffix. The results should be
    35  # identical despite range keys serving as masks, because none of the point keys
    36  # have suffixes.
    37  
    38  combined-iter mask-suffix=@9
    39  seek-ge a
    40  next
    41  next
    42  next
    43  next
    44  next
    45  ----
    46  a: (a, .)
    47  b: (b, [b-c) @5=boop UPDATED)
    48  c: (c, . UPDATED)
    49  cat: (., [cat-dog) @3=beep UPDATED)
    50  d: (d, [cat-dog) @3=beep)
    51  .
    52  
    53  # Scan backward
    54  
    55  combined-iter
    56  seek-lt z
    57  prev
    58  prev
    59  prev
    60  prev
    61  prev
    62  ----
    63  d: (d, [cat-dog) @3=beep UPDATED)
    64  cat: (., [cat-dog) @3=beep)
    65  c: (c, . UPDATED)
    66  b: (b, [b-c) @5=boop UPDATED)
    67  a: (a, . UPDATED)
    68  .
    69  
    70  combined-iter
    71  seek-ge ace
    72  seek-ge b
    73  seek-ge c
    74  seek-ge cab
    75  seek-ge cat
    76  seek-ge d
    77  seek-ge day
    78  seek-ge dog
    79  ----
    80  b: (b, [b-c) @5=boop UPDATED)
    81  b: (b, [b-c) @5=boop)
    82  c: (c, . UPDATED)
    83  cat: (., [cat-dog) @3=beep UPDATED)
    84  cat: (., [cat-dog) @3=beep)
    85  d: (d, [cat-dog) @3=beep)
    86  day: (., [cat-dog) @3=beep)
    87  .
    88  
    89  combined-iter
    90  seek-lt 1
    91  seek-lt ace
    92  seek-lt b
    93  seek-lt c
    94  seek-lt cab
    95  seek-lt cat
    96  seek-lt d
    97  seek-lt day
    98  seek-lt dog
    99  seek-lt zebra
   100  ----
   101  .
   102  a: (a, .)
   103  a: (a, .)
   104  b: (b, [b-c) @5=boop UPDATED)
   105  c: (c, . UPDATED)
   106  c: (c, .)
   107  cat: (., [cat-dog) @3=beep UPDATED)
   108  d: (d, [cat-dog) @3=beep)
   109  d: (d, [cat-dog) @3=beep)
   110  d: (d, [cat-dog) @3=beep)
   111  
   112  rangekey-iter
   113  first
   114  next
   115  next
   116  set-bounds lower=bat upper=catatonic
   117  first
   118  next
   119  next
   120  ----
   121  b [b-c) @5=boop UPDATED
   122  cat [cat-dog) @3=beep UPDATED
   123  .
   124  .
   125  bat [bat-c) @5=boop UPDATED
   126  cat [cat-catatonic) @3=beep UPDATED
   127  .
   128  
   129  rangekey-iter
   130  seek-ge bat
   131  ----
   132  bat [b-c) @5=boop UPDATED
   133  
   134  # Delete 'b': The Iterator should still stop at b because of the range key
   135  # with a start boundary at b.
   136  
   137  batch commit
   138  del b
   139  ----
   140  committed 1 keys
   141  
   142  combined-iter
   143  seek-ge b
   144  seek-ge ace
   145  ----
   146  b: (., [b-c) @5=boop UPDATED)
   147  b: (., [b-c) @5=boop)
   148  
   149  rangekey-iter
   150  seek-ge b
   151  seek-ge ace
   152  ----
   153  b [b-c) @5=boop UPDATED
   154  b [b-c) @5=boop
   155  
   156  # Delete the b-c range key and the beginning of the cat-dog range key,
   157  # truncating it to now begin at 'd'.
   158  
   159  batch name=indexed
   160  range-key-del b d
   161  ----
   162  wrote 1 keys to batch "indexed"
   163  
   164  # Reading through the indexed batch, we should see the beginning of the cat-dog
   165  # range key now beginning at 'd'.
   166  
   167  combined-iter reader=indexed
   168  seek-ge b
   169  next
   170  ----
   171  c: (c, .)
   172  d: (d, [d-dog) @3=beep UPDATED)
   173  
   174  commit batch=indexed
   175  ----
   176  committed 1 keys
   177  
   178  # Reading through the database after applying the batch, we should still see the
   179  # beginning of the cat-dog range key now beginning at 'd'.
   180  
   181  combined-iter
   182  seek-ge b
   183  next
   184  ----
   185  c: (c, .)
   186  d: (d, [d-dog) @3=beep UPDATED)
   187  
   188  # Reading through the database after flushing, we should still see the
   189  # beginning of the cat-dog range key now beginning at 'd'.
   190  
   191  flush
   192  ----
   193  
   194  combined-iter
   195  seek-ge b
   196  next
   197  ----
   198  c: (c, .)
   199  d: (d, [d-dog) @3=beep UPDATED)
   200  
   201  
   202  reset
   203  ----
   204  
   205  batch commit
   206  range-key-set c d @1 boop
   207  range-key-set apple c @3 beep
   208  range-key-set ace apple @3 beep
   209  set a a1
   210  set b b1
   211  set c c1
   212  del a
   213  set b b2
   214  set c c2
   215  ----
   216  committed 9 keys
   217  
   218  # Test that reverse iteration surfaces range key start boundaries alongside
   219  # point keys at the same key, and defragments logically equivalent ranges.
   220  
   221  combined-iter
   222  last
   223  prev
   224  prev
   225  prev
   226  ----
   227  c: (c2, [c-d) @1=boop UPDATED)
   228  b: (b2, [ace-c) @3=beep UPDATED)
   229  ace: (., [ace-c) @3=beep)
   230  .
   231  
   232  # Test that forward iteration surfaces range key start boundaries alongside
   233  # point keys at the same key, and defragments logically equivalent ranges.
   234  
   235  combined-iter
   236  first
   237  next
   238  next
   239  next
   240  ----
   241  ace: (., [ace-c) @3=beep UPDATED)
   242  b: (b2, [ace-c) @3=beep)
   243  c: (c2, [c-d) @1=boop UPDATED)
   244  .
   245  
   246  # NB: seek-prefix-ge truncates bounds to the prefix.
   247  
   248  combined-iter
   249  seek-prefix-ge b
   250  next
   251  ----
   252  b: (b2, [b-"b\x00") @3=beep UPDATED)
   253  .
   254  
   255  reset
   256  ----
   257  
   258  # For all prefixes a, aa, ab, ... zz, write 3 keys at timestamps @1, @10, @100.
   259  # This populates a total of (26**2 + 26) * 3 = 2106 keys.
   260  
   261  populate keylen=2 timestamps=(1, 10, 100)
   262  ----
   263  wrote 2106 keys
   264  
   265  batch commit
   266  range-key-set   b c @5 beep
   267  range-key-unset c d @1
   268  range-key-del   d e
   269  ----
   270  committed 3 keys
   271  
   272  flush
   273  ----
   274  
   275  metrics
   276  ----
   277  Metrics.Keys.RangeKeySetsCount = 1
   278  
   279  combined-iter
   280  seek-ge az
   281  next
   282  next
   283  next
   284  next
   285  next
   286  seek-ge bz@10
   287  next
   288  next
   289  ----
   290  az@100: (az@100, .)
   291  az@10: (az@10, .)
   292  az@1: (az@1, .)
   293  b: (., [b-c) @5=beep UPDATED)
   294  b@100: (b@100, [b-c) @5=beep)
   295  b@10: (b@10, [b-c) @5=beep)
   296  bz@10: (bz@10, [b-c) @5=beep)
   297  bz@1: (bz@1, [b-c) @5=beep)
   298  c@100: (c@100, . UPDATED)
   299  
   300  # Perform the same iteration with all range keys serving as masks. The bz@1
   301  # point key should be elided.
   302  
   303  combined-iter mask-suffix=@100
   304  seek-ge az
   305  next
   306  next
   307  next
   308  next
   309  next
   310  seek-ge bz@10
   311  next
   312  next
   313  ----
   314  az@100: (az@100, .)
   315  az@10: (az@10, .)
   316  az@1: (az@1, .)
   317  b: (., [b-c) @5=beep UPDATED)
   318  b@100: (b@100, [b-c) @5=beep)
   319  b@10: (b@10, [b-c) @5=beep)
   320  bz@10: (bz@10, [b-c) @5=beep)
   321  c@100: (c@100, . UPDATED)
   322  c@10: (c@10, .)
   323  
   324  # Ensure that a cloned iterator includes range keys.
   325  
   326  combined-iter
   327  seek-ge bz@10
   328  clone
   329  seek-ge bz@10
   330  ----
   331  bz@10: (bz@10, [b-c) @5=beep UPDATED)
   332  .
   333  bz@10: (bz@10, [b-c) @5=beep UPDATED)
   334  
   335  # Within a batch, later writes overwrite earlier writes. Here, the range-key-del
   336  # of [bat, bus) overwrites the earlier writes of [b,c) and [b,e).
   337  
   338  batch commit
   339  range-key-set   b c @5 beep
   340  range-key-set   b e @1 bop
   341  range-key-set   c z @1000 boop
   342  range-key-del   bat bus
   343  ----
   344  committed 4 keys
   345  
   346  flush
   347  ----
   348  
   349  lsm
   350  ----
   351  0.1:
   352    000008:[b#2120,RANGEKEYSET-z#inf,RANGEKEYSET]
   353  0.0:
   354    000006:[a@100#12,SET-zz@1#2113,SET]
   355  
   356  scan-rangekeys
   357  ----
   358  [b, bat)
   359   @5=beep, @1=bop
   360  [bus, c)
   361   @5=beep, @1=bop
   362  [c, e)
   363   @1000=boop, @1=bop
   364  [e, z)
   365   @1000=boop
   366  
   367  # NB: There are now 8 range key sets in the database. See the 7 range keys in
   368  # the above scan-rangekeys. Additionally, the sstable flushed earlier up above
   369  # included a rangekeyset [b,c) @5=beep.
   370  
   371  metrics
   372  ----
   373  Metrics.Keys.RangeKeySetsCount = 8
   374  
   375  
   376  combined-iter
   377  seek-prefix-ge ca
   378  next
   379  seek-prefix-ge ca@100
   380  ----
   381  ca: (., [ca-"ca\x00") @1000=boop, @1=bop UPDATED)
   382  ca@100: (ca@100, [ca-"ca\x00") @1000=boop, @1=bop)
   383  ca@100: (ca@100, [ca-"ca\x00") @1000=boop, @1=bop)
   384  
   385  
   386  # Perform the same iteration as above, but with @1000 range-key masking. The
   387  # previously encountered point keys should be elided.
   388  
   389  combined-iter mask-suffix=@1000
   390  seek-prefix-ge ca
   391  next
   392  seek-prefix-ge ca@100
   393  ----
   394  ca: (., [ca-"ca\x00") @1000=boop, @1=bop UPDATED)
   395  .
   396  ca@100: (., [ca-"ca\x00") @1000=boop, @1=bop UPDATED)
   397  
   398  # Test masked, non-prefixed iteration. We should see the range keys, but all the
   399  # points should be masked except those beginning with z which were excluded by
   400  # the range key's exclusive z end bound.
   401  
   402  combined-iter mask-suffix=@1000
   403  seek-ge ca
   404  next
   405  next
   406  next
   407  next
   408  next
   409  ----
   410  ca: (., [c-e) @1000=boop, @1=bop UPDATED)
   411  e: (., [e-z) @1000=boop UPDATED)
   412  z@100: (z@100, . UPDATED)
   413  z@10: (z@10, .)
   414  z@1: (z@1, .)
   415  za@100: (za@100, .)
   416  
   417  # Applying range keys to a DB running with a version that doesn't support them
   418  # results in an error. Range keys were added in version 7.
   419  reset format-major-version=6
   420  ----
   421  
   422  batch commit
   423  range-key-set a   z   @5 boop
   424  ----
   425  pebble: batch requires at least format major version 8 (current: 6)
   426  
   427  # Constructing iterator over range keys on a DB that doesn't support them
   428  # results in an error.
   429  
   430  reset format-major-version=6
   431  ----
   432  
   433  combined-iter
   434  ----
   435  pebble: range keys require at least format major version 8 (current: 6)
   436  
   437  # Test Prev-ing back over a synthetic range key marker. Synthetic range-key
   438  # markers (the keys interleaved at 'c' during a SeekGE(c) when there's a
   439  # straddling range key) are ephemeral, and Prev-ing back must move back the
   440  # appropriate number of times.
   441  
   442  reset
   443  ----
   444  
   445  batch commit
   446  set a a
   447  range-key-set b e @1 foo
   448  ----
   449  committed 2 keys
   450  
   451  flush
   452  ----
   453  
   454  combined-iter
   455  seek-ge b
   456  prev
   457  seek-ge c
   458  prev
   459  ----
   460  b: (., [b-e) @1=foo UPDATED)
   461  a: (a, . UPDATED)
   462  c: (., [b-e) @1=foo UPDATED)
   463  b: (., [b-e) @1=foo)
   464  
   465  define
   466  L6
   467  a.RANGEDEL.3:z
   468  rangekey:b-d:{(#5,RANGEKEYSET,@2,foo)}
   469  ----
   470  6:
   471    000004:[a#3,RANGEDEL-z#inf,RANGEDEL]
   472  
   473  combined-iter
   474  seek-lt apple
   475  ----
   476  .
   477  
   478  combined-iter
   479  seek-ge apple
   480  seek-ge z
   481  seek-lt apple
   482  seek-lt z
   483  first
   484  last
   485  ----
   486  b: (., [b-d) @2=foo UPDATED)
   487  .
   488  .
   489  b: (., [b-d) @2=foo UPDATED)
   490  b: (., [b-d) @2=foo)
   491  b: (., [b-d) @2=foo)
   492  
   493  combined-iter
   494  seek-ge apple
   495  prev
   496  last
   497  next
   498  prev
   499  seek-lt c
   500  prev
   501  ----
   502  b: (., [b-d) @2=foo UPDATED)
   503  .
   504  b: (., [b-d) @2=foo UPDATED)
   505  .
   506  b: (., [b-d) @2=foo UPDATED)
   507  b: (., [b-d) @2=foo)
   508  .