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

     1  # Test a scenario that should NOT result in defragmentation.
     2  
     3  define
     4  a-c:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
     5  c-d:{(#4,RANGEKEYSET,@3,bananas)}
     6  d-e:{(#4,RANGEKEYSET,@3,bananas) (#4,RANGEKEYSET,@1,pineapple)}
     7  ----
     8  
     9  iter
    10  first
    11  next
    12  next
    13  last
    14  prev
    15  prev
    16  ----
    17  first     a-c:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    18  next      c-d:{(#4,RANGEKEYSET,@3,bananas)}
    19  next      d-e:{(#4,RANGEKEYSET,@3,bananas) (#4,RANGEKEYSET,@1,pineapple)}
    20  last      d-e:{(#4,RANGEKEYSET,@3,bananas) (#4,RANGEKEYSET,@1,pineapple)}
    21  prev      c-d:{(#4,RANGEKEYSET,@3,bananas)}
    22  prev      a-c:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    23  
    24  iter
    25  first
    26  next
    27  next
    28  next
    29  last
    30  prev
    31  prev
    32  prev
    33  ----
    34  first     a-c:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    35  next      c-d:{(#4,RANGEKEYSET,@3,bananas)}
    36  next      d-e:{(#4,RANGEKEYSET,@3,bananas) (#4,RANGEKEYSET,@1,pineapple)}
    37  next      .
    38  last      d-e:{(#4,RANGEKEYSET,@3,bananas) (#4,RANGEKEYSET,@1,pineapple)}
    39  prev      c-d:{(#4,RANGEKEYSET,@3,bananas)}
    40  prev      a-c:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    41  prev      .
    42  
    43  # Test a scenario that SHOULD result in internal defragmentation ([a,c) and
    44  # [c,d) should be merged.
    45  
    46  define
    47  a-c:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    48  c-d:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    49  d-e:{(#1,RANGEKEYSET,@3,bananas)}
    50  ----
    51  
    52  iter
    53  first
    54  next
    55  next
    56  ----
    57  first     a-d:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    58  next      d-e:{(#1,RANGEKEYSET,@3,bananas)}
    59  next      .
    60  
    61  # Test defragmenting in both directions at seek keys.
    62  
    63  define
    64  a-f:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    65  f-h:{(#3,RANGEKEYSET,@3,bananas)}
    66  h-p:{(#3,RANGEKEYSET,@3,bananas)}
    67  p-t:{(#3,RANGEKEYSET,@3,bananas)}
    68  ----
    69  
    70  iter
    71  seekge b
    72  prev
    73  seekge b
    74  next
    75  seeklt d
    76  next
    77  seeklt d
    78  prev
    79  ----
    80  seekge b  f-t:{(#3,RANGEKEYSET,@3,bananas)}
    81  prev      a-f:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    82  seekge b  f-t:{(#3,RANGEKEYSET,@3,bananas)}
    83  next      .
    84  seeklt d  a-f:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    85  next      f-t:{(#3,RANGEKEYSET,@3,bananas)}
    86  seeklt d  a-f:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    87  prev      .
    88  
    89  iter
    90  seeklt d
    91  next
    92  prev
    93  ----
    94  seeklt d  a-f:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    95  next      f-t:{(#3,RANGEKEYSET,@3,bananas)}
    96  prev      a-f:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
    97  
    98  # Test next-ing and prev-ing around seek keys.
    99  
   100  define
   101  a-f:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
   102  f-h:{(#3,RANGEKEYSET,@3,bananas)}
   103  h-p:{(#3,RANGEKEYSET,@3,bananas)}
   104  p-t:{(#3,RANGEKEYSET,@3,bananas)}
   105  t-z:{(#4,RANGEKEYSET,@2,oranges)}
   106  ----
   107  
   108  iter
   109  seekge r
   110  prev
   111  next
   112  next
   113  ----
   114  seekge r  t-z:{(#4,RANGEKEYSET,@2,oranges)}
   115  prev      f-t:{(#3,RANGEKEYSET,@3,bananas)}
   116  next      t-z:{(#4,RANGEKEYSET,@2,oranges)}
   117  next      .
   118  
   119  iter
   120  seekge f
   121  seekge h
   122  seekge p
   123  seekge t
   124  ----
   125  seekge f  f-t:{(#3,RANGEKEYSET,@3,bananas)}
   126  seekge h  t-z:{(#4,RANGEKEYSET,@2,oranges)}
   127  seekge p  t-z:{(#4,RANGEKEYSET,@2,oranges)}
   128  seekge t  t-z:{(#4,RANGEKEYSET,@2,oranges)}
   129  
   130  iter
   131  seeklt f
   132  seeklt h
   133  seeklt p
   134  seeklt t
   135  seeklt z
   136  ----
   137  seeklt f  a-f:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
   138  seeklt h  f-t:{(#3,RANGEKEYSET,@3,bananas)}
   139  seeklt p  f-t:{(#3,RANGEKEYSET,@3,bananas)}
   140  seeklt t  f-t:{(#3,RANGEKEYSET,@3,bananas)}
   141  seeklt z  t-z:{(#4,RANGEKEYSET,@2,oranges)}
   142  
   143  # Test iteration with a reducer that collects keys across all spans that
   144  # constitute a defragmented span. Abutting spans are always combined.
   145  
   146  define
   147  a-b:{(#3,RANGEDEL) (#2,RANGEDEL)}
   148  b-c:{(#4,RANGEDEL) (#1,RANGEDEL)}
   149  c-d:{(#5,RANGEDEL)}
   150  e-f:{(#1,RANGEDEL)}
   151  f-g:{(#2,RANGEDEL)}
   152  ----
   153  
   154  iter equal=always reducer=collect
   155  first
   156  next
   157  next
   158  last
   159  prev
   160  prev
   161  ----
   162  first     a-d:{(#5,RANGEDEL) (#4,RANGEDEL) (#3,RANGEDEL) (#2,RANGEDEL) (#1,RANGEDEL)}
   163  next      e-g:{(#2,RANGEDEL) (#1,RANGEDEL)}
   164  next      .
   165  last      e-g:{(#2,RANGEDEL) (#1,RANGEDEL)}
   166  prev      a-d:{(#5,RANGEDEL) (#4,RANGEDEL) (#3,RANGEDEL) (#2,RANGEDEL) (#1,RANGEDEL)}
   167  prev      .
   168  
   169  # Test defragmentation of non-empty (i.e. more than one value) fragments, while
   170  # empty fragments are left untouched.
   171  
   172  define
   173  a-c:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
   174  c-d:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
   175  d-e:{}
   176  e-f:{}
   177  g-h:{(#1,RANGEKEYSET,@3,bananas)}
   178  ----
   179  
   180  iter
   181  first
   182  next
   183  next
   184  next
   185  next
   186  ----
   187  first     a-d:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
   188  next      d-e:{}
   189  next      e-f:{}
   190  next      g-h:{(#1,RANGEKEYSET,@3,bananas)}
   191  next      .
   192  
   193  iter
   194  last
   195  prev
   196  prev
   197  prev
   198  prev
   199  ----
   200  last      g-h:{(#1,RANGEKEYSET,@3,bananas)}
   201  prev      e-f:{}
   202  prev      d-e:{}
   203  prev      a-d:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
   204  prev      .
   205  
   206  iter
   207  seekge d
   208  next
   209  prev
   210  seekge e
   211  next
   212  prev
   213  prev
   214  prev
   215  ----
   216  seekge d  d-e:{}
   217  next      e-f:{}
   218  prev      d-e:{}
   219  seekge e  e-f:{}
   220  next      g-h:{(#1,RANGEKEYSET,@3,bananas)}
   221  prev      e-f:{}
   222  prev      d-e:{}
   223  prev      a-d:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}
   224  
   225  iter
   226  seeklt e
   227  next
   228  prev
   229  seeklt f
   230  next
   231  prev
   232  prev
   233  prev
   234  ----
   235  seeklt e  d-e:{}
   236  next      e-f:{}
   237  prev      d-e:{}
   238  seeklt f  e-f:{}
   239  next      g-h:{(#1,RANGEKEYSET,@3,bananas)}
   240  prev      e-f:{}
   241  prev      d-e:{}
   242  prev      a-d:{(#3,RANGEKEYUNSET,@5) (#2,RANGEKEYSET,@5,apples) (#1,RANGEKEYSET,@3,bananas)}