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

     1  batch
     2  set a 1
     3  set b 2
     4  del c
     5  ----
     6  
     7  flush
     8  ----
     9  0.0:
    10    000005:[a#1,SET-c#3,DEL]
    11  
    12  wait-pending-table-stats
    13  000005
    14  ----
    15  num-entries: 3
    16  num-deletions: 1
    17  num-range-key-sets: 0
    18  point-deletions-bytes-estimate: 0
    19  range-deletions-bytes-estimate: 0
    20  
    21  compact a-c
    22  ----
    23  6:
    24    000005:[a#1,SET-c#3,DEL]
    25  
    26  batch
    27  del-range a c
    28  ----
    29  
    30  flush
    31  ----
    32  0.0:
    33    000007:[a#4,RANGEDEL-c#72057594037927935,RANGEDEL]
    34  6:
    35    000005:[a#1,SET-c#3,DEL]
    36  
    37  wait-pending-table-stats
    38  000007
    39  ----
    40  num-entries: 1
    41  num-deletions: 1
    42  num-range-key-sets: 0
    43  point-deletions-bytes-estimate: 0
    44  range-deletions-bytes-estimate: 51
    45  
    46  reopen
    47  ----
    48  
    49  # After re-opening the database, the table stats collector should eventually
    50  # load 000007's stats.
    51  
    52  wait-loaded-initial
    53  ----
    54  [JOB 2] all initial table stats loaded
    55  
    56  wait-pending-table-stats
    57  000007
    58  ----
    59  num-entries: 1
    60  num-deletions: 1
    61  num-range-key-sets: 0
    62  point-deletions-bytes-estimate: 0
    63  range-deletions-bytes-estimate: 51
    64  
    65  compact a-c
    66  ----
    67  
    68  # Test a file that is moved by a compaction before its table stats are
    69  # collected. The stats collector should silently skip the first pending file,
    70  # but the second entry from the move compaction should cause the file's stats
    71  # to be loaded.
    72  
    73  disable
    74  ----
    75  
    76  batch
    77  set a 1
    78  set b 2
    79  ----
    80  
    81  flush
    82  ----
    83  0.0:
    84    000012:[a#5,SET-b#6,SET]
    85  
    86  compact a-c
    87  ----
    88  6:
    89    000012:[a#5,SET-b#6,SET]
    90  
    91  enable
    92  ----
    93  
    94  wait-pending-table-stats
    95  000012
    96  ----
    97  num-entries: 2
    98  num-deletions: 0
    99  num-range-key-sets: 0
   100  point-deletions-bytes-estimate: 0
   101  range-deletions-bytes-estimate: 0
   102  
   103  # Test a file that is deleted by a compaction before its table stats are
   104  # collected. The stats collector should just silently skip the pending file.
   105  
   106  disable
   107  ----
   108  
   109  batch
   110  del-range a c
   111  ----
   112  
   113  flush
   114  ----
   115  0.0:
   116    000014:[a#7,RANGEDEL-c#72057594037927935,RANGEDEL]
   117  6:
   118    000012:[a#5,SET-b#6,SET]
   119  
   120  compact a-c
   121  ----
   122  
   123  enable
   124  ----
   125  
   126  wait-pending-table-stats
   127  000014
   128  ----
   129  (not found)
   130  
   131  # Test range tombstones that need to be truncated to file bounds. The
   132  # grandparent limit and small target file size ensures that our manual
   133  # compaction of L4->L5 will split the range tombstone across several files.
   134  
   135  define target-file-sizes=(100, 1)
   136  L4
   137    a.RANGEDEL.8:f
   138  L5
   139    b.SET.7:v
   140  L6
   141    a.SET.1:v
   142  L6
   143    b.SET.2:v
   144  L6
   145    c.SET.3:v
   146  L6
   147    d.SET.4:v
   148  L6
   149    e.SET.5:v
   150  ----
   151  4:
   152    000004:[a#8,RANGEDEL-f#72057594037927935,RANGEDEL]
   153  5:
   154    000005:[b#7,SET-b#7,SET]
   155  6:
   156    000006:[a#1,SET-a#1,SET]
   157    000007:[b#2,SET-b#2,SET]
   158    000008:[c#3,SET-c#3,SET]
   159    000009:[d#4,SET-d#4,SET]
   160    000010:[e#5,SET-e#5,SET]
   161  
   162  compact a-b L4
   163  ----
   164  5:
   165    000011:[a#8,RANGEDEL-b#72057594037927935,RANGEDEL]
   166    000012:[b#8,RANGEDEL-c#72057594037927935,RANGEDEL]
   167    000013:[c#8,RANGEDEL-d#72057594037927935,RANGEDEL]
   168    000014:[d#8,RANGEDEL-e#72057594037927935,RANGEDEL]
   169    000015:[e#8,RANGEDEL-f#72057594037927935,RANGEDEL]
   170  6:
   171    000006:[a#1,SET-a#1,SET]
   172    000007:[b#2,SET-b#2,SET]
   173    000008:[c#3,SET-c#3,SET]
   174    000009:[d#4,SET-d#4,SET]
   175    000010:[e#5,SET-e#5,SET]
   176  
   177  wait-pending-table-stats
   178  000011
   179  ----
   180  num-entries: 1
   181  num-deletions: 1
   182  num-range-key-sets: 0
   183  point-deletions-bytes-estimate: 0
   184  range-deletions-bytes-estimate: 769
   185  
   186  wait-pending-table-stats
   187  000012
   188  ----
   189  num-entries: 1
   190  num-deletions: 1
   191  num-range-key-sets: 0
   192  point-deletions-bytes-estimate: 0
   193  range-deletions-bytes-estimate: 769
   194  
   195  # A table in L6 with two point keys blocks, each covered by distinct range dels.
   196  # The deletion estimate takes into account the contribution from both deleted
   197  # blocks. Note that the snapshot is required to allow the hint to be computed.
   198  define block-size=1 snapshots=(10)
   199  L6
   200    e.SET.5:e a.RANGEDEL.15:f m.SET.5:m g.RANGEDEL.15:z
   201  ----
   202  6:
   203    000004:[a#15,RANGEDEL-z#72057594037927935,RANGEDEL]
   204  
   205  wait-pending-table-stats
   206  000004
   207  ----
   208  num-entries: 4
   209  num-deletions: 2
   210  num-range-key-sets: 0
   211  point-deletions-bytes-estimate: 0
   212  range-deletions-bytes-estimate: 68
   213  
   214  # Hints that partially overlap tables in lower levels only count blocks that are
   215  # contained within the hint.
   216  #
   217  #  L0 |-|              000004: a.RANGEDEL:b
   218  #  L1        |---|     000005: d.RANGEDEL:f
   219  #  L2  x     x         000006: Two blocks [a, d]
   220  #  L2          x     x 000007: Two blocks [e, h]
   221  #  -------------------
   222  #      a b c d e f g h
   223  
   224  define block-size=1
   225  L0
   226    a.RANGEDEL.2:b
   227  L1
   228    d.RANGEDEL.1:f
   229  L2
   230    a.SET.0:a d.SET.0:d
   231  L2
   232    e.SET.0:e h.SET.0:h
   233  ----
   234  0.0:
   235    000004:[a#2,RANGEDEL-b#72057594037927935,RANGEDEL]
   236  1:
   237    000005:[d#1,RANGEDEL-f#72057594037927935,RANGEDEL]
   238  2:
   239    000006:[a#0,SET-d#0,SET]
   240    000007:[e#0,SET-h#0,SET]
   241  
   242  # Table 000004 deletes the first block in table 000006.
   243  wait-pending-table-stats
   244  000004
   245  ----
   246  num-entries: 1
   247  num-deletions: 1
   248  num-range-key-sets: 0
   249  point-deletions-bytes-estimate: 0
   250  range-deletions-bytes-estimate: 33
   251  
   252  # Table 000005 deletes the second block in table 000006 (containing 'd') and the
   253  # first block in table 000007 (containing 'e').
   254  wait-pending-table-stats
   255  000005
   256  ----
   257  num-entries: 1
   258  num-deletions: 1
   259  num-range-key-sets: 0
   260  point-deletions-bytes-estimate: 0
   261  range-deletions-bytes-estimate: 66
   262  
   263  # Test the interaction between point and range key deletions.
   264  
   265  define
   266  ----
   267  
   268  # Start with a table that contains point and range keys, but no range dels or
   269  # range key dels.
   270  batch
   271  set a a
   272  range-key-set a b @1 foo
   273  range-key-unset a b @2
   274  ----
   275  
   276  flush
   277  ----
   278  0.0:
   279    000005:[a#3,RANGEKEYUNSET-b#72057594037927935,RANGEKEYSET]
   280  
   281  # Add a table that contains only point keys, to the right of the existing table.
   282  batch
   283  set c c
   284  ----
   285  
   286  flush
   287  ----
   288  0.0:
   289    000005:[a#3,RANGEKEYUNSET-b#72057594037927935,RANGEKEYSET]
   290    000007:[c#4,SET-c#4,SET]
   291  
   292  compact a-c
   293  ----
   294  6:
   295    000008:[a#2,RANGEKEYSET-b#72057594037927935,RANGEKEYSET]
   296    000009:[c#0,SET-c#0,SET]
   297  
   298  # Add a table that contains a RANGEKEYDEL covering the first table in L6.
   299  batch
   300  range-key-del a b
   301  ----
   302  
   303  flush
   304  ----
   305  0.0:
   306    000011:[a#5,RANGEKEYDEL-b#72057594037927935,RANGEKEYDEL]
   307  6:
   308    000008:[a#2,RANGEKEYSET-b#72057594037927935,RANGEKEYSET]
   309    000009:[c#0,SET-c#0,SET]
   310  
   311  # Add one more table containing a RANGEDEL.
   312  batch
   313  del-range a c
   314  ----
   315  
   316  flush
   317  ----
   318  0.1:
   319    000013:[a#6,RANGEDEL-c#72057594037927935,RANGEDEL]
   320  0.0:
   321    000011:[a#5,RANGEKEYDEL-b#72057594037927935,RANGEKEYDEL]
   322  6:
   323    000008:[a#2,RANGEKEYSET-b#72057594037927935,RANGEKEYSET]
   324    000009:[c#0,SET-c#0,SET]
   325  
   326  # Compute stats on the table containing range key del. It should not show an
   327  # estimate for deleted point keys as there are no tables below it that contain
   328  # only range keys.
   329  wait-pending-table-stats
   330  000011
   331  ----
   332  num-entries: 0
   333  num-deletions: 0
   334  num-range-key-sets: 0
   335  point-deletions-bytes-estimate: 0
   336  range-deletions-bytes-estimate: 0
   337  
   338  # Compute stats on the table containing the range del. It should show an
   339  # estimate for deleted point keys, as a table below it (000008) contains point
   340  # keys. Note that even though table 000008 contains range keys, the range del
   341  # estimates are non-zero, as this number is agnostic of range keys.
   342  wait-pending-table-stats
   343  000013
   344  ----
   345  num-entries: 1
   346  num-deletions: 1
   347  num-range-key-sets: 0
   348  point-deletions-bytes-estimate: 0
   349  range-deletions-bytes-estimate: 915
   350  
   351  # Drop a range del and a range key del over the entire keyspace. This table can
   352  # delete everything underneath it.
   353  ingest ext1
   354  del-range a z
   355  range-key-del a z
   356  ----
   357  0.2:
   358    000014:[a#7,RANGEKEYDEL-z#72057594037927935,RANGEDEL]
   359  0.1:
   360    000013:[a#6,RANGEDEL-c#72057594037927935,RANGEDEL]
   361  0.0:
   362    000011:[a#5,RANGEKEYDEL-b#72057594037927935,RANGEKEYDEL]
   363  6:
   364    000008:[a#2,RANGEKEYSET-b#72057594037927935,RANGEKEYSET]
   365    000009:[c#0,SET-c#0,SET]
   366  
   367  compact a-z
   368  ----
   369  
   370  # A hint for exclusively range key deletions that covers a table with point keys
   371  # should not contain an estimate for point keys.
   372  
   373  define
   374  ----
   375  
   376  # A table with point keys.
   377  batch
   378  set b b
   379  ----
   380  
   381  flush
   382  ----
   383  0.0:
   384    000005:[b#1,SET-b#1,SET]
   385  
   386  # A table with a mixture of point and range keys.
   387  batch
   388  set c c
   389  range-key-set d d @1 foo
   390  ----
   391  
   392  flush
   393  ----
   394  0.0:
   395    000005:[b#1,SET-b#1,SET]
   396    000007:[c#2,SET-c#2,SET]
   397  
   398  compact a-z
   399  ----
   400  6:
   401    000008:[b#0,SET-b#0,SET]
   402    000009:[c#0,SET-c#0,SET]
   403  
   404  # The table with the range key del, that spans the previous two tables.
   405  batch
   406  range-key-del a z
   407  ----
   408  
   409  flush
   410  ----
   411  0.0:
   412    000011:[a#4,RANGEKEYDEL-z#72057594037927935,RANGEKEYDEL]
   413  6:
   414    000008:[b#0,SET-b#0,SET]
   415    000009:[c#0,SET-c#0,SET]
   416  
   417  # The hint on table 000011 does estimates zero size for range deleted point
   418  # keys.
   419  wait-pending-table-stats
   420  000011
   421  ----
   422  num-entries: 0
   423  num-deletions: 0
   424  num-range-key-sets: 0
   425  point-deletions-bytes-estimate: 0
   426  range-deletions-bytes-estimate: 0
   427  
   428  # A hint from a range del that covers a table with only range keys should not
   429  # contain an estimate for the range keys.
   430  
   431  define
   432  L4
   433    a.RANGEDEL.4:c
   434  L5
   435    a.RANGEDEL.2:e
   436    b.SET.3:b
   437  L6
   438    rangekey:c-d:{(#1,RANGEKEYSET,@1,foo)}
   439  ----
   440  4:
   441    000004:[a#4,RANGEDEL-c#72057594037927935,RANGEDEL]
   442  5:
   443    000005:[a#2,RANGEDEL-e#72057594037927935,RANGEDEL]
   444  6:
   445    000006:[c#1,RANGEKEYSET-d#72057594037927935,RANGEKEYSET]
   446  
   447  # The table in L5 should not contain an estimate for the table below it, which
   448  # contains only range keys.
   449  wait-pending-table-stats
   450  000005
   451  ----
   452  num-entries: 2
   453  num-deletions: 1
   454  num-range-key-sets: 0
   455  point-deletions-bytes-estimate: 0
   456  range-deletions-bytes-estimate: 0
   457  
   458  # The table in L4 can delete the table in L5, which contains point keys. The
   459  # estimate is only partial, as the range del does not fully overlap the table.
   460  wait-pending-table-stats
   461  000004
   462  ----
   463  num-entries: 1
   464  num-deletions: 1
   465  num-range-key-sets: 0
   466  point-deletions-bytes-estimate: 0
   467  range-deletions-bytes-estimate: 26