use of org.apache.flink.migration.streaming.runtime.streamrecord.MultiplexingStreamRecordSerializer in project flink by apache.
the class AbstractKeyedCEPPatternOperator method restoreState.
////////////////////// Backwards Compatibility //////////////////////
@Override
public void restoreState(FSDataInputStream in) throws Exception {
// this is the flag indicating if we have udf
// state to restore (not needed here)
in.read();
DataInputViewStreamWrapper inputView = new DataInputViewStreamWrapper(in);
InternalWatermarkCallbackService<KEY> watermarkCallbackService = getInternalWatermarkCallbackService();
if (migratingFromOldKeyedOperator) {
int numberEntries = inputView.readInt();
for (int i = 0; i < numberEntries; i++) {
watermarkCallbackService.registerKeyForWatermarkCallback(keySerializer.deserialize(inputView));
}
} else {
final ObjectInputStream ois = new ObjectInputStream(in);
// retrieve the NFA
@SuppressWarnings("unchecked") NFA<IN> nfa = (NFA<IN>) ois.readObject();
// retrieve the elements that were pending in the priority queue
MultiplexingStreamRecordSerializer<IN> recordSerializer = new MultiplexingStreamRecordSerializer<>(inputSerializer);
PriorityQueue<StreamRecord<IN>> priorityQueue = priorityQueueFactory.createPriorityQueue();
int entries = ois.readInt();
for (int i = 0; i < entries; i++) {
StreamElement streamElement = recordSerializer.deserialize(inputView);
priorityQueue.offer(streamElement.<IN>asRecord());
}
// finally register the retrieved state with the new keyed state.
setCurrentKey((byte) 0);
nfaOperatorState.update(nfa);
priorityQueueOperatorState.update(priorityQueue);
if (!isProcessingTime) {
// this is relevant only for event/ingestion time
// need to work around type restrictions
InternalWatermarkCallbackService rawWatermarkCallbackService = (InternalWatermarkCallbackService) watermarkCallbackService;
rawWatermarkCallbackService.registerKeyForWatermarkCallback((byte) 0);
}
ois.close();
}
}
Aggregations