W window() { return context.window(); }
Collection<W> mergingWindows() { return activeWindows.readStateAddresses(context.window()); }
public StateAccessorImpl( ActiveWindowSet<W> activeWindows, Coder<W> windowCoder, StateInternals stateInternals, StateContext<W> context, StateStyle style) { this.activeWindows = activeWindows; this.windowCoder = windowCoder; this.stateInternals = stateInternals; this.context = checkNotNull(context); this.windowNamespace = namespaceFor(context.window()); this.style = style; }
@Override public <StateT extends State> StateT access(StateTag<StateT> address) { switch (style) { case DIRECT: return stateInternals.state(windowNamespace(), address, context); case RENAMED: return stateInternals.state( namespaceFor(activeWindows.writeStateAddress(context.window())), address, context); } throw new RuntimeException(); // cases are exhaustive. } }
@Override public <StateT extends State> StateT access(StateTag<StateT> address) { switch (style) { case DIRECT: return stateInternals.state(windowNamespace(), address, context); case RENAMED: return stateInternals.state( namespaceFor( activeWindows.mergedWriteStateAddress(activeToBeMerged, context.window())), address, context); } throw new RuntimeException(); // cases are exhaustive. }
@Override public <StateT extends State> Map<W, StateT> accessInEachMergingWindow( StateTag<StateT> address) { ImmutableMap.Builder<W, StateT> builder = ImmutableMap.builder(); for (W stateAddressWindow : activeWindows.readStateAddresses(context.window())) { StateT stateForWindow = stateInternals.state(namespaceFor(stateAddressWindow), address, context); builder.put(stateAddressWindow, stateForWindow); } return builder.build(); } }