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

     1  # Verify these invariantLs:
     2  # No overlapping ranges.
     3  # Size should reflect what's currently in the queue.
     4  # Empty queue should return nil.
     5  # Oldest element should be removed first.
     6  
     7  # Remove from empty queue.
     8  # Removing from the empty queue should return nil.
     9  create
    10  ----
    11  (success)
    12  
    13  print-size
    14  ----
    15  0
    16  
    17  remove-compaction
    18  ----
    19  (nil)
    20  
    21  # Add to empty queue.
    22  create
    23  ----
    24  (success)
    25  
    26  add-compaction
    27  L5: a-e 1
    28  ----
    29  
    30  print-size
    31  ----
    32  1
    33  
    34  remove-compaction
    35  ----
    36  L5: a-e 1
    37  
    38  print-size
    39  ----
    40  0
    41  
    42  remove-compaction
    43  ----
    44  (nil)
    45  
    46  # No intersection in a non-full queue.
    47  create
    48  ----
    49  (success)
    50  
    51  add-compaction
    52  L5: a-e 1
    53  ----
    54  
    55  print-queue
    56  ----
    57  L5: a-e 1
    58  
    59  add-compaction
    60  L5: g-k 2
    61  ----
    62  
    63  print-queue
    64  ----
    65  L5: a-e 1
    66  L5: g-k 2
    67  
    68  print-size
    69  ----
    70  2
    71  
    72  remove-compaction
    73  ----
    74  L5: a-e 1
    75  
    76  print-size
    77  ----
    78  1
    79  
    80  remove-compaction
    81  ----
    82  L5: g-k 2
    83  
    84  print-size
    85  ----
    86  0
    87  
    88  # No intersection in a full queue.
    89  # This adds a compaction once the queue is already full.
    90  # This new compaction doesn't intersect with any compaction
    91  # already in the queue, so the oldest element is evicted.
    92  create
    93  ----
    94  (success)
    95  
    96  add-compaction
    97  L5: a-e 1
    98  ----
    99  
   100  add-compaction
   101  L5: f-g 2
   102  ----
   103  
   104  add-compaction
   105  L5: k-m 3
   106  ----
   107  
   108  add-compaction
   109  L5: n-o 4
   110  ----
   111  
   112  add-compaction
   113  L5: p-r 5
   114  ----
   115  
   116  print-size
   117  ----
   118  5
   119  
   120  print-queue
   121  ----
   122  L5: a-e 1
   123  L5: f-g 2
   124  L5: k-m 3
   125  L5: n-o 4
   126  L5: p-r 5
   127  
   128  add-compaction
   129  L4: t-u 6
   130  ----
   131  
   132  print-queue
   133  ----
   134  L5: f-g 2
   135  L5: k-m 3
   136  L5: n-o 4
   137  L5: p-r 5
   138  L4: t-u 6
   139  
   140  print-size
   141  ----
   142  5
   143  
   144  
   145  # One intersection in a non-full queue.
   146  # Try intersections with intervals at
   147  # various positions in the queue, and examine
   148  # the state of the queue after.
   149  create
   150  ----
   151  (success)
   152  
   153  add-compaction
   154  L5: a-e 1
   155  ----
   156  
   157  add-compaction
   158  L5: f-g 2
   159  ----
   160  
   161  add-compaction
   162  L5: k-m 3
   163  ----
   164  
   165  add-compaction
   166  L5: n-w 4
   167  ----
   168  
   169  # 
   170  print-size
   171  ----
   172  4
   173  
   174  print-queue
   175  ----
   176  L5: a-e 1
   177  L5: f-g 2
   178  L5: k-m 3
   179  L5: n-w 4
   180  
   181  # Add interval which intersects with the first
   182  # interval in the queue.
   183  add-compaction
   184  L4: c-d 5
   185  ----
   186  
   187  print-queue
   188  ----
   189  L5: f-g 2
   190  L5: k-m 3
   191  L5: n-w 4
   192  L4: c-d 5
   193  
   194  print-size
   195  ----
   196  4
   197  
   198  # Add an interval which intersects with the last
   199  # element in the queue.
   200  add-compaction
   201  L3: a-d 6
   202  ----
   203  
   204  print-queue
   205  ----
   206  L5: f-g 2
   207  L5: k-m 3
   208  L5: n-w 4
   209  L3: a-d 6
   210  
   211  print-size
   212  ----
   213  4
   214  
   215  # Add an interval which intersects with an element in the
   216  # middle of the queue.
   217  add-compaction
   218  L3: u-z 7
   219  ----
   220  
   221  print-queue
   222  ----
   223  L5: f-g 2
   224  L5: k-m 3
   225  L3: a-d 6
   226  L3: u-z 7
   227  
   228  print-size
   229  ----
   230  4
   231  
   232  remove-compaction
   233  ----
   234  L5: f-g 2
   235  
   236  remove-compaction
   237  ----
   238  L5: k-m 3
   239  
   240  remove-compaction
   241  ----
   242  L3: a-d 6
   243  
   244  remove-compaction
   245  ----
   246  L3: u-z 7
   247  
   248  remove-compaction
   249  ----
   250  (nil)
   251  
   252  # One intersection in a full queue.
   253  # We're doing some tests with full/non-full queues
   254  # because the logic for those cases is sometimes different.
   255  create
   256  ----
   257  (success)
   258  
   259  add-compaction
   260  L5: a-e 1
   261  ----
   262  
   263  add-compaction
   264  L5: f-g 2
   265  ----
   266  
   267  add-compaction
   268  L5: k-m 3
   269  ----
   270  
   271  add-compaction
   272  L5: n-w 4
   273  ----
   274  
   275  add-compaction
   276  L5: x-z 5
   277  ----
   278  
   279  print-size
   280  ----
   281  5
   282  
   283  print-queue
   284  ----
   285  L5: a-e 1
   286  L5: f-g 2
   287  L5: k-m 3
   288  L5: n-w 4
   289  L5: x-z 5
   290  
   291  # Add interval which intersects with the first
   292  # interval in the queue.
   293  add-compaction
   294  L4: c-d 6
   295  ----
   296  
   297  print-queue
   298  ----
   299  L5: f-g 2
   300  L5: k-m 3
   301  L5: n-w 4
   302  L5: x-z 5
   303  L4: c-d 6
   304  
   305  print-size
   306  ----
   307  5
   308  
   309  # Add an interval which intersects with the last
   310  # element in the queue.
   311  add-compaction
   312  L3: a-d 6
   313  ----
   314  
   315  print-queue
   316  ----
   317  L5: f-g 2
   318  L5: k-m 3
   319  L5: n-w 4
   320  L5: x-z 5
   321  L3: a-d 6
   322  
   323  print-size
   324  ----
   325  5
   326  
   327  # Add an interval which intersects with an element in the
   328  # middle of the queue.
   329  add-compaction
   330  L3: u-z 7
   331  ----
   332  
   333  print-queue
   334  ----
   335  L5: f-g 2
   336  L5: k-m 3
   337  L3: a-d 6
   338  L3: u-z 7
   339  
   340  print-size
   341  ----
   342  4
   343  
   344  remove-compaction
   345  ----
   346  L5: f-g 2
   347  
   348  remove-compaction
   349  ----
   350  L5: k-m 3
   351  
   352  remove-compaction
   353  ----
   354  L3: a-d 6
   355  
   356  remove-compaction
   357  ----
   358  L3: u-z 7
   359  
   360  remove-compaction
   361  ----
   362  (nil)
   363  
   364  # More than one intersection in a non-full queue.
   365  create
   366  ----
   367  (success)
   368  
   369  add-compaction
   370  L5: a-e 1
   371  ----
   372  
   373  add-compaction
   374  L5: f-g 2
   375  ----
   376  
   377  add-compaction
   378  L5: k-m 3
   379  ----
   380  
   381  add-compaction
   382  L5: n-w 4
   383  ----
   384  
   385  # 
   386  print-size
   387  ----
   388  4
   389  
   390  print-queue
   391  ----
   392  L5: a-e 1
   393  L5: f-g 2
   394  L5: k-m 3
   395  L5: n-w 4
   396  
   397  # Add an interval with intersects with two elements of the queue.
   398  add-compaction
   399  L4: f-m 5
   400  ----
   401  
   402  print-queue
   403  ----
   404  L5: a-e 1
   405  L5: n-w 4
   406  L4: f-m 5
   407  
   408  print-size
   409  ----
   410  3
   411  
   412  # Add an interval which clears the entire queue.
   413  add-compaction
   414  L3: a-z 6
   415  ----
   416  
   417  print-queue
   418  ----
   419  L3: a-z 6
   420  
   421  print-size
   422  ----
   423  1
   424  
   425  remove-compaction
   426  ----
   427  L3: a-z 6
   428  
   429  
   430  remove-compaction
   431  ----
   432  (nil)
   433  
   434  print-size
   435  ----
   436  0
   437  
   438  # More than one intersection in a full queue.
   439  create
   440  ----
   441  (success)
   442  
   443  add-compaction
   444  L5: a-e 1
   445  ----
   446  
   447  add-compaction
   448  L5: f-g 2
   449  ----
   450  
   451  add-compaction
   452  L5: k-m 3
   453  ----
   454  
   455  add-compaction
   456  L5: n-w 4
   457  ----
   458  
   459  add-compaction
   460  L3: y-z 5
   461  ----
   462  
   463  add-compaction
   464  L2: a-z 6
   465  ----
   466  
   467  print-queue
   468  ----
   469  L2: a-z 6
   470  
   471  print-size
   472  ----
   473  1
   474  
   475  create
   476  ----
   477  (success)
   478  
   479  add-compaction
   480  L5: a-e 1
   481  ----
   482  
   483  add-compaction
   484  L5: f-g 2
   485  ----
   486  
   487  add-compaction
   488  L5: k-m 3
   489  ----
   490  
   491  add-compaction
   492  L5: n-w 4
   493  ----
   494  
   495  add-compaction
   496  L3: y-z 5
   497  ----
   498  
   499  # Test multiple overlap which doesn't cover the entire full queue.
   500  
   501  add-compaction
   502  L2: o-y 6
   503  ----
   504  
   505  print-queue
   506  ----
   507  L5: a-e 1
   508  L5: f-g 2
   509  L5: k-m 3
   510  L2: o-y 6
   511  
   512  remove-compaction
   513  ----
   514  L5: a-e 1
   515  
   516  remove-compaction
   517  ----
   518  L5: f-g 2
   519  
   520  remove-compaction
   521  ----
   522  L5: k-m 3
   523  
   524  remove-compaction
   525  ----
   526  L2: o-y 6
   527  
   528  remove-compaction
   529  ----
   530  (nil)
   531  
   532  # Test a queue which becomes full, then empty, then fills up again.
   533  create
   534  ----
   535  (success)
   536  
   537  add-compaction
   538  L5: a-e 1
   539  ----
   540  
   541  add-compaction
   542  L5: f-g 2
   543  ----
   544  
   545  add-compaction
   546  L5: k-m 3
   547  ----
   548  
   549  add-compaction
   550  L5: n-w 4
   551  ----
   552  
   553  add-compaction
   554  L3: y-z 5
   555  ----
   556  
   557  add-compaction
   558  L2: o-y 6
   559  ----
   560  
   561  print-queue
   562  ----
   563  L5: a-e 1
   564  L5: f-g 2
   565  L5: k-m 3
   566  L2: o-y 6
   567  
   568  remove-compaction
   569  ----
   570  L5: a-e 1
   571  
   572  remove-compaction
   573  ----
   574  L5: f-g 2
   575  
   576  remove-compaction
   577  ----
   578  L5: k-m 3
   579  
   580  remove-compaction
   581  ----
   582  L2: o-y 6
   583  
   584  remove-compaction
   585  ----
   586  (nil)
   587  
   588  add-compaction
   589  L5: a-e 1
   590  ----
   591  
   592  add-compaction
   593  L5: f-g 2
   594  ----
   595  
   596  add-compaction
   597  L5: k-m 3
   598  ----
   599  
   600  add-compaction
   601  L5: n-w 4
   602  ----
   603  
   604  print-queue
   605  ----
   606  L5: a-e 1
   607  L5: f-g 2
   608  L5: k-m 3
   609  L5: n-w 4
   610  
   611  print-size
   612  ----
   613  4
   614  
   615  # Test overlap once we refill the queue.
   616  add-compaction
   617  L4: b-l 5
   618  ----
   619  
   620  print-queue
   621  ----
   622  L5: n-w 4
   623  L4: b-l 5
   624  
   625  print-size
   626  ----
   627  2