You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "RainerMatthiasS (via GitHub)" <gi...@apache.org> on 2023/08/28 06:27:45 UTC
[GitHub] [flink] RainerMatthiasS commented on a diff in pull request #23239: [FLINK-26585][state-processor-api] replace implementation of MultiStateKeyIterator with Stream-free implementation
RainerMatthiasS commented on code in PR #23239:
URL: https://github.com/apache/flink/pull/23239#discussion_r1306963160
##########
flink-libraries/flink-state-processing-api/src/main/java/org/apache/flink/state/api/input/MultiStateKeyIterator.java:
##########
@@ -31,65 +31,82 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.stream.Stream;
/**
* An iterator for reading all keys in a state backend across multiple partitioned states.
*
* <p>To read unique keys across all partitioned states callers must invoke {@link
* MultiStateKeyIterator#remove}.
*
+ * <p>Note: This is a replacement of the original implementation which used streams with a known
+ * flaw in the {@link Stream#flatMap(java.util.function.Function)} implementation that lead to
+ * completely enumerating and buffering nested iterators event for a single call to {@link
+ * MultiStateKeyIterator#hasNext}.
+ *
+ * @see <a
+ * href="https://bugs.openjdk.org/browse/JDK-8267359">https://bugs.openjdk.org/browse/JDK-8267359</a>
* @param <K> Type of the key by which state is keyed.
*/
@Internal
-public final class MultiStateKeyIterator<K> implements CloseableIterator<K> {
Review Comment:
Good morning
[JDK-8267359](https://bugs.openjdk.org/browse/JDK-8267359) leads to inadequate/unnecessary use of computer memory up to OOM errors when reading state sets with many keys ... the manual implementation of the nested iterator prevents this known java streams problem.
--
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