Vancior commented on code in PR #19743: URL: https://github.com/apache/flink/pull/19743#discussion_r877785593
########## 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: Since users already have `items()` interface, `keys()` and `values()` just making it more like `dict` in python, without not much extra code giving that the underlying state runtime implementation is actually map state too. -- 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-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org