github.com/cockroachdb/pebble@v0.0.0-20231214172447-ab4952c5f87b/testdata/iterator_seek_opt (about)

     1  
     2  define auto-compactions=off
     3  L0
     4    a.SET.4:4
     5  L1
     6    a.SET.3:3
     7  L2
     8    d.SET.2:2
     9  L3
    10    b.SET.1:1
    11    c.SET.1:1
    12    d.SET.1:1
    13    e.SET.1:1
    14  ----
    15  0.0:
    16    000004:[a#4,SET-a#4,SET]
    17  1:
    18    000005:[a#3,SET-a#3,SET]
    19  2:
    20    000006:[d#2,SET-d#2,SET]
    21  3:
    22    000007:[b#1,SET-e#1,SET]
    23  
    24  # Simple case: three successive seeks, at increasing keys. Should use
    25  # trySeekUsingNext.
    26  
    27  iter
    28  seek-ge a
    29  ----
    30  a: (4, .)
    31  stats: (interface (dir, seek, step): (fwd, 1, 0), (rev, 0, 0)), (internal (dir, seek, step): (fwd, 1, 0), (rev, 0, 0))
    32  SeekGEs with trySeekUsingNext: 0
    33  SeekPrefixGEs with trySeekUsingNext: 0
    34  
    35  iter
    36  seek-ge b
    37  ----
    38  b: (1, .)
    39  stats: (interface (dir, seek, step): (fwd, 2, 0), (rev, 0, 0)), (internal (dir, seek, step): (fwd, 2, 0), (rev, 0, 0))
    40  SeekGEs with trySeekUsingNext: 2
    41  SeekPrefixGEs with trySeekUsingNext: 0
    42  
    43  iter
    44  seek-ge c
    45  ----
    46  c: (1, .)
    47  stats: (interface (dir, seek, step): (fwd, 3, 0), (rev, 0, 0)), (internal (dir, seek, step): (fwd, 3, 0), (rev, 0, 0))
    48  SeekGEs with trySeekUsingNext: 4
    49  SeekPrefixGEs with trySeekUsingNext: 0
    50  
    51  # Seek at a lower key. Should not call with trySeekUsingNext = true.
    52  
    53  iter
    54  seek-ge bb
    55  ----
    56  c: (1, .)
    57  stats: (interface (dir, seek, step): (fwd, 4, 0), (rev, 0, 0)), (internal (dir, seek, step): (fwd, 4, 0), (rev, 0, 0))
    58  SeekGEs with trySeekUsingNext: 4
    59  SeekPrefixGEs with trySeekUsingNext: 0
    60  
    61  # Seek at a greater key than last seek, but lands on the same key. Should
    62  # not call internalIterator at all.
    63  
    64  iter
    65  seek-ge bbb
    66  ----
    67  c: (1, .)
    68  stats: (interface (dir, seek, step): (fwd, 5, 0), (rev, 0, 0)), (internal (dir, seek, step): (fwd, 4, 0), (rev, 0, 0))
    69  SeekGEs with trySeekUsingNext: 4
    70  SeekPrefixGEs with trySeekUsingNext: 0
    71  
    72  # A step followed by a seek should not call with trySeekUsingNext = true.
    73  
    74  iter
    75  next
    76  seek-ge e
    77  ----
    78  d: (2, .)
    79  e: (1, .)
    80  stats: (interface (dir, seek, step): (fwd, 6, 1), (rev, 0, 0)), (internal (dir, seek, step): (fwd, 5, 1), (rev, 0, 0))
    81  SeekGEs with trySeekUsingNext: 4
    82  SeekPrefixGEs with trySeekUsingNext: 0
    83  
    84  iter
    85  prev
    86  seek-ge b
    87  ----
    88  d: (2, .)
    89  b: (1, .)
    90  stats: (interface (dir, seek, step): (fwd, 7, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 6, 1), (rev, 0, 3))
    91  SeekGEs with trySeekUsingNext: 4
    92  SeekPrefixGEs with trySeekUsingNext: 0
    93  
    94  # SeekPrefixGE simple case.
    95  
    96  iter
    97  seek-prefix-ge a
    98  ----
    99  a: (4, .)
   100  stats: (interface (dir, seek, step): (fwd, 8, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 7, 1), (rev, 0, 3))
   101  SeekGEs with trySeekUsingNext: 4
   102  SeekPrefixGEs with trySeekUsingNext: 0
   103  
   104  iter
   105  seek-prefix-ge b
   106  ----
   107  b: (1, .)
   108  stats: (interface (dir, seek, step): (fwd, 9, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 8, 1), (rev, 0, 3))
   109  SeekGEs with trySeekUsingNext: 4
   110  SeekPrefixGEs with trySeekUsingNext: 2
   111  
   112  iter
   113  seek-prefix-ge c
   114  ----
   115  c: (1, .)
   116  stats: (interface (dir, seek, step): (fwd, 10, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 9, 1), (rev, 0, 3))
   117  SeekGEs with trySeekUsingNext: 4
   118  SeekPrefixGEs with trySeekUsingNext: 4
   119  
   120  # Seek at a lower key. Should not call with trySeekUsingNext = true.
   121  
   122  iter
   123  seek-prefix-ge bb
   124  ----
   125  .
   126  stats: (interface (dir, seek, step): (fwd, 11, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 10, 1), (rev, 0, 3))
   127  SeekGEs with trySeekUsingNext: 4
   128  SeekPrefixGEs with trySeekUsingNext: 4
   129  
   130  # Shifting bounds followed by SeekGEs. The one immediately after a bounds change
   131  # does not use trySeekUsingNext, but successive ones do (while still respecting
   132  # bounds).
   133  
   134  iter
   135  set-bounds lower=a upper=aa
   136  seek-ge a
   137  ----
   138  .
   139  a: (4, .)
   140  stats: (interface (dir, seek, step): (fwd, 12, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 11, 1), (rev, 0, 3))
   141  SeekGEs with trySeekUsingNext: 4
   142  SeekPrefixGEs with trySeekUsingNext: 4
   143  
   144  iter
   145  set-bounds lower=a upper=c
   146  seek-ge b
   147  ----
   148  .
   149  b: (1, .)
   150  stats: (interface (dir, seek, step): (fwd, 13, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 12, 1), (rev, 0, 3))
   151  SeekGEs with trySeekUsingNext: 4
   152  SeekPrefixGEs with trySeekUsingNext: 4
   153  
   154  iter
   155  seek-ge bb
   156  ----
   157  .
   158  stats: (interface (dir, seek, step): (fwd, 14, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 13, 1), (rev, 0, 3))
   159  SeekGEs with trySeekUsingNext: 5
   160  SeekPrefixGEs with trySeekUsingNext: 4
   161  
   162  iter
   163  set-bounds lower=a upper=d
   164  seek-ge bbb
   165  ----
   166  .
   167  c: (1, .)
   168  stats: (interface (dir, seek, step): (fwd, 15, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 14, 1), (rev, 0, 3))
   169  SeekGEs with trySeekUsingNext: 5
   170  SeekPrefixGEs with trySeekUsingNext: 4
   171  
   172  iter
   173  seek-ge cc
   174  ----
   175  .
   176  stats: (interface (dir, seek, step): (fwd, 16, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 15, 1), (rev, 0, 3))
   177  SeekGEs with trySeekUsingNext: 6
   178  SeekPrefixGEs with trySeekUsingNext: 4
   179  
   180  # Shifting bounds, with non-overlapping and monotonic bounds. A set-bounds sits
   181  # between every two seeks. We don't call trySeekUsingNext=true when the bounds
   182  # are set to unequal bounds, but the results are still correct and within
   183  # bounds. We do call trySeekUsingNext=true when the set bounds are identical.
   184  
   185  iter
   186  set-bounds lower=a upper=c
   187  seek-ge b
   188  ----
   189  .
   190  b: (1, .)
   191  stats: (interface (dir, seek, step): (fwd, 17, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 16, 1), (rev, 0, 3))
   192  SeekGEs with trySeekUsingNext: 6
   193  SeekPrefixGEs with trySeekUsingNext: 4
   194  
   195  iter
   196  set-bounds lower=c upper=e
   197  seek-ge c
   198  ----
   199  .
   200  c: (1, .)
   201  stats: (interface (dir, seek, step): (fwd, 18, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 17, 1), (rev, 0, 3))
   202  SeekGEs with trySeekUsingNext: 6
   203  SeekPrefixGEs with trySeekUsingNext: 4
   204  
   205  # NB: Equal bounds.
   206  
   207  iter
   208  set-bounds lower=c upper=e
   209  seek-ge d
   210  ----
   211  .
   212  d: (2, .)
   213  stats: (interface (dir, seek, step): (fwd, 19, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 18, 1), (rev, 0, 3))
   214  SeekGEs with trySeekUsingNext: 8
   215  SeekPrefixGEs with trySeekUsingNext: 4
   216  
   217  iter
   218  set-bounds lower=a upper=c
   219  seek-prefix-ge b
   220  ----
   221  .
   222  b: (1, .)
   223  stats: (interface (dir, seek, step): (fwd, 20, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 19, 1), (rev, 0, 3))
   224  SeekGEs with trySeekUsingNext: 8
   225  SeekPrefixGEs with trySeekUsingNext: 4
   226  
   227  iter
   228  set-bounds lower=c upper=e
   229  seek-prefix-ge c
   230  ----
   231  .
   232  c: (1, .)
   233  stats: (interface (dir, seek, step): (fwd, 21, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 20, 1), (rev, 0, 3))
   234  SeekGEs with trySeekUsingNext: 8
   235  SeekPrefixGEs with trySeekUsingNext: 4
   236  
   237  # NB: Equal bounds.
   238  
   239  iter
   240  set-bounds lower=c upper=e
   241  seek-prefix-ge d
   242  ----
   243  .
   244  d: (2, .)
   245  stats: (interface (dir, seek, step): (fwd, 22, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 21, 1), (rev, 0, 3))
   246  SeekGEs with trySeekUsingNext: 8
   247  SeekPrefixGEs with trySeekUsingNext: 6
   248  
   249  # Shifting bounds, with non-overlapping and monotonic bounds, but using
   250  # SetOptions. A set-options sits between every two seeks. We don't call
   251  # trySeekUsingNext=true when the bounds are set to unequal bounds, but the
   252  # results are still correct and within bounds. We do call trySeekUsingNext=true
   253  # when the set bounds are identical.
   254  
   255  iter
   256  set-options lower=a upper=c
   257  seek-ge b
   258  ----
   259  .
   260  b: (1, .)
   261  stats: (interface (dir, seek, step): (fwd, 23, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 22, 1), (rev, 0, 3))
   262  SeekGEs with trySeekUsingNext: 8
   263  SeekPrefixGEs with trySeekUsingNext: 6
   264  
   265  iter
   266  set-options lower=c upper=e
   267  seek-ge c
   268  ----
   269  .
   270  c: (1, .)
   271  stats: (interface (dir, seek, step): (fwd, 24, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 23, 1), (rev, 0, 3))
   272  SeekGEs with trySeekUsingNext: 8
   273  SeekPrefixGEs with trySeekUsingNext: 6
   274  
   275  # NB: Equal bounds.
   276  
   277  iter
   278  set-options lower=c upper=e
   279  seek-ge d
   280  ----
   281  .
   282  d: (2, .)
   283  stats: (interface (dir, seek, step): (fwd, 25, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 24, 1), (rev, 0, 3))
   284  SeekGEs with trySeekUsingNext: 10
   285  SeekPrefixGEs with trySeekUsingNext: 6
   286  
   287  iter
   288  set-options lower=a upper=c
   289  seek-prefix-ge b
   290  ----
   291  .
   292  b: (1, .)
   293  stats: (interface (dir, seek, step): (fwd, 26, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 25, 1), (rev, 0, 3))
   294  SeekGEs with trySeekUsingNext: 10
   295  SeekPrefixGEs with trySeekUsingNext: 6
   296  
   297  iter
   298  set-options lower=c upper=e
   299  seek-prefix-ge c
   300  ----
   301  .
   302  c: (1, .)
   303  stats: (interface (dir, seek, step): (fwd, 27, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 26, 1), (rev, 0, 3))
   304  SeekGEs with trySeekUsingNext: 10
   305  SeekPrefixGEs with trySeekUsingNext: 6
   306  
   307  # NB: Equal bounds.
   308  
   309  iter
   310  set-options lower=c upper=e
   311  seek-prefix-ge d
   312  ----
   313  .
   314  d: (2, .)
   315  stats: (interface (dir, seek, step): (fwd, 28, 1), (rev, 0, 1)), (internal (dir, seek, step): (fwd, 27, 1), (rev, 0, 3))
   316  SeekGEs with trySeekUsingNext: 10
   317  SeekPrefixGEs with trySeekUsingNext: 8