public class SSTableOfflineRelevel
extends java.lang.Object
Create a decent leveling for the given keyspace/column family
Approach is to sort the sstables by their last token
given an original leveling like this (note that [ ] indicates token boundaries, not sstable size on disk, all sstables are the same size)
L3 [][][][][][][][][][][]
L2 [ ][ ][ ][ ]
L1 [ ][ ]
L0 [ ]
Will look like this after being dropped to L0 and sorted by last token (and, to illustrate overlap, the overlapping ones are put on a new line):
[][][]
[ ][][][]
[ ]
[ ]
...
Then, we start iterating from the smallest last-token and adding all sstables that do not cause an overlap to
a level, we will reconstruct the original leveling top-down. Whenever we add an sstable to the level, we remove it from
the sorted list. Once we reach the end of the sorted list, we have a full level, and can start over with the level below.
If we end up with more levels than expected, we put all levels exceeding the expected in L0, for example, original L0
files will most likely be put in a level of its own since they most often overlap many other sstables