/** * Clear all state in {@code address} in all windows under merge (even result windows) in {@code * context}. */ public static <K, StateT extends State, W extends BoundedWindow> void clear( MergingStateAccessor<K, W> context, StateTag<StateT> address) { for (StateT state : context.accessInEachMergingWindow(address).values()) { state.clear(); } }
@Override public void clearForWindow(W window) { for (Map.Entry<String, DoFnSignature.StateDeclaration> entry : signature.stateDeclarations().entrySet()) { try { StateSpec<?> spec = (StateSpec<?>) entry.getValue().field().get(fn); State state = stateInternals.state( StateNamespaces.window(windowCoder, window), StateTags.tagForSpec(entry.getKey(), (StateSpec) spec)); state.clear(); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } } }