@Override public Tuple4<Integer, Long, Integer, String> map(Tuple3<Integer, Long, String> value) throws IOException { // update counter Integer counterValue = counter.value(); if (counterValue == null) { counterValue = 0; } counter.update(counterValue + 1); // save last value Long lastValue = last.value(); if (lastValue == null) { lastValue = initialValue; } last.update(value.f1); return Tuple4.of(value.f0, value.f1 - lastValue, counterValue, value.f2); } }
.map(x -> Tuple4.of("0-0", 0L, 1, x.f0)) .returns(Types.TUPLE(Types.STRING, Types.LONG, Types.INT, Types.STRING))
@Override public void run(SourceContext<Tuple4<Integer, String, Double, Long>> ctx) throws Exception { while (isRunning) { long timestamp = initialTimestamp + 1000 * number.get(); ctx.collectWithTimestamp(Tuple4.of(number.get(), "test_tuple", random.nextDouble(), timestamp), timestamp); if (number.incrementAndGet() >= this.count) { cancel(); } } }
Tuple4.of(restoreStateMetaInfoSnapshot.getKeySerializer(), UnloadableDummyTypeSerializer.class, restoreStateMetaInfoSnapshot.getKeySerializerConfigSnapshot(), newKeySerializer), Tuple4.of(restoreStateMetaInfoSnapshot.getValueSerializer(), UnloadableDummyTypeSerializer.class, restoreStateMetaInfoSnapshot.getValueSerializerConfigSnapshot(), newValueSerializer), Tuple4.of(restoreStateMetaInfoSnapshot.getNamespaceSerializer(), null, restoreStateMetaInfoSnapshot.getNamespaceSerializerConfigSnapshot(),
public static RegisteredStateMetaInfo resolveStateCompatibility( StateMetaInfoSnapshot restoreStateMetaInfoSnapshot, KeyedStateDescriptor newKeyedStateDescriptor) throws StateMigrationException { if (!VoidNamespaceSerializer.INSTANCE.equals(restoreStateMetaInfoSnapshot.getNamespaceSerializer())) { throw new IllegalStateException("Expected Keyed state's meta info snapshot."); } Preconditions.checkState( Objects.equals(newKeyedStateDescriptor.getName(), restoreStateMetaInfoSnapshot.getName()), "Incompatible state names. " + "Was [" + restoreStateMetaInfoSnapshot.getName() + "], " + "registered with [" + newKeyedStateDescriptor.getName() + "]."); TypeSerializer newKeySerializer = newKeyedStateDescriptor.getKeySerializer(); TypeSerializer newValueSerializer = newKeyedStateDescriptor.getValueSerializer(); checkRequireMigration(Arrays.asList( Tuple4.of(restoreStateMetaInfoSnapshot.getKeySerializer(), UnloadableDummyTypeSerializer.class, restoreStateMetaInfoSnapshot.getKeySerializerConfigSnapshot(), newKeySerializer), Tuple4.of(restoreStateMetaInfoSnapshot.getValueSerializer(), UnloadableDummyTypeSerializer.class, restoreStateMetaInfoSnapshot.getValueSerializerConfigSnapshot(), newValueSerializer))); return new RegisteredStateMetaInfo( newKeyedStateDescriptor.getStateType(), newKeyedStateDescriptor.getName(), newKeySerializer, newValueSerializer); }