[
https://issues.apache.org/jira/browse/FLINK-8345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16354025#comment-16354025
]
ASF GitHub Bot commented on FLINK-8345:
---------------------------------------
Github user aljoscha commented on a diff in the pull request:
https://github.com/apache/flink/pull/5230#discussion_r166337384
--- Diff:
flink-runtime/src/main/java/org/apache/flink/runtime/state/KeyedStateBackend.java
---
@@ -38,6 +38,37 @@
*/
void setCurrentKey(K newKey);
+ /**
+ * Returns a safe version of the current key (see {@link
#setCurrentKey(Object)}).
+ *
+ * <p>"Safe" means that the user can interact with it without
jeopardizing correctness.
+ * This implies that:
+ * <ol>
+ * <li>for the {@code MemoryStateBackend} and the {@code
FsStateBackend} we
+ * return a <b>copy</b> of the actual key, while
+ * <li>for the {@code RocksDBStateBackend} we return the key
itself, as returned
+ * by the backend.
+ * </ol>
+ *
+ * <p>The copy is created using the {@link TypeSerializer#copy(Object)
copy()} method
+ * of the key {@link TypeSerializer}. Consequently, the correctness of
the method assumes
+ * a correct {@code copy()} method.
+ *
+ */
+ K getCurrentKeySafe();
--- End diff --
I think we don't need this since the methods on broadcast state also don't
make sure that returned values are safe, i.e. if a user modifies the value they
break things. In the other parts we document in the Javadoc that users
shouldn't modify the value, I think we can go down the same route here, which
makes iteration over all keys cheaper.
> Iterate over keyed state on broadcast side of connect with broadcast.
> ---------------------------------------------------------------------
>
> Key: FLINK-8345
> URL: https://issues.apache.org/jira/browse/FLINK-8345
> Project: Flink
> Issue Type: New Feature
> Components: Streaming
> Affects Versions: 1.5.0
> Reporter: Kostas Kloudas
> Assignee: Kostas Kloudas
> Priority: Major
> Fix For: 1.5.0
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)