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

     1  # The example used in the documentation for tableRangedDeletionIter. An iterator
     2  # over the following table:
     3  #
     4  #
     5  #         |---------|     |---------|         |-------| RANGEKEYDELs
     6  #   |-----------|-------------|           |-----|       RANGEDELs
     7  # __________________________________________________________
     8  #   a b c d e f g h i j k l m n o p q r s t u v w x y z
     9  #
    10  # yields the following spans:
    11  #
    12  #      1       3       1    3    2          1  3   2
    13  #   |-----|---------|-----|---|-----|     |---|-|-----|
    14  # __________________________________________________________
    15  #   a b c d e f g h i j k l m n o p q r s t u v w x y z
    16  #
    17  # where:
    18  # - 1: homogenous span with range dels only
    19  # - 2: homogenous span with range key dels only
    20  # - 3: heterogeneous span with range dels and range key dels
    21  
    22  build
    23  a-g:{(#0,RANGEDEL)}
    24  g-n:{(#0,RANGEDEL)}
    25  t-w:{(#0,RANGEDEL)}
    26  d-i:{(#0,RANGEKEYDEL)}
    27  l-q:{(#0,RANGEKEYDEL)}
    28  v-z:{(#0,RANGEKEYDEL)}
    29  ----
    30  000000:[a#0,RANGEDEL-z#inf,RANGEKEYDEL]
    31  
    32  spans
    33  ----
    34  a-d:{(#0,RANGEDEL)}
    35  d-i:{(#0,RANGEKEYDEL) (#0,RANGEDEL)}
    36  i-l:{(#0,RANGEDEL)}
    37  l-n:{(#0,RANGEKEYDEL) (#0,RANGEDEL)}
    38  n-q:{(#0,RANGEKEYDEL)}
    39  t-v:{(#0,RANGEDEL)}
    40  v-w:{(#0,RANGEKEYDEL) (#0,RANGEDEL)}
    41  w-z:{(#0,RANGEKEYDEL)}
    42  
    43  # The iterator elides anything other than range deletes and range key deletes.
    44  
    45  #   |---------------RANGEKEYUNSET----------------------|
    46  #   |---------------RANGEKEYSET------------------------|
    47  #   |---------------RANGEKEYDEL------------------------|
    48  # __________________________________________________________
    49  #   a b c d e f g h i j k l m n o p q r s t u v w x y z
    50  #
    51  # Becomes:
    52  #   |---------------RANGEKEYDEL------------------------|
    53  # __________________________________________________________
    54  #   a b c d e f g h i j k l m n o p q r s t u v w x y z
    55  
    56  build
    57  a-z:{(#0,RANGEKEYDEL) (#0,RANGEKEYSET,@1,foo) (#0,RANGEKEYUNSET,@2)}
    58  ----
    59  000000:[a#0,RANGEKEYSET-z#inf,RANGEKEYDEL]
    60  
    61  spans
    62  ----
    63  a-z:{(#0,RANGEKEYDEL)}
    64  
    65  # The same as the above, except that the RANGEKEYDEL is at a lower sequence
    66  # number than the SET and UNSET. The three keys exist at different sequence
    67  # numbers, with the DEL at the bottom to avoid the perceived affects of
    68  # shadowing.
    69  
    70  build
    71  a-z:{(#3,RANGEKEYSET,@1,foo) (#2,RANGEKEYUNSET,@2) (#1,RANGEKEYDEL)}
    72  ----
    73  000000:[a#3,RANGEKEYSET-z#inf,RANGEKEYDEL]
    74  
    75  spans
    76  ----
    77  a-z:{(#1,RANGEKEYDEL)}
    78  
    79  #   |-RANGEKEYSET-|-RANGEKEYUNSET-|-RANGEKEYDEL--------|
    80  # __________________________________________________________
    81  #   a b c d e f g h i j k l m n o p q r s t u v w x y z
    82  #
    83  # Becomes:
    84  #                                 |-RANGEKEYDEL-------|
    85  # __________________________________________________________
    86  #   a b c d e f g h i j k l m n o p q r s t u v w x y z
    87  
    88  build
    89  a-h:{(#0,RANGEKEYSET,@1,foo)}
    90  h-p:{(#0,RANGEKEYUNSET,@1)}
    91  p-z:{(#0,RANGEKEYDEL)}
    92  ----
    93  000000:[a#0,RANGEKEYSET-z#inf,RANGEKEYDEL]
    94  
    95  spans
    96  ----
    97  p-z:{(#0,RANGEKEYDEL)}
    98  
    99  #   |-RANGEKEYSET-|-RANGEKEYUNSET-|-RANGEKEYDEL--------|
   100  #   |--RANGEDEL-----------------------------|
   101  # __________________________________________________________
   102  #   a b c d e f g h i j k l m n o p q r s t u v w x y z
   103  #
   104  # Becomes:
   105  #
   106  #   |---------------1-------------|----3----|----2----|
   107  # __________________________________________________________
   108  #   a b c d e f g h i j k l m n o p q r s t u v w x y z
   109  
   110  build
   111  a-u:{(#0,RANGEDEL)}
   112  a-h:{(#0,RANGEKEYSET,@1,foo)}
   113  h-p:{(#0,RANGEKEYUNSET,@1)}
   114  p-z:{(#0,RANGEKEYDEL)}
   115  ----
   116  000000:[a#0,RANGEKEYSET-z#inf,RANGEKEYDEL]
   117  
   118  spans
   119  ----
   120  a-p:{(#0,RANGEDEL)}
   121  p-u:{(#0,RANGEKEYDEL) (#0,RANGEDEL)}
   122  u-z:{(#0,RANGEKEYDEL)}
   123  
   124  # An iterator over a table with neither range dels or range key dels present
   125  # yields no spans.
   126  
   127  build
   128  a-m:{(#0,RANGEKEYSET,@1,foo)}
   129  m-z:{(#0,RANGEKEYUNSET,@1)}
   130  ----
   131  000000:[a#0,RANGEKEYSET-z#inf,RANGEKEYUNSET]
   132  
   133  spans
   134  ----
   135  (none)
   136  
   137  # Abutting spans that are merged emit only the largest and smallest key.
   138  
   139  build
   140  a-c:{(#4,RANGEDEL) (#3,RANGEDEL) (#1,RANGEDEL)}
   141  c-d:{(#9,RANGEDEL) (#7,RANGEDEL) (#6,RANGEDEL) (#2,RANGEDEL)}
   142  ----
   143  000000:[a#4,RANGEDEL-d#inf,RANGEDEL]
   144  
   145  spans
   146  ----
   147  a-d:{(#9,RANGEDEL) (#1,RANGEDEL)}
   148  
   149  # The same as above, but for range key dels.
   150  
   151  build
   152  a-c:{(#4,RANGEKEYDEL) (#3,RANGEKEYDEL) (#1,RANGEKEYDEL)}
   153  c-d:{(#9,RANGEKEYDEL) (#7,RANGEKEYDEL) (#6,RANGEKEYDEL) (#2,RANGEKEYDEL)}
   154  ----
   155  000000:[a#4,RANGEKEYDEL-d#inf,RANGEKEYDEL]
   156  
   157  spans
   158  ----
   159  a-d:{(#9,RANGEKEYDEL) (#1,RANGEKEYDEL)}
   160  
   161  # The same as above, but for mixed key kinds. The resulting span has four keys,
   162  # given the respective largest / smallest keys from the range del and range key
   163  # del spans are interleaved.
   164  
   165  build
   166  a-c:{(#4,RANGEDEL) (#2,RANGEDEL)}
   167  a-c:{(#3,RANGEKEYDEL) (#1,RANGEKEYDEL)}
   168  ----
   169  000000:[a#4,RANGEDEL-c#inf,RANGEDEL]
   170  
   171  spans
   172  ----
   173  a-c:{(#4,RANGEDEL) (#3,RANGEKEYDEL) (#2,RANGEDEL) (#1,RANGEKEYDEL)}
   174  
   175  # "Hetrogenous spans" (i.e. spans containing both range dels and range key dels)
   176  # are preserved when abutting spans are merged. This tests that the reducing
   177  # function does not "lose information" of the merged spans, effectively
   178  # resulting in the span switching types from a heterogeneous span to a
   179  # homogenous span.
   180  
   181  # 10 |-------|---|---| RANGEDELs
   182  # 5  |-------|---|     RANGEKEYDELs
   183  # 3  |-------|---|---| RANGEDELs
   184  # _____________________
   185  #    a   b   c   d   e
   186  
   187  build
   188  a-c:{(#10,RANGEDEL) (#3,RANGEDEL)}
   189  c-d:{(#10,RANGEDEL) (#3,RANGEDEL)}
   190  d-e:{(#10,RANGEDEL) (#3,RANGEDEL)}
   191  a-c:{(#5,RANGEKEYDEL)}
   192  c-d:{(#5,RANGEKEYDEL)}
   193  ----
   194  000000:[a#10,RANGEDEL-e#inf,RANGEDEL]
   195  
   196  spans
   197  ----
   198  a-d:{(#10,RANGEDEL) (#5,RANGEKEYDEL) (#3,RANGEDEL)}
   199  d-e:{(#10,RANGEDEL) (#3,RANGEDEL)}