[ https://issues.apache.org/jira/browse/FLINK-9036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16407830#comment-16407830 ]
ASF GitHub Bot commented on FLINK-9036: --------------------------------------- GitHub user StephanEwen opened a pull request: https://github.com/apache/flink/pull/5735 [FLINK-9036] [core] Add default values to State Descriptors via suppliers **This PR is based on #5732 and only the last two commits are relevant for this PR** ## What is the purpose of the change Earlier versions had a default value in `ValueState`. We dropped that, because the value would have to be duplicated on each access, to be safe against side effects when using mutable types. This pull request re-adds the feature, but using a supplier/factory function to create the default value on access. This is more efficient than copying a shared default value on access. ## Brief change log - The `StateDescriptor` produces default values through a optional `Supplier` function. - For backwards compatibility, the mode to pass directly a value is kept. The value is wrapped in a `DefaultValueFactory` which implements the legacy functionality using a serializer to copy the value on each access. ## Verifying this change - This change adds a set of unit tests - The change modifies one example program (`StateMachineExample`). Running that example shows how the change works end-to-end. ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): (yes / no) - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no) - The serializers: (yes / no / don't know) - The runtime per-record code paths (performance sensitive): (yes / no / don't know) - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / no / don't know) - The S3 file system connector: (yes / no / don't know) ## Documentation - Does this pull request introduce a new feature? (yes / no) - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented) You can merge this pull request into a Git repository by running: $ git pull https://github.com/StephanEwen/incubator-flink state_default_values Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/5735.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #5735 ---- commit 1c756f0d6dfe71114a97a1b9effaf321b9da063b Author: Stephan Ewen <sewen@...> Date: 2018-03-20T14:29:12Z [hotfix] [core] Add missing serialVersionUID to MapStateDescriptor commit 186008c609635f99e4123912a632a4e068d3c532 Author: Stephan Ewen <sewen@...> Date: 2018-03-20T14:36:19Z [hotfix] [core] Demockitofy state descriptor tests commit 98666506c193feffb3952d9d424d3aa924f40318 Author: Stephan Ewen <sewen@...> Date: 2018-03-20T14:44:27Z [hotfix] [core] Make State Descriptors consistently use Preconditions instead of Objects. commit 1b286e4adbb5369df41c902bd161f5e854b862b8 Author: Stephan Ewen <sewen@...> Date: 2018-03-20T15:22:12Z [FLINK-9034] [core] StateDescriptor does not throw away TypeInformation upon serialization. Throwing away TypeInformation upon serialization was previously done because the type information was not serializable. Now that it is serializable, we can (and should) keep it to provide consistent user experience, where all serializers respect the ExecutionConfig. commit 6064b3d49d75d40ea69a65f5e38724bf9119b526 Author: Stephan Ewen <sewen@...> Date: 2018-03-20T15:46:13Z [hotfix] [core] Consilidate serializer duplication tests in StateDescriptorTest where possible commit a29b128f4f1bec49f1403aa21889e5890dc589ee Author: Stephan Ewen <sewen@...> Date: 2018-03-20T16:16:06Z [FLINK-9035] [core] Fix state descriptor equals() and hashCode() handling commit f19a4721acae62f8ba578c7cb235b6a917f3a258 Author: Stephan Ewen <sewen@...> Date: 2018-03-20T17:04:24Z [FLINK-9036] [core] Add default values to State Descriptors via suppliers commit 6d7757017f52f7c3fd7cbe99d05f1de63186d12d Author: Stephan Ewen <sewen@...> Date: 2018-03-20T18:51:02Z [FLINK-9036] [examples] Use state default value in StateMachineExample ---- > Add default value via suppliers > ------------------------------- > > Key: FLINK-9036 > URL: https://issues.apache.org/jira/browse/FLINK-9036 > Project: Flink > Issue Type: Improvement > Components: State Backends, Checkpointing > Reporter: Stephan Ewen > Assignee: Stephan Ewen > Priority: Major > Fix For: 1.6.0 > > > Earlier versions had a default value in {{ValueState}}. We dropped that, > because the value would have to be duplicated on each access, to be safe > against side effects when using mutable types. > For convenience, we should re-add the feature, but using a supplier/factory > function to create the default value on access. -- This message was sent by Atlassian JIRA (v7.6.3#76005)