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 2021/03/10 03:19:02 UTC

[GitHub] [flink] HuangXingBo opened a new pull request #15130: [FLINK-21632][python] Add NamespacedStateView and PerWindowStateDataViewStore

HuangXingBo opened a new pull request #15130:
URL: https://github.com/apache/flink/pull/15130


   ## What is the purpose of the change
   
   *This pull request will add `NamespacedStateView` and `PerWindowStateDataViewStore`*
   
   
   ## Brief change log
   
     - *add `NamespacedStateView` and `PerWindowStateDataViewStore`*
     - *Add keyedDataView and NamespaceDataView*
   
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - *Original tests*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable)
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #15130: [FLINK-21632][python] Add NamespacedStateView and PerWindowStateDataViewStore

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15130:
URL: https://github.com/apache/flink/pull/15130#issuecomment-794821417


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1355c454f84507fcc4aaa0e56529a397d86f47ae",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14373",
       "triggerID" : "1355c454f84507fcc4aaa0e56529a397d86f47ae",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1355c454f84507fcc4aaa0e56529a397d86f47ae Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14373) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #15130: [FLINK-21632][python] Add NamespacedStateView and PerWindowStateDataViewStore

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #15130:
URL: https://github.com/apache/flink/pull/15130#issuecomment-794821417


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1355c454f84507fcc4aaa0e56529a397d86f47ae",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "1355c454f84507fcc4aaa0e56529a397d86f47ae",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1355c454f84507fcc4aaa0e56529a397d86f47ae UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #15130: [FLINK-21632][python] Add NamespacedStateView and PerWindowStateDataViewStore

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #15130:
URL: https://github.com/apache/flink/pull/15130#issuecomment-794805686


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit 1355c454f84507fcc4aaa0e56529a397d86f47ae (Wed Mar 10 03:24:13 UTC 2021)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] WeiZhong94 commented on a change in pull request #15130: [FLINK-21632][python] Add NamespacedStateView and PerWindowStateDataViewStore

Posted by GitBox <gi...@apache.org>.
WeiZhong94 commented on a change in pull request #15130:
URL: https://github.com/apache/flink/pull/15130#discussion_r592109738



##########
File path: flink-python/pyflink/fn_execution/state_data_view.py
##########
@@ -99,9 +114,35 @@ def __hash__(self) -> int:
         return hash([i for i in self.get()])
 
 
-class StateMapView(MapView):
+class KeyedStateListView(StateListView[N]):
+    """
+    KeyedStateListView is an default implementation of StateListView whose underlying

Review comment:
       an -> a

##########
File path: flink-python/pyflink/fn_execution/state_data_view.py
##########
@@ -136,6 +177,32 @@ def clear(self) -> None:
         return self._map_state.clear()
 
 
+class KeyedStateMapView(StateMapView[N]):
+    """
+    KeyedStateMapView is an default implementation of StateMapView whose underlying

Review comment:
       an -> a

