Package org.apache.kafka.connect.util
Class ConnectorUtils
- java.lang.Object
-
- org.apache.kafka.connect.util.ConnectorUtils
-
public class ConnectorUtils extends Object
Utilities that connector implementations might find useful. Contains common building blocks for writing connectors.
-
-
Constructor Summary
Constructors Constructor Description ConnectorUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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 partitionnumGroups
- the number of output groups to generate.
-
-