github.com/cockroachdb/pebble@v1.1.1-0.20240513155919-3622ade60459/testdata/manual_compaction_multilevel (about)

     1  # This set of tests validates that manually executed multi level compactions work
     2  # The multilevel compaction tests mainly live in
     3  # /testdata/compaction_setup_inputs_multilevel_write_amp
     4  
     5  # A vanilla multi level compaction
     6  define level-max-bytes=(L2 : 5) auto-compactions=off
     7  L1
     8    a.SET.3:v b.SET.2:v
     9  L2
    10    a.SET.2:v c.SET.4:v
    11  L3
    12    c.SET.3:v d.SET.2:v
    13  L4
    14    c.SET.2:v d.SET.1:v
    15  ----
    16  1:
    17    000004:[a#3,SET-b#2,SET]
    18  2:
    19    000005:[a#2,SET-c#4,SET]
    20  3:
    21    000006:[c#3,SET-d#2,SET]
    22  4:
    23    000007:[c#2,SET-d#1,SET]
    24  
    25  compact a-b L1
    26  ----
    27  3:
    28    000008:[a#3,SET-d#2,SET]
    29  4:
    30    000007:[c#2,SET-d#1,SET]
    31  
    32  # Conduct a multi level compaction with no output level files
    33  define level-max-bytes=(L2 : 5) auto-compactions=off
    34  L1
    35    a.SET.3:v b.SET.2:v
    36  L2
    37    a.SET.2:v c.SET.4:v
    38  L4
    39    c.SET.2:v d.SET.1:v
    40  ----
    41  1:
    42    000004:[a#3,SET-b#2,SET]
    43  2:
    44    000005:[a#2,SET-c#4,SET]
    45  4:
    46    000006:[c#2,SET-d#1,SET]
    47  
    48  compact a-b L1
    49  ----
    50  3:
    51    000007:[a#3,SET-c#4,SET]
    52  4:
    53    000006:[c#2,SET-d#1,SET]
    54  
    55  # No multilevel compaction because a move to L2 results in less writeamp than the ML compaction
    56  # which includes the file in L3.
    57  define level-max-bytes=(L2 : 5) auto-compactions=off
    58  L1
    59    a.SET.3:v b.SET.2:v
    60  L3
    61    a.SET.2:v c.SET.4:v
    62  L4
    63    c.SET.2:v d.SET.1:v
    64  ----
    65  1:
    66    000004:[a#3,SET-b#2,SET]
    67  3:
    68    000005:[a#2,SET-c#4,SET]
    69  4:
    70    000006:[c#2,SET-d#1,SET]
    71  
    72  compact a-b L1
    73  ----
    74  2:
    75    000004:[a#3,SET-b#2,SET]
    76  3:
    77    000005:[a#2,SET-c#4,SET]
    78  4:
    79    000006:[c#2,SET-d#1,SET]
    80  
    81  # Conduct a multi input compaction without intermediate or output level, basically a move.
    82  define level-max-bytes=(L2 : 5) auto-compactions=off multi-input-level
    83  L1
    84    a.SET.3:v b.SET.2:v
    85  L4
    86    c.SET.2:v d.SET.1:v
    87  ----
    88  1:
    89    000004:[a#3,SET-b#2,SET]
    90  4:
    91    000005:[c#2,SET-d#1,SET]
    92  
    93  compact a-b L1
    94  ----
    95  3:
    96    000004:[a#3,SET-b#2,SET]
    97  4:
    98    000005:[c#2,SET-d#1,SET]
    99  
   100  # Don't conduct a multi level compaction on L0.
   101  define level-max-bytes=(L1 : 5) auto-compactions=off multi-input-level
   102  L0
   103    a.SET.1:v b.SET.2:v
   104  L1
   105    a.SET.3:v c.SET.4:v
   106  L2
   107    c.SET.2:v d.SET.2:v
   108  ----
   109  0.0:
   110    000004:[a#1,SET-b#2,SET]
   111  1:
   112    000005:[a#3,SET-c#4,SET]
   113  2:
   114    000006:[c#2,SET-d#2,SET]
   115  
   116  compact a-b L0
   117  ----
   118  1:
   119    000007:[a#3,SET-c#4,SET]
   120  2:
   121    000006:[c#2,SET-d#2,SET]