You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "jeyhunkarimov (via GitHub)" <gi...@apache.org> on 2024/03/10 14:59:06 UTC
[PR] [WIP][FLINK-32513][core] Add predecessor caching [flink]
jeyhunkarimov opened a new pull request, #24475:
URL: https://github.com/apache/flink/pull/24475
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
*(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
## Brief change log
*(for example:)*
- *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
- *Deployments RPC transmits only the blob storage reference*
- *TaskManagers retrieve the TaskInfo from the blob cache*
## Verifying this change
Please make sure both new and modified tests in this PR follows the conventions defined in our code quality guide: https://flink.apache.org/contributing/code-style-and-quality-common.html#testing
*(Please pick either of the following options)*
This change is a trivial rework / code cleanup without any test coverage.
*(or)*
This change is already covered by existing tests, such as *(please describe tests)*.
*(or)*
This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads (100MB)*
- *Extended integration test for recovery after master (JobManager) failure*
- *Added test that validates that TaskInfo is transferred only once across recoveries*
- *Manually verified the change by running a 4 node cluster with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
- The serializers: (yes / no / don't know)
- The runtime per-record code paths (performance sensitive): (yes / no / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
- The S3 file system connector: (yes / no / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #24475:
URL: https://github.com/apache/flink/pull/24475#discussion_r1524777467
##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/transformations/AbstractMultipleInputTransformation.java:
##########
@@ -76,10 +78,10 @@ public StreamOperatorFactory<OUT> getOperatorFactory() {
}
@Override
- public List<Transformation<?>> getTransitivePredecessors() {
Review Comment:
Well. I just noticed a potential bug that the transformation itself is not added to the predecessors, unlike all other transformations.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "jeyhunkarimov (via GitHub)" <gi...@apache.org>.
jeyhunkarimov commented on PR #24475:
URL: https://github.com/apache/flink/pull/24475#issuecomment-2002135965
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #24475:
URL: https://github.com/apache/flink/pull/24475#discussion_r1519708804
##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/transformations/AbstractMultipleInputTransformation.java:
##########
@@ -76,7 +76,7 @@ public StreamOperatorFactory<OUT> getOperatorFactory() {
}
@Override
- public List<Transformation<?>> getTransitivePredecessors() {
+ protected List<Transformation<?>> getTransitivePredecessorsInternal() {
return inputs.stream()
.flatMap(input -> input.getTransitivePredecessors().stream())
Review Comment:
One transformation, and all its predecessors, can appear multiple times if it is the head of a diamond DAG structure, like the case reported in FLINK-32513. This may results in lots of memory consumption.
Maybe we can introduce an `LinkedHashSet` to do deduplication.
##########
flink-core/src/test/java/org/apache/flink/api/dag/TransformationTest.java:
##########
@@ -42,10 +43,21 @@
public class TransformationTest extends TestLogger {
private Transformation<Void> transformation;
+ private Transformation<Void> transformationWithInput;
@Before
public void setUp() {
transformation = new TestTransformation<>("t", null, 1);
+ transformationWithInput =
+ new TestTransformationWithInput<>(
+ "t", null, 1, Arrays.asList(transformation, transformation));
+ }
+
+ @Test
+ public void testPredecessorCache() throws Exception {
+ transformationWithInput.getTransitivePredecessors();
+ assertEquals(transformationWithInput.getPredecessorsCache().size(), 1);
+ assertEquals(((TestTransformation<?>) transformation).getNumGetTransitivePredecessor(), 1);
}
Review Comment:
Could you construct a case that is demonstrated in FLINK-32513 and verify the traversing count and predecessor count?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "jeyhunkarimov (via GitHub)" <gi...@apache.org>.
jeyhunkarimov commented on PR #24475:
URL: https://github.com/apache/flink/pull/24475#issuecomment-1990782761
Thanks @zhuzhurk for the review. I addressed them. Could you please check again?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WIP][FLINK-32513][core] Add predecessor caching [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #24475:
URL: https://github.com/apache/flink/pull/24475#issuecomment-1987262990
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "89fdb18a4980e46c30683675025736b9ce5fd05d",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "89fdb18a4980e46c30683675025736b9ce5fd05d",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 89fdb18a4980e46c30683675025736b9ce5fd05d UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk closed pull request #24475: [FLINK-32513][core] Add predecessor caching
URL: https://github.com/apache/flink/pull/24475
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "jeyhunkarimov (via GitHub)" <gi...@apache.org>.
jeyhunkarimov commented on PR #24475:
URL: https://github.com/apache/flink/pull/24475#issuecomment-2002153186
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #24475:
URL: https://github.com/apache/flink/pull/24475#discussion_r1524742606
##########
flink-core/src/test/java/org/apache/flink/api/dag/TransformationTest.java:
##########
@@ -42,10 +43,21 @@
public class TransformationTest extends TestLogger {
private Transformation<Void> transformation;
+ private Transformation<Void> transformationWithInput;
@Before
public void setUp() {
transformation = new TestTransformation<>("t", null, 1);
+ transformationWithInput =
+ new TestTransformationWithInput<>(
+ "t", null, 1, Arrays.asList(transformation, transformation));
+ }
+
+ @Test
+ public void testPredecessorCache() throws Exception {
+ transformationWithInput.getTransitivePredecessors();
+ assertEquals(transformationWithInput.getPredecessorsCache().size(), 1);
+ assertEquals(((TestTransformation<?>) transformation).getNumGetTransitivePredecessor(), 1);
}
Review Comment:
Can we verify the result of `topNode.getTransitivePredecessors()`?
Ideally it should be 3. But without the fix it will be 4.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #24475:
URL: https://github.com/apache/flink/pull/24475#discussion_r1533318682
##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/transformations/GetTransitivePredecessorsTest.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.api.transformations;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.typeutils.GenericTypeInfo;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@code getTransitivePredecessors} method of {@link Transformation}. */
+class GetTransitivePredecessorsTest extends TestLogger {
Review Comment:
` extends TestLogger` is no longer needed since JUnit5. The logging will be enabled automatically.
##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/transformations/GetTransitivePredecessorsTest.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.api.transformations;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.typeutils.GenericTypeInfo;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@code getTransitivePredecessors} method of {@link Transformation}. */
+class GetTransitivePredecessorsTest extends TestLogger {
+
+ private Transformation<Integer> commonNode;
+ private Transformation<Integer> midNode;
+
+ @BeforeEach
+ void setup() {
+ commonNode = new TestTransformation<>("commonNode", new MockIntegerTypeInfo(), 1);
+ midNode =
+ new OneInputTransformation<>(
+ commonNode,
+ "midNode",
+ new DummyOneInputOperator(),
+ new MockIntegerTypeInfo(),
+ 1);
+ }
+
+ @Test
+ void testTwoInputTransformation() {
+ Transformation<Integer> topNode =
+ new TwoInputTransformation<>(
+ commonNode,
+ midNode,
+ "topNode",
+ new DummyTwoInputOperator<>(),
+ midNode.getOutputType(),
+ 1);
+ List<Transformation<?>> predecessors = topNode.getTransitivePredecessors();
+ assertThat(predecessors.size()).isEqualTo(3);
+ assertThat(((TestTransformation<?>) commonNode).getNumGetTransitivePredecessor())
Review Comment:
We may change the definition of `commonNode` as `TestTransformation<?>` as that we do not need to conduct type casting each time.
##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/transformations/GetTransitivePredecessorsTest.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.api.transformations;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.typeutils.GenericTypeInfo;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@code getTransitivePredecessors} method of {@link Transformation}. */
+class GetTransitivePredecessorsTest extends TestLogger {
+
+ private Transformation<Integer> commonNode;
+ private Transformation<Integer> midNode;
+
+ @BeforeEach
+ void setup() {
+ commonNode = new TestTransformation<>("commonNode", new MockIntegerTypeInfo(), 1);
+ midNode =
+ new OneInputTransformation<>(
+ commonNode,
+ "midNode",
+ new DummyOneInputOperator(),
+ new MockIntegerTypeInfo(),
+ 1);
+ }
+
+ @Test
+ void testTwoInputTransformation() {
+ Transformation<Integer> topNode =
+ new TwoInputTransformation<>(
+ commonNode,
+ midNode,
+ "topNode",
+ new DummyTwoInputOperator<>(),
+ midNode.getOutputType(),
+ 1);
+ List<Transformation<?>> predecessors = topNode.getTransitivePredecessors();
+ assertThat(predecessors.size()).isEqualTo(3);
+ assertThat(((TestTransformation<?>) commonNode).getNumGetTransitivePredecessor())
+ .isEqualTo(1);
+ }
+
+ @Test
+ void testUnionTransformation() {
+ Transformation<Integer> topNode =
+ new UnionTransformation<>(Arrays.asList(commonNode, midNode));
+ List<Transformation<?>> predecessors = topNode.getTransitivePredecessors();
+ assertThat(predecessors.size()).isEqualTo(3);
+ assertThat(((TestTransformation<?>) commonNode).getNumGetTransitivePredecessor())
+ .isEqualTo(1);
+ }
+
+ @Test
+ void testBroadcastStateTransformation() {
+ Transformation<Integer> topNode =
+ new AbstractBroadcastStateTransformation<>(
+ "topNode", commonNode, midNode, null, midNode.getOutputType(), 1);
+ List<Transformation<?>> predecessors = topNode.getTransitivePredecessors();
+ assertThat(predecessors.size()).isEqualTo(3);
+ assertThat(((TestTransformation<?>) commonNode).getNumGetTransitivePredecessor())
+ .isEqualTo(0);
+ }
Review Comment:
Maybe one more test case for `AbstractMultipleInputTransformation`?
##########
flink-core/src/test/java/org/apache/flink/api/dag/TransformationTest.java:
##########
@@ -24,32 +24,30 @@
import org.apache.flink.core.testutils.OneShotLatch;
import org.apache.flink.util.TestLogger;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
/** Tests for {@link Transformation}. */
-public class TransformationTest extends TestLogger {
+class TransformationTest extends TestLogger {
Review Comment:
`extends TestLogger` is no longer needed after migrating to JUnit5.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "jeyhunkarimov (via GitHub)" <gi...@apache.org>.
jeyhunkarimov commented on PR #24475:
URL: https://github.com/apache/flink/pull/24475#issuecomment-2014868333
> Looks good to me. Thanks for addressing all the comments! @jeyhunkarimov Would you squash the last two commits and rebase the changes onto the latest Flink master branch?
Thanks a lot @zhuzhurk for your reviews. Done
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #24475:
URL: https://github.com/apache/flink/pull/24475#discussion_r1524746682
##########
flink-core/src/test/java/org/apache/flink/api/dag/TransformationTest.java:
##########
@@ -125,19 +145,34 @@ public void testDeclareManagedMemorySlotScopeUseCaseFailWrongScope() {
/** A test implementation of {@link Transformation}. */
private static class TestTransformation<T> extends Transformation<T> {
-
- public TestTransformation(String name, TypeInformation<T> outputType, int parallelism) {
Review Comment:
It's better to introduce a `TestMultipleInputTransformation` which inherits `AbstractMultipleInputTransformation`.
Otherwise we are testing some testing logic instead of production logic.
##########
flink-core/src/test/java/org/apache/flink/api/dag/TransformationTest.java:
##########
@@ -45,7 +47,25 @@ public class TransformationTest extends TestLogger {
@Before
public void setUp() {
- transformation = new TestTransformation<>("t", null, 1);
+ transformation = new TestTransformation<>("t", null, 1, null);
+ }
+
+ @Test
+ public void testPredecessorCache() throws Exception {
+ // diamond-like transformation:
+ // --> midNode-\
+ // ---/ --\
+ // --/ ->
+ // commonNode -----------------> topNode
+ Transformation<Void> commonNode = new TestTransformation<>("commonNode", null, 1, null);
+ Transformation<Void> midNode =
+ new TestTransformation<>("midNode", null, 1, Collections.singletonList(commonNode));
+ Transformation<Void> topNode =
+ new TestTransformation<>("topNode", null, 1, Arrays.asList(midNode, commonNode));
+
+ topNode.getTransitivePredecessors();
+ assertEquals(topNode.getPredecessorsCache().size(), 1);
Review Comment:
Flink is turning to JUnit5. According to the community guide[1], new tests should be written using JUnit5. If we have to modify an existing testing class, we should migrate it to JUnit5 first in a hotfix commit, for example, [#20350](https://github.com/apache/flink/pull/20350/commits).
[1] https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#tooling
##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/transformations/AbstractBroadcastStateTransformation.java:
##########
@@ -103,7 +103,7 @@ public void setChainingStrategy(ChainingStrategy chainingStrategy) {
}
@Override
- public List<Transformation<?>> getTransitivePredecessors() {
+ protected List<Transformation<?>> getTransitivePredecessorsInternal() {
Review Comment:
This method, and a few other methods like in TwoInputTransformation and UnionTransformation, need to be fixed too.
And it's better to introduce a test for each of them. Maybe we can introduce a separate test class `GetTransitivePredecessorsTest` to host them all.
##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/transformations/AbstractMultipleInputTransformation.java:
##########
@@ -76,10 +78,10 @@ public StreamOperatorFactory<OUT> getOperatorFactory() {
}
@Override
- public List<Transformation<?>> getTransitivePredecessors() {
Review Comment:
A simpler way can be
```
return inputs.stream()
.flatMap(input -> input.getTransitivePredecessors().stream())
.distinct();
.collect(Collectors.toList());
```
##########
flink-core/src/test/java/org/apache/flink/api/dag/TransformationTest.java:
##########
@@ -42,10 +43,21 @@
public class TransformationTest extends TestLogger {
private Transformation<Void> transformation;
+ private Transformation<Void> transformationWithInput;
@Before
public void setUp() {
transformation = new TestTransformation<>("t", null, 1);
+ transformationWithInput =
+ new TestTransformationWithInput<>(
+ "t", null, 1, Arrays.asList(transformation, transformation));
+ }
+
+ @Test
+ public void testPredecessorCache() throws Exception {
+ transformationWithInput.getTransitivePredecessors();
+ assertEquals(transformationWithInput.getPredecessorsCache().size(), 1);
+ assertEquals(((TestTransformation<?>) transformation).getNumGetTransitivePredecessor(), 1);
}
Review Comment:
Can we verify the result of `topNode.getTransitivePredecessors()`?
Ideally it should be 2. But without the fix it will be 3.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "jeyhunkarimov (via GitHub)" <gi...@apache.org>.
jeyhunkarimov commented on PR #24475:
URL: https://github.com/apache/flink/pull/24475#issuecomment-1987359390
Hi @zhuzhurk could you please review the PR in you available time? Thanks!
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #24475:
URL: https://github.com/apache/flink/pull/24475#discussion_r1524746682
##########
flink-core/src/test/java/org/apache/flink/api/dag/TransformationTest.java:
##########
@@ -125,19 +145,34 @@ public void testDeclareManagedMemorySlotScopeUseCaseFailWrongScope() {
/** A test implementation of {@link Transformation}. */
private static class TestTransformation<T> extends Transformation<T> {
-
- public TestTransformation(String name, TypeInformation<T> outputType, int parallelism) {
Review Comment:
It's better to introduce a `TestTwoInputTransformation` which inherits `TwoInputTransformation`.
Otherwise we are testing some testing logic instead of production logic.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-32513][core] Add predecessor caching [flink]
Posted by "jeyhunkarimov (via GitHub)" <gi...@apache.org>.
jeyhunkarimov commented on PR #24475:
URL: https://github.com/apache/flink/pull/24475#issuecomment-2002128082
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org