Class ConnectorUtils


  • public class ConnectorUtils
    extends Object
    Utilities that connector implementations might find useful. Contains common building blocks for writing connectors.
    • Constructor Detail

      • ConnectorUtils

        public ConnectorUtils()
    • Method Detail

      • groupPartitions

        public static <T> List<List<T>> groupPartitions​(List<T> elements,
                                                        int numGroups)
        Given a list of elements and a target number of groups, generates list of groups of elements to match the target number of groups, spreading them evenly among the groups. This generates groups with contiguous elements, which results in intuitive ordering if your elements are also ordered (e.g. alphabetical lists of table names if you sort table names alphabetically to generate the raw partitions) or can result in efficient partitioning if elements are sorted according to some criteria that affects performance (e.g. topic partitions with the same leader).
        Parameters:
        elements - list of elements to partition
        numGroups - the number of output groups to generate.