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

     1  # Simple test with a single file per level.
     2  
     3  define
     4  L1
     5    b.SET.11:foo
     6    c.SET.11:foo
     7  L2
     8    c.SET.0:foo
     9    d.SET.0:foo
    10  ----
    11  1:
    12    000004:[b#11,SET-c#11,SET]
    13  2:
    14    000005:[c#0,SET-d#0,SET]
    15  
    16  file-sizes
    17  ----
    18  L1:
    19    000004:[b#11,1-c#11,1]: 669 bytes (669B)
    20  L2:
    21    000005:[c#0,1-d#0,1]: 668 bytes (668B)
    22  
    23  pick-file L1
    24  ----
    25  000004:[b#11,1-c#11,1]
    26  
    27  pick-file L2
    28  ----
    29  000005:[c#0,1-d#0,1]
    30  
    31  # Test a scenario where we should pick a file with a tiny file size over one
    32  # with a larger file size, because the tiny sized one overlaps zero data in the
    33  # output level.
    34  
    35  define
    36  L5
    37    b.SET.11:<rand-bytes=65536>
    38    c.SET.11:<rand-bytes=65536>
    39  L5
    40    e.SET.11:<rand-bytes=2>
    41  L6
    42    a.SET.0:foo
    43    d.SET.0:foo
    44  ----
    45  5:
    46    000004:[b#11,SET-c#11,SET]
    47    000005:[e#11,SET-e#11,SET]
    48  6:
    49    000006:[a#0,SET-d#0,SET]
    50  
    51  pick-file L5
    52  ----
    53  000005:[e#11,1-e#11,1]
    54  
    55  # Test the same scenario as above, but the larger file that overlaps the next
    56  # level only overlaps on its start boundary key ("c").
    57  
    58  define
    59  L5
    60    c.SET.11:<rand-bytes=65536>
    61    d.SET.11:<rand-bytes=65536>
    62  L5
    63    e.SET.11:<rand-bytes=2>
    64  L6
    65    a.SET.0:foo
    66    c.SET.0:foo
    67  ----
    68  5:
    69    000004:[c#11,SET-d#11,SET]
    70    000005:[e#11,SET-e#11,SET]
    71  6:
    72    000006:[a#0,SET-c#0,SET]
    73  
    74  pick-file L5
    75  ----
    76  000005:[e#11,1-e#11,1]
    77  
    78  
    79  # Test a scenario where the file containing e.SET.11 overlaps an L6 file
    80  # containing e.SET.0. These files should be considered overlapping, despite the
    81  # fact that they don't overlap within the internal key keyspace. The overlap
    82  # should then cause the larger file (with a lower overlapping ratio) to be
    83  # picked.
    84  
    85  define
    86  L5
    87    c.SET.11:<rand-bytes=65536>
    88    d.SET.11:<rand-bytes=65536>
    89  L5
    90    e.SET.11:<rand-bytes=2>
    91  L6
    92    a.SET.0:foo
    93    c.SET.0:foo
    94  L6
    95    e.SET.0:foo
    96  ----
    97  5:
    98    000004:[c#11,SET-d#11,SET]
    99    000005:[e#11,SET-e#11,SET]
   100  6:
   101    000006:[a#0,SET-c#0,SET]
   102    000007:[e#0,SET-e#0,SET]
   103  
   104  pick-file L5
   105  ----
   106  000004:[c#11,1-d#11,1]