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 2020/10/01 13:17:05 UTC

[GitHub] [flink] alpinegizmo commented on a change in pull request #13510: [FLINK-13095][state-processor-api] Introduce window bootstrap writer for writing window operator state

alpinegizmo commented on a change in pull request #13510:
URL: https://github.com/apache/flink/pull/13510#discussion_r498222828



##########
File path: docs/dev/libs/state_processor_api.md
##########
@@ -742,6 +740,56 @@ If a processing time timer is set but the state is not restored until after that
 
 <span class="label label-danger">Attention</span> If your bootstrap function creates timers, the state can only be restored using one of the [process]({{ site.baseurl }}/dev/stream/operators/process_function.html) type functions.
 
+### Window State
+
+The state processor api supports writing state for the [window operator]({{ site.baseurl }}/dev/stream/operators/windows.html).
+When writing window state, users specify the operator id, window assigner, evictor, optional trigger, and aggregation type.
+It is important the configurations on the bootstrap transformation match the configurations on the DataStream window.
+
+<div class="codetabs" markdown="1">
+<div data-lang="java" markdown="1">
+{% highlight java %}
+public class Account {
+    public int id;
+
+    public double amount;	
+
+    public long timestamp;
+}
+ 
+ExecutionEnvironment bEnv = ExecutionEnvironment.getExecutionEnvironment();
+
+DataSet<Account> accountDataSet = bEnv.fromCollection(accounts);
+
+BootstrapTransformation<Account> transformation = OperatorTransformation
+    .bootstrapWith(accountDataSet)
+    // When using event time windows, its important

Review comment:
       ```suggestion
       // When using event time windows, it is important
   ```

##########
File path: docs/dev/libs/state_processor_api.md
##########
@@ -742,6 +740,56 @@ If a processing time timer is set but the state is not restored until after that
 
 <span class="label label-danger">Attention</span> If your bootstrap function creates timers, the state can only be restored using one of the [process]({{ site.baseurl }}/dev/stream/operators/process_function.html) type functions.
 
+### Window State
+
+The state processor api supports writing state for the [window operator]({{ site.baseurl }}/dev/stream/operators/windows.html).
+When writing window state, users specify the operator id, window assigner, evictor, optional trigger, and aggregation type.
+It is important the configurations on the bootstrap transformation match the configurations on the DataStream window.
+
+<div class="codetabs" markdown="1">
+<div data-lang="java" markdown="1">
+{% highlight java %}
+public class Account {
+    public int id;
+
+    public double amount;	
+
+    public long timestamp;
+}
+ 
+ExecutionEnvironment bEnv = ExecutionEnvironment.getExecutionEnvironment();
+
+DataSet<Account> accountDataSet = bEnv.fromCollection(accounts);
+
+BootstrapTransformation<Account> transformation = OperatorTransformation
+    .bootstrapWith(accountDataSet)
+    // When using event time windows, its important
+    // to assign timestamps to each record.
+    .assignTimestamps(account -> account.timestamp)
+    .keyBy(acc -> acc.id)
+    .window(TumblingEventTimeWindows.of)
+    .reduce((left, right) -> left + right);
+{% endhighlight %}
+</div>
+<div data-lang="java" markdown="1">
+{% highlight scala %}
+case class Account(id: Int, amount: Double, timestamp: Long)
+ 
+val bEnv = ExecutionEnvironment.getExecutionEnvironment();
+val accountDataSet = bEnv.fromCollection(accounts);
+
+val transformation = OperatorTransformation
+    .bootstrapWith(accountDataSet)
+    // When using event time windows, its important
+    // to assign timestamps to each record.
+    .assignTimestamps(account -> account.timestamp)
+    .keyBy(acc -> acc.id)
+    .window(TumblingEventTimeWindows.of)
+    .reduce((left, right) -> left + right)

Review comment:
       This doesn't look like code that would actually compile.




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