Github user aljoscha commented on the pull request:

    https://github.com/apache/flink/pull/2051#issuecomment-222648249
  
    Hi,
    just some high-level remarks about the API of `KeyedStream` and 
`QueryableStateStream`. You could parameterize them both by the State type. 
This way you would also get a very nice way of generically accessing the 
different types of state on the query side. Let me quickly show what I mean. 
`KeyedStream` would have this method:
    
    ```
    <S extends State> QueryableStateStream<KEY, S> asQueryableState(
        String queryableStateName,
        StateDescriptor<S, ?> stateDescriptor);
    ```
    
    the signature of `QueryableStateStream` would be like this:
    
    ```
    public class QueryableStateStream<K, S extends State> {
        private StateDescriptor<S, ?> stateDescriptor;
        
        /**
         * Read the state represented by this stream using a state client
         */ 
        public S read(K key, QueryableStateClient client) {
            return stateDescriptor.bind(new QueryStateBinder(client.read(key, 
stateName)));
        }
    }
    ```
    
    The nice thing about `StateDescriptor.bind()` is that you can use this to 
create a state reader based on the state type. You pass in a custom 
`StateBackend` (this should really be called `StateBinder`, btw). That 
constructs a state reader that deserializes the bytes read from the state 
client.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to