/** * Extracts all the sequences of events from the start to the given computation state. An event * sequence is returned as a map which contains the events and the names of the states to which * the events were mapped. * * @param sharedBufferAccessor The accessor to {@link SharedBuffer} from which to extract the matches * @param computationState The end computation state of the extracted event sequences * @return Collection of event sequences which end in the given computation state * @throws Exception Thrown if the system cannot access the state. */ private Map<String, List<EventId>> extractCurrentMatches( final SharedBufferAccessor<T> sharedBufferAccessor, final ComputationState computationState) throws Exception { if (computationState.getPreviousBufferEntry() == null) { return new HashMap<>(); } List<Map<String, List<EventId>>> paths = sharedBufferAccessor.extractPatterns( computationState.getPreviousBufferEntry(), computationState.getVersion()); if (paths.isEmpty()) { return new HashMap<>(); } // for a given computation state, we cannot have more than one matching patterns. Preconditions.checkState(paths.size() == 1); return paths.get(0); }
nfaState.getCompletedMatches().poll(); List<Map<String, List<EventId>>> matchedResult = sharedBufferAccessor.extractPatterns(earliestMatch.getPreviousBufferEntry(), earliestMatch.getVersion());
sharedBufferAccessor.extractPatterns( match.getPreviousBufferEntry(), match.getVersion()).get(0) );
private void serializeSingleComputationState( ComputationState computationState, DataOutputView target) throws IOException { StringValue.writeString(computationState.getCurrentStateName(), target); nodeIdSerializer.serialize(computationState.getPreviousBufferEntry(), target); versionSerializer.serialize(computationState.getVersion(), target); target.writeLong(computationState.getStartTimestamp()); serializeStartEvent(computationState.getStartEventID(), target); }
outgoingEdges.getTotalIgnoreBranches(), outgoingEdges.getTotalTakeBranches()); version = computationState.getVersion().increase(toIncrease); } else { version = computationState.getVersion() .increase(totalTakeToSkip + ignoreBranchesToVisit) .addStage(); final DeweyNumber currentVersion = computationState.getVersion().increase(takeBranchesToVisit); final DeweyNumber nextVersion = new DeweyNumber(currentVersion).addStage(); takeBranchesToVisit--; outgoingEdges.getTotalTakeBranches()); DeweyNumber startVersion = computationState.getVersion().increase(totalBranches); ComputationState startState = ComputationState.createStartState(computationState.getCurrentStateName(), startVersion); resultingComputationStates.add(startState);
/** * Extracts all the sequences of events from the start to the given computation state. An event * sequence is returned as a map which contains the events and the names of the states to which * the events were mapped. * * @param sharedBufferAccessor The accessor to {@link SharedBuffer} from which to extract the matches * @param computationState The end computation state of the extracted event sequences * @return Collection of event sequences which end in the given computation state * @throws Exception Thrown if the system cannot access the state. */ private Map<String, List<EventId>> extractCurrentMatches( final SharedBufferAccessor<T> sharedBufferAccessor, final ComputationState computationState) throws Exception { if (computationState.getPreviousBufferEntry() == null) { return new HashMap<>(); } List<Map<String, List<EventId>>> paths = sharedBufferAccessor.extractPatterns( computationState.getPreviousBufferEntry(), computationState.getVersion()); if (paths.isEmpty()) { return new HashMap<>(); } // for a given computation state, we cannot have more than one matching patterns. Preconditions.checkState(paths.size() == 1); return paths.get(0); }
/** * Extracts all the sequences of events from the start to the given computation state. An event * sequence is returned as a map which contains the events and the names of the states to which * the events were mapped. * * @param sharedBufferAccessor The accessor to {@link SharedBuffer} from which to extract the matches * @param computationState The end computation state of the extracted event sequences * @return Collection of event sequences which end in the given computation state * @throws Exception Thrown if the system cannot access the state. */ private Map<String, List<EventId>> extractCurrentMatches( final SharedBufferAccessor<T> sharedBufferAccessor, final ComputationState computationState) throws Exception { if (computationState.getPreviousBufferEntry() == null) { return new HashMap<>(); } List<Map<String, List<EventId>>> paths = sharedBufferAccessor.extractPatterns( computationState.getPreviousBufferEntry(), computationState.getVersion()); if (paths.isEmpty()) { return new HashMap<>(); } // for a given computation state, we cannot have more than one matching patterns. Preconditions.checkState(paths.size() == 1); return paths.get(0); }
computationState.getTimestamp(), computationState.getCounter(), computationState.getVersion());
0, readState.getTimestamp(), readState.getVersion(), readState.getStartTimestamp() ));
nfaState.getCompletedMatches().poll(); List<Map<String, List<EventId>>> matchedResult = sharedBufferAccessor.extractPatterns(earliestMatch.getPreviousBufferEntry(), earliestMatch.getVersion());
nfaState.getCompletedMatches().poll(); List<Map<String, List<EventId>>> matchedResult = sharedBufferAccessor.extractPatterns(earliestMatch.getPreviousBufferEntry(), earliestMatch.getVersion());
sharedBufferAccessor.extractPatterns( match.getPreviousBufferEntry(), match.getVersion()).get(0) );
sharedBufferAccessor.extractPatterns( match.getPreviousBufferEntry(), match.getVersion()).get(0) );
private void serializeComputationStates(Queue<ComputationState> states, DataOutputView target) throws IOException { target.writeInt(states.size()); for (ComputationState computationState : states) { STATE_NAME_SERIALIZER.serialize(computationState.getCurrentStateName(), target); NODE_ID_SERIALIZER.serialize(computationState.getPreviousBufferEntry(), target); VERSION_SERIALIZER.serialize(computationState.getVersion(), target); TIMESTAMP_SERIALIZER.serialize(computationState.getStartTimestamp(), target); if (computationState.getStartEventID() != null) { target.writeByte(1); EVENT_ID_SERIALIZER.serialize(computationState.getStartEventID(), target); } else { target.writeByte(0); } } }
private void serializeComputationStates(Queue<ComputationState> states, DataOutputView target) throws IOException { target.writeInt(states.size()); for (ComputationState computationState : states) { STATE_NAME_SERIALIZER.serialize(computationState.getCurrentStateName(), target); NODE_ID_SERIALIZER.serialize(computationState.getPreviousBufferEntry(), target); VERSION_SERIALIZER.serialize(computationState.getVersion(), target); TIMESTAMP_SERIALIZER.serialize(computationState.getStartTimestamp(), target); if (computationState.getStartEventID() != null) { target.writeByte(1); EVENT_ID_SERIALIZER.serialize(computationState.getStartEventID(), target); } else { target.writeByte(0); } } }
outgoingEdges.getTotalIgnoreBranches(), outgoingEdges.getTotalTakeBranches()); version = computationState.getVersion().increase(toIncrease); } else { version = computationState.getVersion() .increase(totalTakeToSkip + ignoreBranchesToVisit) .addStage(); final DeweyNumber currentVersion = computationState.getVersion().increase(takeBranchesToVisit); final DeweyNumber nextVersion = new DeweyNumber(currentVersion).addStage(); takeBranchesToVisit--; outgoingEdges.getTotalTakeBranches()); DeweyNumber startVersion = computationState.getVersion().increase(totalBranches); ComputationState startState = ComputationState.createStartState(computationState.getCurrentStateName(), startVersion); resultingComputationStates.add(startState);
outgoingEdges.getTotalIgnoreBranches(), outgoingEdges.getTotalTakeBranches()); version = computationState.getVersion().increase(toIncrease); } else { version = computationState.getVersion() .increase(totalTakeToSkip + ignoreBranchesToVisit) .addStage(); final DeweyNumber currentVersion = computationState.getVersion().increase(takeBranchesToVisit); final DeweyNumber nextVersion = new DeweyNumber(currentVersion).addStage(); takeBranchesToVisit--; outgoingEdges.getTotalTakeBranches()); DeweyNumber startVersion = computationState.getVersion().increase(totalBranches); ComputationState startState = ComputationState.createStartState(computationState.getCurrentStateName(), startVersion); resultingComputationStates.add(startState);
@Override public void serialize(NFA<T> record, DataOutputView target) throws IOException { serializeStates(record.states, target); target.writeLong(record.windowTime); target.writeBoolean(record.handleTimeout); sharedBufferSerializer.serialize(record.eventSharedBuffer, target); target.writeInt(record.computationStates.size()); StringSerializer stateNameSerializer = StringSerializer.INSTANCE; LongSerializer timestampSerializer = LongSerializer.INSTANCE; DeweyNumber.DeweyNumberSerializer versionSerializer = new DeweyNumber.DeweyNumberSerializer(); for (ComputationState<T> computationState: record.computationStates) { stateNameSerializer.serialize(computationState.getState().getName(), target); stateNameSerializer.serialize(computationState.getPreviousState() == null ? null : computationState.getPreviousState().getName(), target); timestampSerializer.serialize(computationState.getTimestamp(), target); versionSerializer.serialize(computationState.getVersion(), target); timestampSerializer.serialize(computationState.getStartTimestamp(), target); target.writeInt(computationState.getCounter()); if (computationState.getEvent() == null) { target.writeBoolean(false); } else { target.writeBoolean(true); eventSerializer.serialize(computationState.getEvent(), target); } } }
outgoingEdges.getTotalIgnoreBranches(), outgoingEdges.getTotalTakeBranches()); version = computationState.getVersion().increase(toIncrease); } else { version = computationState.getVersion() .increase(totalTakeToSkip + ignoreBranchesToVisit) .addStage(); final DeweyNumber currentVersion = computationState.getVersion().increase(takeBranchesToVisit); final DeweyNumber nextVersion = new DeweyNumber(currentVersion).addStage(); takeBranchesToVisit--; outgoingEdges.getTotalTakeBranches()); DeweyNumber startVersion = computationState.getVersion().increase(totalBranches); ComputationState<T> startState = ComputationState.createStartState(this, computationState.getState(), startVersion); resultingComputationStates.add(startState);