You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/05/20 13:41:55 UTC

[GitHub] [flink] pnowojski commented on a change in pull request #12243: [FLINK-17805][networ] Fix ArrayIndexOutOfBound for rotated input gate indexes

pnowojski commented on a change in pull request #12243:
URL: https://github.com/apache/flink/pull/12243#discussion_r428017856



##########
File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/io/InputProcessorUtilTest.java
##########
@@ -58,4 +79,57 @@ public void testGenerateInputGateToChannelIndexOffsetMap() {
 		assertEquals(0, inputGateToChannelIndexOffsetMap.get(ig1).intValue());
 		assertEquals(3, inputGateToChannelIndexOffsetMap.get(ig2).intValue());
 	}
+
+	@Test
+	public void testCreateCheckpointedMultipleInputGate() throws Exception {
+		try (CloseableRegistry registry = new CloseableRegistry()) {
+			MockEnvironment environment = new MockEnvironmentBuilder().build();
+			MockStreamTask streamTask = new MockStreamTaskBuilder(environment).build();
+			StreamConfig streamConfig = new StreamConfig(environment.getJobConfiguration());
+			streamConfig.setCheckpointMode(CheckpointingMode.EXACTLY_ONCE);
+			streamConfig.setUnalignedCheckpointsEnabled(true);
+
+			// First input gate has index larger than the second
+			Collection<IndexedInputGate>[] inputGates = new Collection[] {
+				Collections.singletonList(new MockIndexedInputGate(1, 4)),
+				Collections.singletonList(new MockIndexedInputGate(0, 2)),
+			};
+
+			new MockChannelStateWriter() {

Review comment:
       ops, that's a left over of some previous version.

##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/io/InputProcessorUtil.java
##########
@@ -79,11 +80,26 @@ public static CheckpointedInputGate createCheckpointedInputGate(
 			unionedInputGates[i] = InputGateUtil.createInputGate(inputGates[i].toArray(new IndexedInputGate[0]));
 		}
 
+		IntStream numberOfInputChannelsPerGate =
+			Arrays
+				.stream(inputGates)
+				.flatMap(collection -> collection.stream())
+				.sorted(Comparator.comparingInt(IndexedInputGate::getGateIndex))
+				.mapToInt(InputGate::getNumberOfInputChannels);
+
 		Map<InputGate, Integer> inputGateToChannelIndexOffset = generateInputGateToChannelIndexOffsetMap(unionedInputGates);
+		// Note that numberOfInputChannelsPerGate and inputGateToChannelIndexOffset have a bit different

Review comment:
       Hmmm, I'm not sure, as what if left input has input gates with indexes `0` and `3`, while the right input has indexes `1`, `2` and `4`? (I'm not sure if that's a valid scenario in the JobGraphGenerator) Left input would have a one instance of `UnionInputGate` over gates 0 and 3, while right input would have another instance with gates 1, 2 and 4. However we sort them, it would be somehow inconsistent? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org