Codota Logo
NFACompiler$NFAFactoryCompiler
Code IndexAdd Codota to your IDE (free)

How to use
NFACompiler$NFAFactoryCompiler
in
org.apache.flink.cep.nfa.compiler

Best Java code snippets using org.apache.flink.cep.nfa.compiler.NFACompiler$NFAFactoryCompiler (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: apache/flink

NFAFactoryCompiler<?> compiler = new NFAFactoryCompiler<>(checkNotNull(pattern));
compiler.compileFactory();
State<?> startState = compiler.getStates().stream().filter(State::isStart).findFirst().orElseThrow(
  () -> new IllegalStateException("Compiler produced no start state. It is a bug. File a jira."));
origin: apache/flink

private State<T> createLooping(final State<T> sinkState) {
  if (currentPattern instanceof GroupPattern) {
    return createLoopingGroupPatternState((GroupPattern) currentPattern, sinkState);
  final IterativeCondition<T> ignoreCondition = extendWithUntilCondition(
    getInnerIgnoreCondition(currentPattern),
    untilCondition,
    false);
  final IterativeCondition<T> takeCondition = extendWithUntilCondition(
    getTakeCondition(currentPattern),
    untilCondition,
    true);
  IterativeCondition<T> proceedCondition = getTrueFunction();
  final State<T> loopingState = createState(currentPattern.getName(), State.StateType.Normal);
      State<T> sinkStateCopy = copy(sinkState);
      loopingState.addProceed(sinkStateCopy, new RichAndCondition<>(proceedCondition, untilCondition));
      originalStateMap.put(sinkState.getName(), sinkStateCopy);
        ? new RichAndCondition<>(proceedCondition, new RichNotCondition<>(untilCondition))
        : proceedCondition);
    updateWithGreedyCondition(sinkState, getTakeCondition(currentPattern));
  } else {
    loopingState.addProceed(sinkState, proceedCondition);
  addStopStateToLooping(loopingState);
    final State<T> ignoreState = createState(currentPattern.getName(), State.StateType.Normal);
origin: apache/flink

final boolean isOptional) {
if (currentPattern instanceof GroupPattern) {
  return createGroupPatternState((GroupPattern) currentPattern, sinkState, proceedState, isOptional);
final State<T> singletonState = createState(currentPattern.getName(), State.StateType.Normal);
final State<T> sink = copyWithoutTransitiveNots(sinkState);
singletonState.addTake(sink, takeCondition);
final IterativeCondition<T> proceedCondition = getTrueFunction();
if (isOptional && !headOfGroup(currentPattern)) {
  if (currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY)) {
    final IterativeCondition<T> untilCondition =
  final State<T> ignoreState;
  if (isOptional) {
    ignoreState = createState(currentPattern.getName(), State.StateType.Normal);
    ignoreState.addTake(sink, takeCondition);
    ignoreState.addIgnore(ignoreCondition);
    addStopStates(ignoreState);
  } else {
    ignoreState = singletonState;
origin: apache/flink

/**
 * Creates the Start {@link State} of the resulting NFA graph.
 *
 * @param sinkState the state that Start state should point to (always first state of middle states)
 * @return created state
 */
@SuppressWarnings("unchecked")
private State<T> createStartState(State<T> sinkState) {
  final State<T> beginningState = convertPattern(sinkState);
  beginningState.makeStart();
  return beginningState;
}
origin: org.apache.flink/flink-cep_2.11

private State<T> convertPattern(final State<T> sinkState) {
  final State<T> lastSink;
  final Quantifier quantifier = currentPattern.getQuantifier();
  if (quantifier.hasProperty(Quantifier.QuantifierProperty.LOOPING)) {
    // if loop has started then all notPatterns previous to the optional states are no longer valid
    setCurrentGroupPatternFirstOfLoop(false);
    final State<T> sink = copyWithoutTransitiveNots(sinkState);
    final State<T> looping = createLooping(sink);
    setCurrentGroupPatternFirstOfLoop(true);
    lastSink = createTimesState(looping, sinkState, currentPattern.getTimes());
  } else if (quantifier.hasProperty(Quantifier.QuantifierProperty.TIMES)) {
    lastSink = createTimesState(sinkState, sinkState, currentPattern.getTimes());
  } else {
    lastSink = createSingletonState(sinkState);
  }
  addStopStates(lastSink);
  return lastSink;
}
origin: org.apache.flink/flink-cep_2.11

/**
 * Compiles the given pattern into a {@link NFAFactory}. The NFA factory can be used to create
 * multiple NFAs.
 *
 * @param pattern Definition of sequence pattern
 * @param timeoutHandling True if the NFA shall return timed out event patterns
 * @param <T> Type of the input events
 * @return Factory for NFAs corresponding to the given pattern
 */
@SuppressWarnings("unchecked")
public static <T> NFAFactory<T> compileFactory(
  final Pattern<T, ?> pattern,
  boolean timeoutHandling) {
  if (pattern == null) {
    // return a factory for empty NFAs
    return new NFAFactoryImpl<>(0, Collections.<State<T>>emptyList(), timeoutHandling);
  } else {
    final NFAFactoryCompiler<T> nfaFactoryCompiler = new NFAFactoryCompiler<>(pattern);
    nfaFactoryCompiler.compileFactory();
    return new NFAFactoryImpl<>(nfaFactoryCompiler.getWindowTime(), nfaFactoryCompiler.getStates(), timeoutHandling);
  }
}
origin: org.apache.flink/flink-cep_2.10

private State<T> convertPattern(final State<T> sinkState) {
  final State<T> lastSink;
  final Quantifier quantifier = currentPattern.getQuantifier();
  if (quantifier.hasProperty(Quantifier.QuantifierProperty.LOOPING)) {
    // if loop has started then all notPatterns previous to the optional states are no longer valid
    final State<T> sink = copyWithoutTransitiveNots(sinkState);
    final State<T> looping = createLooping(sink);
    if (!quantifier.hasProperty(Quantifier.QuantifierProperty.OPTIONAL)) {
      lastSink = createInitMandatoryStateOfOneOrMore(looping);
    } else {
      lastSink = createInitOptionalStateOfZeroOrMore(looping, sinkState);
    }
  } else if (quantifier.hasProperty(Quantifier.QuantifierProperty.TIMES)) {
    lastSink = createTimesState(sinkState, currentPattern.getTimes());
  } else {
    lastSink = createSingletonState(sinkState);
  }
  addStopStates(lastSink);
  return lastSink;
}
origin: org.apache.flink/flink-cep

/**
 * Compiles the given pattern into a {@link NFAFactory}. The NFA factory can be used to create
 * multiple NFAs.
 */
void compileFactory() {
  if (currentPattern.getQuantifier().getConsumingStrategy() == Quantifier.ConsumingStrategy.NOT_FOLLOW) {
    throw new MalformedPatternException("NotFollowedBy is not supported as a last part of a Pattern!");
  }
  checkPatternNameUniqueness();
  checkPatternSkipStrategy();
  // we're traversing the pattern from the end to the beginning --> the first state is the final state
  State<T> sinkState = createEndingState();
  // add all the normal states
  sinkState = createMiddleStates(sinkState);
  // add the beginning state
  createStartState(sinkState);
}
origin: org.apache.flink/flink-cep

/**
 * Compiles the given pattern into a {@link NFAFactory}. The NFA factory can be used to create
 * multiple NFAs.
 *
 * @param pattern Definition of sequence pattern
 * @param timeoutHandling True if the NFA shall return timed out event patterns
 * @param <T> Type of the input events
 * @return Factory for NFAs corresponding to the given pattern
 */
@SuppressWarnings("unchecked")
public static <T> NFAFactory<T> compileFactory(
  final Pattern<T, ?> pattern,
  boolean timeoutHandling) {
  if (pattern == null) {
    // return a factory for empty NFAs
    return new NFAFactoryImpl<>(0, Collections.<State<T>>emptyList(), timeoutHandling);
  } else {
    final NFAFactoryCompiler<T> nfaFactoryCompiler = new NFAFactoryCompiler<>(pattern);
    nfaFactoryCompiler.compileFactory();
    return new NFAFactoryImpl<>(nfaFactoryCompiler.getWindowTime(), nfaFactoryCompiler.getStates(), timeoutHandling);
  }
}
origin: org.apache.flink/flink-cep

/**
 * Create the states for the group pattern as a looping one.
 *
 * @param groupPattern the group pattern to create the states for
 * @param sinkState the state that the group pattern being converted should point to
 * @return the first state of the states of the group pattern
 */
private State<T> createLoopingGroupPatternState(
  final GroupPattern<T, ?> groupPattern,
  final State<T> sinkState) {
  final IterativeCondition<T> proceedCondition = getTrueFunction();
  Pattern<T, ?> oldCurrentPattern = currentPattern;
  Pattern<T, ?> oldFollowingPattern = followingPattern;
  GroupPattern<T, ?> oldGroupPattern = currentGroupPattern;
  final State<T> dummyState = createState(currentPattern.getName(), State.StateType.Normal);
  State<T> lastSink = dummyState;
  currentGroupPattern = groupPattern;
  currentPattern = groupPattern.getRawPattern();
  lastSink = createMiddleStates(lastSink);
  lastSink = convertPattern(lastSink);
  lastSink.addProceed(sinkState, proceedCondition);
  dummyState.addProceed(lastSink, proceedCondition);
  currentPattern = oldCurrentPattern;
  followingPattern = oldFollowingPattern;
  currentGroupPattern = oldGroupPattern;
  return lastSink;
}
origin: org.apache.flink/flink-cep_2.11

/**
 * Create the states for the group pattern as a looping one.
 *
 * @param groupPattern the group pattern to create the states for
 * @param sinkState the state that the group pattern being converted should point to
 * @return the first state of the states of the group pattern
 */
private State<T> createLoopingGroupPatternState(
  final GroupPattern<T, ?> groupPattern,
  final State<T> sinkState) {
  final IterativeCondition<T> proceedCondition = getTrueFunction();
  Pattern<T, ?> oldCurrentPattern = currentPattern;
  Pattern<T, ?> oldFollowingPattern = followingPattern;
  GroupPattern<T, ?> oldGroupPattern = currentGroupPattern;
  final State<T> dummyState = createState(currentPattern.getName(), State.StateType.Normal);
  State<T> lastSink = dummyState;
  currentGroupPattern = groupPattern;
  currentPattern = groupPattern.getRawPattern();
  lastSink = createMiddleStates(lastSink);
  lastSink = convertPattern(lastSink);
  lastSink.addProceed(sinkState, proceedCondition);
  dummyState.addProceed(lastSink, proceedCondition);
  currentPattern = oldCurrentPattern;
  followingPattern = oldFollowingPattern;
  currentGroupPattern = oldGroupPattern;
  return lastSink;
}
origin: org.apache.flink/flink-cep_2.10

/**
 * Compiles the given pattern into a {@link NFAFactory}. The NFA factory can be used to create
 * multiple NFAs.
 *
 * @param pattern Definition of sequence pattern
 * @param inputTypeSerializer Serializer for the input type
 * @param timeoutHandling True if the NFA shall return timed out event patterns
 * @param <T> Type of the input events
 * @return Factory for NFAs corresponding to the given pattern
 */
@SuppressWarnings("unchecked")
public static <T> NFAFactory<T> compileFactory(
  final Pattern<T, ?> pattern,
  final TypeSerializer<T> inputTypeSerializer,
  boolean timeoutHandling) {
  if (pattern == null) {
    // return a factory for empty NFAs
    return new NFAFactoryImpl<>(inputTypeSerializer, 0, Collections.<State<T>>emptyList(), timeoutHandling);
  } else {
    final NFAFactoryCompiler<T> nfaFactoryCompiler = new NFAFactoryCompiler<>(pattern);
    nfaFactoryCompiler.compileFactory();
    return new NFAFactoryImpl<>(inputTypeSerializer, nfaFactoryCompiler.getWindowTime(), nfaFactoryCompiler.getStates(), timeoutHandling);
  }
}
origin: org.apache.flink/flink-cep_2.10

State<T> lastSink = copyWithoutTransitiveNots(sinkState);
for (int i = 0; i < times - 1; i++) {
  lastSink = createSingletonState(lastSink, getInnerIgnoreCondition(currentPattern), false);
  addStopStateToLooping(lastSink);
final IterativeCondition<T> ignoreCondition = getIgnoreCondition(currentPattern);
  return createSingletonState(lastSink, ignoreCondition, false);
final State<T> singletonState = createState(currentPattern.getName(), State.StateType.Normal);
singletonState.addTake(lastSink, currentCondition);
singletonState.addProceed(sinkState, BooleanConditions.<T>trueFunction());
  State<T> ignoreState = createState(currentPattern.getName(), State.StateType.Normal);
  ignoreState.addTake(lastSink, currentCondition);
  ignoreState.addIgnore(ignoreCondition);
  singletonState.addIgnore(ignoreState, ignoreCondition);
  addStopStates(ignoreState);
origin: org.apache.flink/flink-cep

private State<T> convertPattern(final State<T> sinkState) {
  final State<T> lastSink;
  final Quantifier quantifier = currentPattern.getQuantifier();
  if (quantifier.hasProperty(Quantifier.QuantifierProperty.LOOPING)) {
    // if loop has started then all notPatterns previous to the optional states are no longer valid
    setCurrentGroupPatternFirstOfLoop(false);
    final State<T> sink = copyWithoutTransitiveNots(sinkState);
    final State<T> looping = createLooping(sink);
    setCurrentGroupPatternFirstOfLoop(true);
    lastSink = createTimesState(looping, sinkState, currentPattern.getTimes());
  } else if (quantifier.hasProperty(Quantifier.QuantifierProperty.TIMES)) {
    lastSink = createTimesState(sinkState, sinkState, currentPattern.getTimes());
  } else {
    lastSink = createSingletonState(sinkState);
  }
  addStopStates(lastSink);
  return lastSink;
}
origin: org.apache.flink/flink-cep_2.10

/**
 * Creates the given state as a looping one. Looping state is one with TAKE edge to itself and
 * PROCEED edge to the sinkState. It also consists of a similar state without the PROCEED edge, so that
 * for each PROCEED transition branches in computation state graph  can be created only once.
 *
 * @param sinkState the state that the converted state should point to
 * @return the first state of the created complex state
 */
@SuppressWarnings("unchecked")
private State<T> createLooping(final State<T> sinkState) {
  final IterativeCondition<T> currentCondition = (IterativeCondition<T>) currentPattern.getCondition();
  final IterativeCondition<T> ignoreCondition = getInnerIgnoreCondition(currentPattern);
  final IterativeCondition<T> trueFunction = BooleanConditions.trueFunction();
  final State<T> loopingState = createState(currentPattern.getName(), State.StateType.Normal);
  loopingState.addProceed(sinkState, trueFunction);
  loopingState.addTake(currentCondition);
  addStopStateToLooping(loopingState);
  if (ignoreCondition != null) {
    final State<T> ignoreState = createState(currentPattern.getName(), State.StateType.Normal);
    ignoreState.addTake(loopingState, currentCondition);
    ignoreState.addIgnore(ignoreCondition);
    loopingState.addIgnore(ignoreState, ignoreCondition);
    addStopStateToLooping(ignoreState);
  }
  return loopingState;
}
origin: org.apache.flink/flink-cep_2.10

/**
 * Compiles the given pattern into a {@link NFAFactory}. The NFA factory can be used to create
 * multiple NFAs.
 */
void compileFactory() {
  if (currentPattern.getQuantifier().getConsumingStrategy() == Quantifier.ConsumingStrategy.NOT_FOLLOW) {
    throw new MalformedPatternException("NotFollowedBy is not supported as a last part of a Pattern!");
  }
  // we're traversing the pattern from the end to the beginning --> the first state is the final state
  State<T> sinkState = createEndingState();
  // add all the normal states
  sinkState = createMiddleStates(sinkState);
  // add the beginning state
  createStartState(sinkState);
}
origin: org.apache.flink/flink-cep

final State<T> proceedState,
final boolean isOptional) {
final IterativeCondition<T> proceedCondition = getTrueFunction();
currentGroupPattern = groupPattern;
currentPattern = groupPattern.getRawPattern();
lastSink = createMiddleStates(lastSink);
lastSink = convertPattern(lastSink);
if (isOptional) {
origin: org.apache.flink/flink-cep_2.11

/**
 * Compiles the given pattern into a {@link NFAFactory}. The NFA factory can be used to create
 * multiple NFAs.
 */
void compileFactory() {
  if (currentPattern.getQuantifier().getConsumingStrategy() == Quantifier.ConsumingStrategy.NOT_FOLLOW) {
    throw new MalformedPatternException("NotFollowedBy is not supported as a last part of a Pattern!");
  }
  checkPatternNameUniqueness();
  checkPatternSkipStrategy();
  // we're traversing the pattern from the end to the beginning --> the first state is the final state
  State<T> sinkState = createEndingState();
  // add all the normal states
  sinkState = createMiddleStates(sinkState);
  // add the beginning state
  createStartState(sinkState);
}
origin: org.apache.flink/flink-cep_2.10

final IterativeCondition<T> trueFunction = BooleanConditions.trueFunction();
final State<T> singletonState = createState(currentPattern.getName(), State.StateType.Normal);
final State<T> sink = copyWithoutTransitiveNots(sinkState);
singletonState.addTake(sink, currentCondition);
  final State<T> ignoreState;
  if (isOptional) {
    ignoreState = createState(currentPattern.getName(), State.StateType.Normal);
    ignoreState.addTake(sink, currentCondition);
    ignoreState.addIgnore(ignoreCondition);
    addStopStates(ignoreState);
  } else {
    ignoreState = singletonState;
origin: org.apache.flink/flink-cep_2.10

/**
 * Creates the Start {@link State} of the resulting NFA graph.
 *
 * @param sinkState the state that Start state should point to (always first state of middle states)
 * @return created state
 */
@SuppressWarnings("unchecked")
private State<T> createStartState(State<T> sinkState) {
  stateNameHandler.checkNameUniqueness(currentPattern.getName());
  final State<T> beginningState = convertPattern(sinkState);
  beginningState.makeStart();
  return beginningState;
}
org.apache.flink.cep.nfa.compilerNFACompiler$NFAFactoryCompiler

Javadoc

Converts a Pattern into graph of State. It enables sharing of compilation state across methods.

Most used methods

  • <init>
  • compileFactory
    Compiles the given pattern into a NFAFactory. The NFA factory can be used to create multiple NFAs.
  • getStates
  • addStopStateToLooping
  • addStopStates
  • convertPattern
  • copyWithoutTransitiveNots
    This method creates an alternative state that is target for TAKE transition from an optional State.
  • createEndingState
    Creates the dummy Final State of the NFA graph.
  • createLooping
    Creates the given state as a looping one. Looping state is one with TAKE edge to itself and PROCEED
  • createMiddleStates
    Creates all the states between Start and Final state.
  • createSingletonState
    Creates a simple single state. For an OPTIONAL state it also consists of a similar state without the
  • createStartState
    Creates the Start State of the resulting NFA graph.
  • createSingletonState,
  • createStartState,
  • createState,
  • createStopState,
  • createTimesState,
  • getCurrentNotCondition,
  • getIgnoreCondition,
  • getInnerIgnoreCondition,
  • getWindowTime,
  • checkPatternNameUniqueness

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • orElseThrow (Optional)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JButton (javax.swing)
  • JTable (javax.swing)
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now