Search in sources :

Example 1 with SplitsAssignment

use of org.apache.flink.api.connector.source.SplitsAssignment in project flink by apache.

the class CoordinatorTestUtils method getSplitsAssignment.

/**
 * Create a SplitsAssignment. The assignments looks like following: Subtask 0: Splits {0}
 * Subtask 1: Splits {1, 2} Subtask 2: Splits {3, 4, 5}
 */
static SplitsAssignment<MockSourceSplit> getSplitsAssignment(int numSubtasks, int startingSplitId) {
    Map<Integer, List<MockSourceSplit>> assignments = new HashMap<>();
    int splitId = startingSplitId;
    for (int subtaskIndex = 0; subtaskIndex < numSubtasks; subtaskIndex++) {
        List<MockSourceSplit> subtaskAssignment = new ArrayList<>();
        for (int j = 0; j < subtaskIndex + 1; j++) {
            subtaskAssignment.add(new MockSourceSplit(splitId++));
        }
        assignments.put(subtaskIndex, subtaskAssignment);
    }
    return new SplitsAssignment<>(assignments);
}
Also used : HashMap(java.util.HashMap) SplitsAssignment(org.apache.flink.api.connector.source.SplitsAssignment) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) MockSourceSplit(org.apache.flink.api.connector.source.mocks.MockSourceSplit)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 SplitsAssignment (org.apache.flink.api.connector.source.SplitsAssignment)1 MockSourceSplit (org.apache.flink.api.connector.source.mocks.MockSourceSplit)1