Repository: flink Updated Branches: refs/heads/master fcc1efcb0 -> 8e1775afc
[FLINK-5876] [docs] Mention Scala extensions in queryable state docs Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/8e1775af Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/8e1775af Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/8e1775af Branch: refs/heads/master Commit: 8e1775afc39a525fce334c71af0eafaeb1d882e1 Parents: fcc1efc Author: Ufuk Celebi <[email protected]> Authored: Wed Feb 22 13:45:27 2017 +0100 Committer: Ufuk Celebi <[email protected]> Committed: Wed Feb 22 13:45:27 2017 +0100 ---------------------------------------------------------------------- docs/dev/stream/queryable_state.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/8e1775af/docs/dev/stream/queryable_state.md ---------------------------------------------------------------------- diff --git a/docs/dev/stream/queryable_state.md b/docs/dev/stream/queryable_state.md index 4a63856..62d6a33 100644 --- a/docs/dev/stream/queryable_state.md +++ b/docs/dev/stream/queryable_state.md @@ -37,14 +37,14 @@ Flink. For some scenarios, queryable state thus eliminates the need for distribu operations/transactions with external systems such as key-value stores which are often the bottleneck in practice. -<div class="alert alert-danger"> +<div class="alert alert-warning"> <strong>Attention:</strong> Queryable state accesses keyed state from a concurrent thread rather than synchronizing with the operator and potentially blocking its operation. Since any state - backend using Java heap space, e.g. <code>MemoryStateBackend</code> or - <code>FsStateBackend</code>, does not work with copies when retrieving values but instead directly + backend using Java heap space, e.g. MemoryStateBackend or + FsStateBackend, does not work with copies when retrieving values but instead directly references the stored values, read-modify-write patterns are unsafe and may cause the queryable state server to fail due to concurrent modifications. - The <code>RocksDBStateBackend</code> is safe from these issues. + The RocksDBStateBackend is safe from these issues. </div> ## Making State Queryable @@ -167,7 +167,7 @@ about any class loading issues etc. There are some serialization utils for key/namespace and value serialization included in `KvStateRequestSerializer`. -## Example +### Example The following example extends the `CountWindowAverage` example (see [Using Managed Keyed State]({{ site.baseurl }}/dev/stream/state.html#using-managed-keyed-state)) @@ -233,6 +233,22 @@ Tuple2<Long, Long> value = KvStateRequestSerializer.deserializeValue(serializedValue, valueSerializer); {% endhighlight %} +### Note for Scala Users + +Please use the available Scala extensions when creating the `TypeSerializer` instances. Add the following import: + +```scala +import org.apache.flink.streaming.api.scala._ +``` + +Now you can create the type serializers as follows: + +```scala +val keySerializer = createTypeInformation[Long] + .createSerializer(new ExecutionConfig) +``` + +If you don't do this, you can run into mismatches between the serializers used in the Flink job and in your client code, because types like `scala.Long` cannot be caputured at runtime. ## Configuration
