PartitionArrangement { int[][] assignPartitionsToProcessors(int localParallelism, boolean isEdgeDistributed) { final int[] ptions = isEdgeDistributed ? localPartitions : allPartitions; final int[][] ptionsPerProcessor = createPtionArrays(ptions.length, localParallelism); for (int i = 0; i < localParallelism; i++) { for (int j = 0, ptionIndex = i; ptionIndex < ptions.length; ptionIndex += localParallelism, j++) { ptionsPerProcessor[i][j] = ptions[ptionIndex]; } } return ptionsPerProcessor; } PartitionArrangement(Address[] partitionOwners, Address thisAddress); Map<Address, int[]> remotePartitionAssignmentToOne(Address target);  }
@Test public void testAssignPartitionsToProcessors() { assertArrayEquals( new int[][]{new int[]{0, 1, 2, 3, 4, 5, 6}}, a.assignPartitionsToProcessors(1, false)); assertArrayEquals( new int[][]{ new int[]{0, 2, 4, 6}, new int[]{1, 3, 5}}, a.assignPartitionsToProcessors(2, false)); assertArrayEquals( new int[][]{ new int[]{0, 3, 6}, new int[]{1, 4}, new int[]{2, 5} }, a.assignPartitionsToProcessors(3, false)); assertArrayEquals( new int[][]{new int[]{0, 3, 6}}, a.assignPartitionsToProcessors(1, true)); assertArrayEquals( new int[][]{ new int[]{0, 6}, new int[]{3}}, a.assignPartitionsToProcessors(2, true)); assertArrayEquals( new int[][]{ new int[]{0}, new int[]{3}, new int[]{6}}, a.assignPartitionsToProcessors(3, true)); }