##########
File path: flink-python/pyflink/fn_execution/state_data_view.py
##########
@@ -173,9 +239,65 @@ def __init__(self,
     def get_runtime_context(self):
         return self._function_context
 
+    @abstractmethod
+    def get_state_list_view(self, state_name, element_coder):
+        """
+        Creates a state list view.
+
+        :param state_name: The name of underlying state of the list view

Review comment:
       add a period at the end of the sentence.

##########
File path: flink-python/pyflink/fn_execution/state_data_view.py
##########
@@ -99,9 +114,35 @@ def __hash__(self) -> int:
         return hash([i for i in self.get()])
 
 
-class StateMapView(MapView):
+class KeyedStateListView(StateListView[N]):
+    """
+    KeyedStateListView is an default implementation of StateListView whose underlying
+    representation is a keyed state.
+    """
 
-    def __init__(self, map_state: MapState):
+    def __init__(self, list_state: ListState):
+        super(KeyedStateListView, self).__init__(list_state)
+
+    def set_current_namespace(self, namespace: N):
+        raise Exception("KeyedStateListView doesn't support set_current_namespace")
+
+
+class NamespacedStateListView(StateListView[N]):
+    """
+    NamespacedStateListView is an StateListView whose underlying representation is a keyed and

Review comment:
       an -> a

##########
File path: flink-python/pyflink/fn_execution/state_data_view.py
##########
@@ -99,9 +114,35 @@ def __hash__(self) -> int:
         return hash([i for i in self.get()])
 
 
-class StateMapView(MapView):
+class KeyedStateListView(StateListView[N]):
+    """
+    KeyedStateListView is an default implementation of StateListView whose underlying
+    representation is a keyed state.
+    """
 
-    def __init__(self, map_state: MapState):
+    def __init__(self, list_state: ListState):
+        super(KeyedStateListView, self).__init__(list_state)
+
+    def set_current_namespace(self, namespace: N):
+        raise Exception("KeyedStateListView doesn't support set_current_namespace")
+
+
+class NamespacedStateListView(StateListView[N]):
+    """
+    NamespacedStateListView is an StateListView whose underlying representation is a keyed and
+    namespaced state. It also support to change current namespace.

Review comment:
       It also supports changing current namespace.

##########
File path: flink-python/pyflink/fn_execution/state_data_view.py
##########
@@ -173,9 +239,65 @@ def __init__(self,
     def get_runtime_context(self):
         return self._function_context
 
+    @abstractmethod
+    def get_state_list_view(self, state_name, element_coder):
+        """
+        Creates a state list view.
+
+        :param state_name: The name of underlying state of the list view
+        :param element_coder: The element coder
+        :return: a keyed list state
+        """
+        pass
+
+    @abstractmethod
+    def get_state_map_view(self, state_name, key_coder, value_coder):
+        """
+        Creates a state map view.
+
+        :param state_name: The name of underlying state of the map view
+        :param key_coder: The key coder
+        :param value_coder: The value coder
+        :return: a keyed map state
+        """
+        pass
+
+
+class PerKeyStateDataViewStore(StateDataViewStore):
+    """
+    Default implementation of StateDataViewStore.
+    """
+
+    def __init__(self,
+                 function_context: FunctionContext,
+                 keyed_state_backend: RemoteKeyedStateBackend):
+        super(PerKeyStateDataViewStore, self).__init__(function_context, keyed_state_backend)
+
+    def get_state_list_view(self, state_name, element_coder):
+        return KeyedStateListView(
+            self._keyed_state_backend.get_list_state(state_name, element_coder))
+
+    def get_state_map_view(self, state_name, key_coder, value_coder):
+        return KeyedStateMapView(
+            self._keyed_state_backend.get_map_state(state_name, key_coder, value_coder))
+
+
+class PerWindowStateDataViewStore(StateDataViewStore):
+    """
+    An implementation of StateDataViewStore for window aggregates which forwards the state
+    registration to an underlying RemoteKeyedStateBackend. The created state by this store has the

Review comment:
       The state created by this store

##########
File path: flink-python/pyflink/fn_execution/state_data_view.py
##########
@@ -136,6 +177,32 @@ def clear(self) -> None:
         return self._map_state.clear()
 
 
+class KeyedStateMapView(StateMapView[N]):
+    """
+    KeyedStateMapView is an default implementation of StateMapView whose underlying
+    representation is a keyed state.
+    """
+
+    def __init__(self, map_state: MapState):
+        super(KeyedStateMapView, self).__init__(map_state)
+
+    def set_current_namespace(self, namespace: N):
+        raise Exception("KeyedStateMapView doesn't support set_current_namespace")
+
+
+class NamespacedStateMapView(StateMapView[N]):
+    """
+    NamespacedStateMapView is an StateMapView whose underlying representation is a keyed and

Review comment:
       an -> a

##########
File path: flink-python/pyflink/fn_execution/state_data_view.py
##########
@@ -136,6 +177,32 @@ def clear(self) -> None:
         return self._map_state.clear()
 
 
+class KeyedStateMapView(StateMapView[N]):
+    """
+    KeyedStateMapView is an default implementation of StateMapView whose underlying
+    representation is a keyed state.
+    """
+
+    def __init__(self, map_state: MapState):
+        super(KeyedStateMapView, self).__init__(map_state)
+
+    def set_current_namespace(self, namespace: N):
+        raise Exception("KeyedStateMapView doesn't support set_current_namespace")
+
+
+class NamespacedStateMapView(StateMapView[N]):
+    """
+    NamespacedStateMapView is an StateMapView whose underlying representation is a keyed and
+    namespaced state. It also support to change current namespace.

Review comment:
       It also supports changing current namespace.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #15130: [FLINK-21632][python] Add NamespacedStateView and PerWindowStateDataViewStore

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15130:
URL: https://github.com/apache/flink/pull/15130#issuecomment-794821417


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1355c454f84507fcc4aaa0e56529a397d86f47ae",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14373",
       "triggerID" : "1355c454f84507fcc4aaa0e56529a397d86f47ae",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1355c454f84507fcc4aaa0e56529a397d86f47ae Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14373) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] HuangXingBo closed pull request #15130: [FLINK-21632][python] Add NamespacedStateView and PerWindowStateDataViewStore

Posted by GitBox <gi...@apache.org>.
HuangXingBo closed pull request #15130:
URL: https://github.com/apache/flink/pull/15130


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org