/** * Identical to {@link #bag()}, but with an element coder explicitly supplied. * * <p>If automatic coder inference fails, use this method. */ public static <T> StateSpec<BagState<T>> bag(Coder<T> elemCoder) { return new BagStateSpec<>(elemCoder); }
/** * Create a {@link StateSpec} for a {@link SetState}, optimized for checking membership. * * <p>This method attempts to infer the element coder automatically. * * @see #set(Coder) */ public static <T> StateSpec<SetState<T>> set() { return new SetStateSpec<>(null); }
@Override public ResultT dispatchSet(Coder<?> elementCoder) { return dispatchDefault(); } }
StatefulPredicateCheck( Coder<T> coder, SerializableFunction<T, String> formatter, SerializableFunction<Set<T>, Boolean> successPredicate) { this.seenEvents = StateSpecs.bag(coder); this.formatter = formatter; this.successPredicate = successPredicate; }
@Override public PaneInfo read() { PaneInfo previousPane = previousPaneFuture.read(); return describePane(key, windowMaxTimestamp, previousPane, isFinal); } };
public DoFn<String, String> newInnerAnonymousDoFnWithTimers() { return new DoFn<String, String>() { @TimerId(TIMER_ID) private final TimerSpec myTimer = TimerSpecs.timer(TimeDomain.PROCESSING_TIME); @OnTimer(TIMER_ID) public void onTimer(BoundedWindow w) {} @ProcessElement public void process(ProcessContext c) {} }; }
/** * Create a {@link StateSpec} for a {@link SetState}, optimized for key lookups and writes. * * <p>This method attempts to infer the key and value coders automatically. * * @see #map(Coder, Coder) */ public static <K, V> StateSpec<MapState<K, V>> map() { return new MapStateSpec<>(null, null); }
private static <InputT, AccumT, OutputT> StateSpec<CombiningState<InputT, AccumT, OutputT>> combiningInternal( Coder<AccumT> accumCoder, CombineFnWithContext<InputT, AccumT, OutputT> combineFn) { return new CombiningWithContextStateSpec<>(accumCoder, combineFn); }
@Override public <ResultT> ResultT match(Cases<ResultT> cases) { return cases.dispatchSet(elemCoder); }
@Override public <T> T sideInput(PCollectionView<T> view) { return c.sideInput(view); } };
/** * Create a {@link StateSpec} for a single value of type {@code T}. * * <p>This method attempts to infer the accumulator coder automatically. * * @see #value(Coder) */ public static <T> StateSpec<ValueState<T>> value() { return new ValueStateSpec<>(null); }
@Override public ValueState<T> bind(String id, StateBinder visitor) { return visitor.bindValue(id, this, coder); }
@Override public <ResultT> ResultT match(Cases<ResultT> cases) { return cases.dispatchBag(elemCoder); }
@Override public SetState<T> bind(String id, StateBinder visitor) { return visitor.bindSet(id, this, elemCoder); }
@Override public ResultT dispatchValue(Coder<?> valueCoder) { return dispatchDefault(); }
private StateSpec<BagState<AccumT>> asBagSpec() { return new BagStateSpec<>(accumCoder); } }
/** * Identical to {@link #set()}, but with an element coder explicitly supplied. * * <p>If automatic coder inference fails, use this method. */ public static <T> StateSpec<SetState<T>> set(Coder<T> elemCoder) { return new SetStateSpec<>(elemCoder); }
/** * Identical to {@link #map()}, but with key and value coders explicitly supplied. * * <p>If automatic coder inference fails, use this method. */ public static <K, V> StateSpec<MapState<K, V>> map(Coder<K> keyCoder, Coder<V> valueCoder) { return new MapStateSpec<>(keyCoder, valueCoder); }
@Override public ResultT dispatchBag(Coder<?> elementCoder) { return dispatchDefault(); }