StatefulPredicateCheck( Coder<T> coder, SerializableFunction<T, String> formatter, SerializableFunction<Set<T>, Boolean> successPredicate) { this.seenEvents = StateSpecs.bag(coder); this.formatter = formatter; this.successPredicate = successPredicate; }
GroupIntoBatchesDoFn( long batchSize, Duration allowedLateness, Coder<K> inputKeyCoder, Coder<InputT> inputValueCoder) { this.batchSize = batchSize; this.allowedLateness = allowedLateness; this.batchSpec = StateSpecs.bag(inputValueCoder); this.numElementsInBatchSpec = StateSpecs.combining( new Combine.BinaryCombineLongFn() { @Override public long identity() { return 0L; } @Override public long apply(long left, long right) { return left + right; } }); this.keySpec = StateSpecs.value(inputKeyCoder); // prefetch every 20% of batchSize elements. Do not prefetch if batchSize is too little this.prefetchFrequency = ((batchSize / 5) <= 1) ? Long.MAX_VALUE : (batchSize / 5); }
/** * Create a state tag that is optimized for adding values frequently, and occasionally retrieving * all the values that have been added. */ public static <T> StateTag<BagState<T>> bag(String id, Coder<T> elemCoder) { return new SimpleStateTag<>(new StructuredId(id), StateSpecs.bag(elemCoder)); }
ExactlyOnceWriter(Write<K, V> spec, Coder<KV<K, V>> elemCoder) { this.spec = spec; this.outOfOrderBufferSpec = StateSpecs.bag(KvCoder.of(BigEndianLongCoder.of(), TimestampedValueCoder.of(elemCoder))); }
ExactlyOnceWriter(Write<K, V> spec, Coder<KV<K, V>> elemCoder) { this.spec = spec; this.outOfOrderBufferSpec = StateSpecs.bag(KvCoder.of(BigEndianLongCoder.of(), TimestampedValueCoder.of(elemCoder))); }
return StateSpecs.value(components.getCoder(stateSpec.getValueSpec().getCoderId())); case BAG_SPEC: return StateSpecs.bag(components.getCoder(stateSpec.getBagSpec().getElementCoderId())); case COMBINING_SPEC: FunctionSpec combineFnSpec = stateSpec.getCombiningSpec().getCombineFn().getSpec();
@Parameters(name = "{index}: {0}") public static Iterable<StateSpec<?>> stateSpecs() { return ImmutableList.of( StateSpecs.value(VarIntCoder.of()), StateSpecs.bag(VarIntCoder.of()), StateSpecs.set(VarIntCoder.of()), StateSpecs.map(StringUtf8Coder.of(), VarIntCoder.of())); }
private final StateSpec<BagState<MyInteger>> bufferState = StateSpecs.bag();
StateSpecs.bag(VarIntCoder.of());
StateSpecs.bag(VarIntCoder.of());
private final StateSpec<BagState<MyInteger>> bufferState = StateSpecs.bag();