Github user danielblazevski commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2368#discussion_r76102678
  
    --- Diff: docs/apis/streaming/windows.md ---
    @@ -459,42 +459,106 @@ ready for processing. This allows to get the benefit 
of incremental window compu
     the additional meta information that writing a `WindowFunction` provides.
     
     This is an example that shows how incremental aggregation functions can be 
combined with
    -a `WindowFunction`.
    +a `WindowFunction`.  The `FoldFunction`/`WindowFunction` example shows how 
to extract the
    +ending event-time of a window of sensor readings that contain a timestamp, 
    +and the `ReduceFunction`/`WindowFunctions` example shows how to do eager 
window
    +aggregation (only a single element is kept in the window).
     
     <div class="codetabs" markdown="1">
     <div data-lang="java" markdown="1">
     {% highlight java %}
    -DataStream<Tuple2<String, Long>> input = ...;
    +DataStream<SensorReading> input = ...;
     
     // for folding incremental computation
     input
         .keyBy(<key selector>)
         .window(<window assigner>)
    -    .apply(<initial value>, new MyFoldFunction(), new MyWindowFunction());
    +    .apply(Long.MIN_VALUE, new MyFoldFunction(), new MyWindowFunction());
    +
    +/* ... */
    +
    +private static  class myFoldFunction implements 
FoldFunction<SensorReading, Long> {
    +
    +    public Long fold(Long acc, SensorReading s) {
    +        return Math.max(acc, s.timestamp());
    +    }
    +}
    +
    +private static class MyWindowFunction implements WindowFunction<Long, 
Long, String, TimeWindow> {
    +
    +    public void apply(String key, TimeWindow window, Iterable<Long> 
timestamps, Collector<Long> out) {
    +            out.collect(timestamps.iterator().next());
    --- End diff --
    
    Made the changes in the Java version and added the comments.  Had some 
issues with the Scala version.  See screenshots, the only change is really to 
change to the type of `Iterable` in the `WindowFunction`, which IntelliJ was 
saying has to have type `SensorReadng`, which is not ideal.  I removed the 
Scala version for now.  
    
    <img width="426" alt="screenshot 2016-08-24 13 28 12" 
src="https://cloud.githubusercontent.com/assets/10012612/17940967/4a025738-69ff-11e6-9354-31c2ead563d4.png";>
    
    <img width="625" alt="screenshot 2016-08-24 13 27 51" 
src="https://cloud.githubusercontent.com/assets/10012612/17940972/4dd5db28-69ff-11e6-8c6a-11b1900796ad.png";>
      


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