You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by al...@apache.org on 2017/02/06 16:29:45 UTC

flink git commit: [FLINK-5721] Add FoldingState to State Documentation

Repository: flink
Updated Branches:
  refs/heads/master 2d270d4a2 -> 588d7c62c


[FLINK-5721] Add FoldingState to State Documentation


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/588d7c62
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/588d7c62
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/588d7c62

Branch: refs/heads/master
Commit: 588d7c62c0c60c83c894d26702d4563567c5e743
Parents: 2d270d4
Author: Aljoscha Krettek <al...@gmail.com>
Authored: Mon Feb 6 14:51:17 2017 +0100
Committer: Aljoscha Krettek <al...@gmail.com>
Committed: Mon Feb 6 17:29:18 2017 +0100

----------------------------------------------------------------------
 docs/dev/stream/state.md | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/588d7c62/docs/dev/stream/state.md
----------------------------------------------------------------------
diff --git a/docs/dev/stream/state.md b/docs/dev/stream/state.md
index 4d1cfab..2472226 100644
--- a/docs/dev/stream/state.md
+++ b/docs/dev/stream/state.md
@@ -113,9 +113,18 @@ be retrieved using `Iterable<T> get()`.
 added to the state. The interface is the same as for `ListState` but elements added using
 `add(T)` are reduced to an aggregate using a specified `ReduceFunction`.
 
+* `FoldingState<T, ACC>`: This keeps a single value that represents the aggregation of all values
+added to the state. Contrary to `ReducingState`, the aggregate type may be different from the type
+of elements that are added to the state. The interface is the same as for `ListState` but elements
+added using `add(T)` are folded into an aggregate using a specified `FoldFunction`.
+
 All types of state also have a method `clear()` that clears the state for the currently
 active key, i.e. the key of the input element.
 
+<span class="label label-danger">Attention</span> `FoldingState` will be deprecated in one of
+the next versions of Flink and will be completely removed in the future. A more general
+alternative will be provided.
+
 It is important to keep in mind that these state objects are only used for interfacing
 with state. The state is not necessarily stored inside but might reside on disk or somewhere else.
 The second thing to keep in mind is that the value you get from the state
@@ -126,8 +135,8 @@ To get a state handle, you have to create a `StateDescriptor`. This holds the na
 (as we will see later, you can create several states, and they have to have unique names so
 that you can reference them), the type of the values that the state holds, and possibly
 a user-specified function, such as a `ReduceFunction`. Depending on what type of state you
-want to retrieve, you create either a `ValueStateDescriptor`, a `ListStateDescriptor` or
-a `ReducingStateDescriptor`.
+want to retrieve, you create either a `ValueStateDescriptor`, a `ListStateDescriptor`,
+a `ReducingStateDescriptor` or a `FoldingStateDescriptor`.
 
 State is accessed using the `RuntimeContext`, so it is only possible in *rich functions*.
 Please see [here]({{ site.baseurl }}/dev/api_concepts#rich-functions) for
@@ -137,6 +146,7 @@ is available in a `RichFunction` has these methods for accessing state:
 * `ValueState<T> getState(ValueStateDescriptor<T>)`
 * `ReducingState<T> getReducingState(ReducingStateDescriptor<T>)`
 * `ListState<T> getListState(ListStateDescriptor<T>)`
+* `FoldingState<T, ACC> getFoldingState(FoldingStateDescriptor<T, ACC>)`
 
 This is an example `FlatMapFunction` that shows how all of the parts fit together: