You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beam.apache.org by Kenneth Knowles <ke...@apache.org> on 2019/08/01 01:34:32 UTC

Re: [Java] Accessing state from FinishBundle method

Because @FinishBundle is not executed in the context of a window, what
state would you be accessing? (analogous to the way that outputs from
finish bundle must have an explicit window specified)

It may make sense to have a separate method @FinishBundleForWindow (or some
better name) that can be called for each window that was present in a
bundle. This would easily allow use of state without having to invent new
APIs.

Kenn

On Mon, Jul 29, 2019 at 12:53 PM Pablo Estrada <pa...@google.com> wrote:

> Hello all,
> I am working on a pipeline where I'd like to write a value to state at the
> end of processing a bundle. As it turns out, I don't think this is
> possible, as FinishBundleContext does not provide a method for it; and
> doing something like so also errors out:
>
> ======
>          @FinishBundle
>           public void finishBundle(
>               FinishBundleContext c,
>               @StateId("myState") MapState<String, MyClass> myState) {
>
>              myState.put(this.myClassVarKey, this.myClassVarValue);
>           }
> ======
>
> Maybe this is not yet implemented, and remains to be? Or maybe there's
> some other way of doing it? Or maybe this is an antipattern? (though I
> doubt that last one).
> Thanks!
> -P.
>