use of org.apache.flink.cep.nfa.sharedbuffer.EventId in project flink by apache.
the class NFAStateSerializer method deserializeStartEvent.
private EventId deserializeStartEvent(DataInputView source) throws IOException {
byte isNull = source.readByte();
EventId startEventId = null;
if (isNull == 1) {
startEventId = eventIdSerializer.deserialize(source);
}
return startEventId;
}
use of org.apache.flink.cep.nfa.sharedbuffer.EventId in project flink by apache.
the class NFAStateSerializer method copyStartEvent.
private void copyStartEvent(DataInputView source, DataOutputView target) throws IOException {
byte isNull = source.readByte();
target.writeByte(isNull);
if (isNull == 1) {
EventId startEventId = eventIdSerializer.deserialize(source);
eventIdSerializer.serialize(startEventId, target);
}
}
use of org.apache.flink.cep.nfa.sharedbuffer.EventId in project flink by apache.
the class MigrationUtils method deserializeComputationStates.
static <T> Queue<ComputationState> deserializeComputationStates(org.apache.flink.cep.nfa.SharedBuffer<T> sharedBuffer, TypeSerializer<T> eventSerializer, DataInputView source) throws IOException {
Queue<ComputationState> computationStates = new LinkedList<>();
StringSerializer stateNameSerializer = StringSerializer.INSTANCE;
LongSerializer timestampSerializer = LongSerializer.INSTANCE;
DeweyNumber.DeweyNumberSerializer versionSerializer = DeweyNumber.DeweyNumberSerializer.INSTANCE;
int computationStateNo = source.readInt();
for (int i = 0; i < computationStateNo; i++) {
String state = stateNameSerializer.deserialize(source);
String prevState = stateNameSerializer.deserialize(source);
long timestamp = timestampSerializer.deserialize(source);
DeweyNumber version = versionSerializer.deserialize(source);
long startTimestamp = timestampSerializer.deserialize(source);
int counter = source.readInt();
T event = null;
if (source.readBoolean()) {
event = eventSerializer.deserialize(source);
}
NodeId nodeId;
EventId startEventId;
if (prevState != null) {
nodeId = sharedBuffer.getNodeId(prevState, timestamp, counter, event);
startEventId = sharedBuffer.getStartEventId(version.getRun());
} else {
nodeId = null;
startEventId = null;
}
computationStates.add(ComputationState.createState(state, nodeId, version, startTimestamp, startEventId));
}
return computationStates;
}
use of org.apache.flink.cep.nfa.sharedbuffer.EventId in project flink by apache.
the class NFAStateSerializer method deserializeSingleComputationState.
private ComputationState deserializeSingleComputationState(DataInputView source) throws IOException {
String stateName = StringValue.readString(source);
NodeId prevState = nodeIdSerializer.deserialize(source);
DeweyNumber version = versionSerializer.deserialize(source);
long startTimestamp = source.readLong();
EventId startEventId = deserializeStartEvent(source);
return ComputationState.createState(stateName, prevState, version, startTimestamp, startEventId);
}
use of org.apache.flink.cep.nfa.sharedbuffer.EventId in project flink by apache.
the class AfterMatchSkipStrategy method prune.
/**
* Prunes matches/partial matches based on the chosen strategy.
*
* @param matchesToPrune current partial matches
* @param matchedResult already completed matches
* @param sharedBufferAccessor accessor to corresponding shared buffer
* @throws Exception thrown if could not access the state
*/
public void prune(Collection<ComputationState> matchesToPrune, Collection<Map<String, List<EventId>>> matchedResult, SharedBufferAccessor<?> sharedBufferAccessor) throws Exception {
EventId pruningId = getPruningId(matchedResult);
if (pruningId != null) {
List<ComputationState> discardStates = new ArrayList<>();
for (ComputationState computationState : matchesToPrune) {
if (computationState.getStartEventID() != null && shouldPrune(computationState.getStartEventID(), pruningId)) {
sharedBufferAccessor.releaseNode(computationState.getPreviousBufferEntry(), computationState.getVersion());
discardStates.add(computationState);
}
}
matchesToPrune.removeAll(discardStates);
}
}
Aggregations