Class Overlaps


  • public class Overlaps
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Overlaps()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <E,​B>
      java.util.List<B>
      assignOverlapsIntoBuckets​(int threshold, Overlaps.InclusionMethod inclusionMethod, java.util.List<java.util.Set<E>> overlaps, Overlaps.BucketMaker<E,​B> bucketer)
      Assign overlap sections into buckets.
      static <E> java.util.List<java.util.Set<E>> constructOverlapSets​(java.util.List<E> items, java.util.function.BiPredicate<E,​E> startsAfter, java.util.Comparator<E> startsComparator, java.util.Comparator<E> endsComparator)
      Construct a minimal list of overlap sets, i.e.
      static <T> java.util.List<T> pullLast​(java.util.List<T> source, int limit)
      Pull the last elements from the given list, up to the given limit.
      static <T> java.util.Collection<T> pullLastWithOverlapLimit​(java.util.List<T> allObjectsSorted, java.util.List<java.util.Set<T>> overlapSets, int limit)
      Select up to `limit` sstables from each overlapping set (more than `limit` in total) by taking the last entries from `allObjectsSorted`.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Overlaps

        public Overlaps()
    • Method Detail

      • constructOverlapSets

        public static <E> java.util.List<java.util.Set<E>> constructOverlapSets​(java.util.List<E> items,
                                                                                java.util.function.BiPredicate<E,​E> startsAfter,
                                                                                java.util.Comparator<E> startsComparator,
                                                                                java.util.Comparator<E> endsComparator)
        Construct a minimal list of overlap sets, i.e. the sections of the range span when we have overlapping items, where we ensure: - non-overlapping items are never put in the same set - no item is present in non-consecutive sets - for any point where items overlap, the result includes a set listing all overlapping items

        For example, for inputs A[0, 4), B[2, 8), C[6, 10), D[1, 9) the result would be the sets ABD and BCD. We are not interested in the spans where A, B, or C are present on their own or in combination with D, only that there exists a set in the list that is a superset of any such combination, and that the non-overlapping A and C are never together in a set.

        Note that the full list of overlap sets A, AD, ABD, BD, BCD, CD, C is also an answer that satisfies the three conditions above, but it contains redundant sets (e.g. AD is already contained in ABD).

        Parameters:
        items - A list of items to distribute in overlap sets. This is assumed to be a transient list and the method may modify or consume it. It is assumed that the start and end positions of an item are ordered, and the items are non-empty.
        startsAfter - Predicate determining if its left argument's start if fully after the right argument's end. This will only be used with arguments where left's start is known to be after right's start. It is up to the caller if this is a strict comparison -- strict (>) for end-inclusive spans and non-strict (>=) for end-exclusive.
        startsComparator - Comparator of items' starting positions.
        endsComparator - Comparator of items' ending positions.
        Returns:
        List of overlap sets.
      • assignOverlapsIntoBuckets

        public static <E,​B> java.util.List<B> assignOverlapsIntoBuckets​(int threshold,
                                                                              Overlaps.InclusionMethod inclusionMethod,
                                                                              java.util.List<java.util.Set<E>> overlaps,
                                                                              Overlaps.BucketMaker<E,​B> bucketer)
        Assign overlap sections into buckets. Identify sections that have at least threshold-many overlapping items and apply the overlap inclusion method to combine with any neighbouring sections that contain selected sstables to make sure we make full use of any sstables selected for compaction (i.e. avoid recompacting, see Controller.overlapInclusionMethod()).
        Parameters:
        threshold - Threshold for selecting a bucket. Sets below this size will be ignored, unless they need to be grouped with a neighboring set due to overlap.
        inclusionMethod - NONE to only form buckets of the overlapping sets, SINGLE to include all sets that share an sstable with a selected bucket, or TRANSITIVE to include all sets that have an overlap chain to a selected bucket.
        overlaps - An ordered list of overlap sets as returned by constructOverlapSets(java.util.List<E>, java.util.function.BiPredicate<E, E>, java.util.Comparator<E>, java.util.Comparator<E>).
        bucketer - Method used to create a bucket out of the supplied set indexes.
      • pullLast

        public static <T> java.util.List<T> pullLast​(java.util.List<T> source,
                                                     int limit)
        Pull the last elements from the given list, up to the given limit.
      • pullLastWithOverlapLimit

        public static <T> java.util.Collection<T> pullLastWithOverlapLimit​(java.util.List<T> allObjectsSorted,
                                                                           java.util.List<java.util.Set<T>> overlapSets,
                                                                           int limit)
        Select up to `limit` sstables from each overlapping set (more than `limit` in total) by taking the last entries from `allObjectsSorted`. To achieve this, keep selecting the last sstable until the next one we would add would bring the number selected in some overlap section over `limit`.