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

    https://github.com/apache/flink/pull/4634#discussion_r136845008
  
    --- Diff: docs/dev/stream/operators/windows.md ---
    @@ -490,15 +490,35 @@ public abstract class ProcessWindowFunction<IN, OUT, 
KEY, W extends Window> impl
                 Iterable<IN> elements,
                 Collector<OUT> out) throws Exception;
     
    -    /**
    -     * The context holding window metadata
    -     */
    -    public abstract class Context {
    -        /**
    -         * @return The window that is being evaluated.
    -         */
    -        public abstract W window();
    -    }
    +           /**
    +            * The context holding window metadata.
    +            */
    +           public abstract class Context implements java.io.Serializable {
    +               /**
    +                * Returns the window that is being evaluated.
    +                */
    +               public abstract W window();
    +   
    +               /** Returns the current processing time. */
    +               public abstract long currentProcessingTime();
    +   
    +               /** Returns the current event-time watermark. */
    +               public abstract long currentWatermark();
    +   
    +               /**
    +                * State accessor for per-key and per-window state.
    +                *
    +                * <p><b>NOTE:</b>If you use per-window state you have to 
ensure that you clean it up
    +                * by implementing {@link 
ProcessWindowFunction#clear(Context)}.
    +                */
    +               public abstract KeyedStateStore windowState();
    +   
    +               /**
    +                * State accessor for per-key global state.
    +                */
    +               public abstract KeyedStateStore globalState();
    +           }
    --- End diff --
    
    The difference between per-key per-window state and per-key global state 
deserves more explanation. It would be even better to sketch out scenarios of 
what one might do with these accessors. There's a fair bit of power being 
exposed here, and that's not at all obvious.


---

Reply via email to