github.com/zuoyebang/bitalostable@v1.0.1-0.20240229032404-e3b99a834294/sstable/testdata/size_estimate (about)

     1  # Sequence of ops which tests all of the code paths in the size_estimate type.
     2  
     3  init 1
     4  ----
     5  success
     6  
     7  # Empty size should be 1
     8  size
     9  ----
    10  1
    11  
    12  # There's a single inflight entry, so the size should be 4.
    13  add_inflight 4
    14  ----
    15  4
    16  
    17  num_inflight_entries
    18  ----
    19  1
    20  
    21  num_entries
    22  ----
    23  1
    24  
    25  # After compression, entry only had a size of 3. The total size is the 3, but the
    26  # max estimated size yet is 4.
    27  entry_written 3 4 3
    28  ----
    29  4
    30  
    31  num_entries
    32  ----
    33  1
    34  
    35  # There should be 0 inflight entries once the previous entry has been written.
    36  num_inflight_entries
    37  ----
    38  0
    39  
    40  # Compression ratio is 0.75 at this point. The total size is 3, and the inflight
    41  # size is 4, so that returned size is uint64(6.75).
    42  add_inflight 5
    43  ----
    44  6
    45  
    46  num_entries
    47  ----
    48  2
    49  
    50  # We don't clear the empty size, so even after clearing a size of 1 is returned.
    51  clear
    52  ----
    53  1
    54  
    55  # Test writing multiple inflight entries.
    56  add_inflight 4
    57  ----
    58  4
    59  
    60  add_inflight 5
    61  ----
    62  9
    63  
    64  num_entries
    65  ----
    66  2
    67  
    68  num_inflight_entries
    69  ----
    70  2
    71  
    72  # First inflight entry written. The entry didn't get compressed. The total size
    73  # now is less than 9, but the max estimated size should still be 9.
    74  entry_written 4 4 4
    75  ----
    76  9
    77  
    78  num_entries
    79  ----
    80  2
    81  
    82  num_inflight_entries
    83  ----
    84  1
    85  
    86  # At this point, inflightSize is 13, the totalSize is 4. The compression ratio
    87  # is 1. So, the returned size should be 17.
    88  add_inflight 8
    89  ----
    90  17
    91  
    92  # One entry has been written.
    93  num_written_entries
    94  ----
    95  1
    96  
    97  # The inflight entry had a size of 5, but the entry added had a size of 3 because
    98  # of compression/size estimation. The compression ratio is 0.77 at this point.
    99  # The inflightSize is 8. The true size is 13.16, but the maxEstimatedSize is
   100  # returned.
   101  entry_written 7 5 3 
   102  ----
   103  17
   104  
   105  # The inflight size is 0, and the total size is 11.
   106  entry_written 11 8 4
   107  ----
   108  17
   109  
   110  num_written_entries
   111  ----
   112  3
   113  
   114  # The compression ratio is 0.64, and the inflight size is 20, 20*0.64 = 12.8,
   115  # so the total size is uint64(12.8 + 11)
   116  add_inflight 20
   117  ----
   118  23
   119  
   120  num_inflight_entries
   121  ----
   122  1
   123  
   124  # We can write an entry, but it might not have an inflightSize, because it
   125  # was never inflight. In such a case, the numInflightEntries, shouldn't be
   126  # decreased.
   127  entry_written 11 0 4
   128  ----
   129  28
   130  
   131  num_inflight_entries
   132  ----
   133  1