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 2022/05/20 06:18:17 UTC

[GitHub] [flink] Vancior commented on a diff in pull request #19743: [FLINK-27657][python] Implement remote operator state backend in PyFlink

Vancior commented on code in PR #19743:
URL: https://github.com/apache/flink/pull/19743#discussion_r877770129


##########
flink-python/pyflink/datastream/state.py:
##########
@@ -281,6 +283,110 @@ def __iter__(self) -> Iterator[K]:
         return iter(self.keys())
 
 
+class ReadOnlyBroadcastState(State, Generic[K, V]):
+    """
+    A read-only view of the :class:`BroadcastState`.
+    Although read-only, the user code should not modify the value returned by the :meth:`get` or the
+    items returned by :meth:`items`, as this can lead to inconsistent states. The reason for this is
+    that we do not create extra copies of the elements for performance reasons.
+    """
+
+    @abstractmethod
+    def get(self, key: K) -> V:
+        """
+        Returns the current value associated with the given key.
+        """
+        pass
+
+    @abstractmethod
+    def contains(self, key: K) -> bool:
+        """
+        Returns whether there exists the given mapping.
+        """
+        pass
+
+    @abstractmethod
+    def items(self) -> Iterable[Tuple[K, V]]:
+        """
+        Returns all the mappings in the state.
+        """
+        pass
+
+    @abstractmethod
+    def keys(self) -> Iterable[K]:

Review Comment:
   We don't have the exactly same interfaces for `MapState`, which might be more intuitive for python users, so I just align `BroadcastState` with `MapState`.



-- 
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