[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-05-09 Thread mushketyk
Github user mushketyk closed the pull request at:

https://github.com/apache/flink/pull/2361


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97789351
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/State.java ---
@@ -43,7 +43,14 @@ public State(final String name, final StateType 
stateType) {
this.name = name;
this.stateType = stateType;
 
-   stateTransitions = new ArrayList();
+   stateTransitions = new ArrayList<>();
+   }
+
+   public State(String name, StateType stateType, 
Collection stateTransitions) {
--- End diff --

I agree with @chermenin and this class can be reverted to its previous 
state. In general, PRs should have the smallest diff possible in order to be 
easier to review.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97790026
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
@@ -130,26 +114,166 @@
}
 
// add the beginning state
-   final State beginningState;
+   State beginningState = 
states.get(BEGINNING_STATE_NAME);;
+   addTransitions(beginningState, -1, patterns, states);
+   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   }
+   }
 
-   if (states.containsKey(BEGINNING_STATE_NAME)) {
-   beginningState = 
states.get(BEGINNING_STATE_NAME);
-   } else {
-   beginningState = new 
State<>(BEGINNING_STATE_NAME, State.StateType.Start);
-   states.put(BEGINNING_STATE_NAME, 
beginningState);
-   }
+   private static  void addTransitions(State currentState, int 
patternPos, ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
 
-   beginningState.addStateTransition(new 
StateTransition(
+   if (shouldRepeatPattern(patternPos, patterns)) {
+   expandRepeatingPattern(currentState, patternPos, 
patterns, states);
+   } else {
+   currentState.addStateTransition(new StateTransition(
StateTransitionAction.TAKE,
-   currentState,
-   (FilterFunction) 
currentPattern.getFilterFunction()
+   succeedingState,
+   (FilterFunction) 
succeedingPattern.getFilterFunction()
));
 
-   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   if (shouldAddSelfTransition(succeedingPattern))  {
+   addTransitionToSelf(succeedingPattern, 
succeedingState);
+   }
+   if (isPatternOptional(succeedingPattern)) {
+   addOptionalTransitions(currentState, 
patternPos, patterns, states);
+   }
+   }
+   }
+
+   private static  void addOptionalTransitions(State currentState, 
int patternPos, ArrayList> patterns, Map 
states) {
+   int firstNonOptionalPattern = 
findFirstNonOptionalPattern(patterns, patternPos + 1);
+
+   for (int optionalPatternPos = patternPos + 2;
+   optionalPatternPos < 
Math.min(firstNonOptionalPattern + 1, patterns.size());
+   optionalPatternPos++) {
+
+   Pattern optionalPattern = 
patterns.get(optionalPatternPos);
+   State optionalState = 
states.get(optionalPattern.getName());
+   currentState.addStateTransition(new StateTransition<>(
+   StateTransitionAction.TAKE,
+   optionalState,
+   (FilterFunction) 
optionalPattern.getFilterFunction()));
}
}
 
/**
+* Expand a pattern number of times and connect expanded states. E.g. 
count(3) wil result in:
+*
+* +-+  +---+  +---+
+* |State+->|State#1+->|State#2+
+* +--+--+  +---+  +--++
+*/
+   private static  void expandRepeatingPattern(State currentState, 
int patternPos,
+   
ArrayList> patterns, Map states) {
--- End diff --

The `patterns` can become a `List` instead of `ArrayList`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97790105
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
@@ -130,26 +114,166 @@
}
 
// add the beginning state
-   final State beginningState;
+   State beginningState = 
states.get(BEGINNING_STATE_NAME);;
+   addTransitions(beginningState, -1, patterns, states);
+   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   }
+   }
 
-   if (states.containsKey(BEGINNING_STATE_NAME)) {
-   beginningState = 
states.get(BEGINNING_STATE_NAME);
-   } else {
-   beginningState = new 
State<>(BEGINNING_STATE_NAME, State.StateType.Start);
-   states.put(BEGINNING_STATE_NAME, 
beginningState);
-   }
+   private static  void addTransitions(State currentState, int 
patternPos, ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
 
-   beginningState.addStateTransition(new 
StateTransition(
+   if (shouldRepeatPattern(patternPos, patterns)) {
+   expandRepeatingPattern(currentState, patternPos, 
patterns, states);
+   } else {
+   currentState.addStateTransition(new StateTransition(
StateTransitionAction.TAKE,
-   currentState,
-   (FilterFunction) 
currentPattern.getFilterFunction()
+   succeedingState,
+   (FilterFunction) 
succeedingPattern.getFilterFunction()
));
 
-   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   if (shouldAddSelfTransition(succeedingPattern))  {
+   addTransitionToSelf(succeedingPattern, 
succeedingState);
+   }
+   if (isPatternOptional(succeedingPattern)) {
+   addOptionalTransitions(currentState, 
patternPos, patterns, states);
+   }
+   }
+   }
+
+   private static  void addOptionalTransitions(State currentState, 
int patternPos, ArrayList> patterns, Map 
states) {
+   int firstNonOptionalPattern = 
findFirstNonOptionalPattern(patterns, patternPos + 1);
+
+   for (int optionalPatternPos = patternPos + 2;
+   optionalPatternPos < 
Math.min(firstNonOptionalPattern + 1, patterns.size());
+   optionalPatternPos++) {
+
+   Pattern optionalPattern = 
patterns.get(optionalPatternPos);
+   State optionalState = 
states.get(optionalPattern.getName());
+   currentState.addStateTransition(new StateTransition<>(
+   StateTransitionAction.TAKE,
+   optionalState,
+   (FilterFunction) 
optionalPattern.getFilterFunction()));
}
}
 
/**
+* Expand a pattern number of times and connect expanded states. E.g. 
count(3) wil result in:
+*
+* +-+  +---+  +---+
+* |State+->|State#1+->|State#2+
+* +--+--+  +---+  +--++
+*/
+   private static  void expandRepeatingPattern(State currentState, 
int patternPos,
+   
ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
+   Pattern currentPattern = patterns.get(patternPos);
+
+   State currentRepeatingState = null;
+   State nextRepeatingState = currentState;
+   for (int i = 1; i < currentPattern.getMaxCount(); i++) {
+   currentRepeatingState = nextRepeatingState;
+   nextRepeatingState = new State<>(
+   currentState.getName() + "#" + i,
+   State.StateType.Normal);
+   states.put(nextRepeatingState.getName(), 
nextRepeatingState);
+   

[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97790271
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
@@ -130,26 +114,166 @@
}
 
// add the beginning state
-   final State beginningState;
+   State beginningState = 
states.get(BEGINNING_STATE_NAME);;
+   addTransitions(beginningState, -1, patterns, states);
+   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   }
+   }
 
-   if (states.containsKey(BEGINNING_STATE_NAME)) {
-   beginningState = 
states.get(BEGINNING_STATE_NAME);
-   } else {
-   beginningState = new 
State<>(BEGINNING_STATE_NAME, State.StateType.Start);
-   states.put(BEGINNING_STATE_NAME, 
beginningState);
-   }
+   private static  void addTransitions(State currentState, int 
patternPos, ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
 
-   beginningState.addStateTransition(new 
StateTransition(
+   if (shouldRepeatPattern(patternPos, patterns)) {
+   expandRepeatingPattern(currentState, patternPos, 
patterns, states);
+   } else {
+   currentState.addStateTransition(new StateTransition(
StateTransitionAction.TAKE,
-   currentState,
-   (FilterFunction) 
currentPattern.getFilterFunction()
+   succeedingState,
+   (FilterFunction) 
succeedingPattern.getFilterFunction()
));
 
-   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   if (shouldAddSelfTransition(succeedingPattern))  {
+   addTransitionToSelf(succeedingPattern, 
succeedingState);
+   }
+   if (isPatternOptional(succeedingPattern)) {
+   addOptionalTransitions(currentState, 
patternPos, patterns, states);
+   }
+   }
+   }
+
+   private static  void addOptionalTransitions(State currentState, 
int patternPos, ArrayList> patterns, Map 
states) {
+   int firstNonOptionalPattern = 
findFirstNonOptionalPattern(patterns, patternPos + 1);
+
+   for (int optionalPatternPos = patternPos + 2;
+   optionalPatternPos < 
Math.min(firstNonOptionalPattern + 1, patterns.size());
+   optionalPatternPos++) {
+
+   Pattern optionalPattern = 
patterns.get(optionalPatternPos);
+   State optionalState = 
states.get(optionalPattern.getName());
+   currentState.addStateTransition(new StateTransition<>(
+   StateTransitionAction.TAKE,
+   optionalState,
+   (FilterFunction) 
optionalPattern.getFilterFunction()));
}
}
 
/**
+* Expand a pattern number of times and connect expanded states. E.g. 
count(3) wil result in:
+*
+* +-+  +---+  +---+
+* |State+->|State#1+->|State#2+
+* +--+--+  +---+  +--++
+*/
+   private static  void expandRepeatingPattern(State currentState, 
int patternPos,
+   
ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
+   Pattern currentPattern = patterns.get(patternPos);
+
+   State currentRepeatingState = null;
+   State nextRepeatingState = currentState;
+   for (int i = 1; i < currentPattern.getMaxCount(); i++) {
+   currentRepeatingState = nextRepeatingState;
+   nextRepeatingState = new State<>(
+   currentState.getName() + "#" + i,
+   State.StateType.Normal);
+   states.put(nextRepeatingState.getName(), 
nextRepeatingState);
+   

[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97790228
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
@@ -130,26 +114,166 @@
}
 
// add the beginning state
-   final State beginningState;
+   State beginningState = 
states.get(BEGINNING_STATE_NAME);;
+   addTransitions(beginningState, -1, patterns, states);
+   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   }
+   }
 
-   if (states.containsKey(BEGINNING_STATE_NAME)) {
-   beginningState = 
states.get(BEGINNING_STATE_NAME);
-   } else {
-   beginningState = new 
State<>(BEGINNING_STATE_NAME, State.StateType.Start);
-   states.put(BEGINNING_STATE_NAME, 
beginningState);
-   }
+   private static  void addTransitions(State currentState, int 
patternPos, ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
 
-   beginningState.addStateTransition(new 
StateTransition(
+   if (shouldRepeatPattern(patternPos, patterns)) {
+   expandRepeatingPattern(currentState, patternPos, 
patterns, states);
+   } else {
+   currentState.addStateTransition(new StateTransition(
StateTransitionAction.TAKE,
-   currentState,
-   (FilterFunction) 
currentPattern.getFilterFunction()
+   succeedingState,
+   (FilterFunction) 
succeedingPattern.getFilterFunction()
));
 
-   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   if (shouldAddSelfTransition(succeedingPattern))  {
+   addTransitionToSelf(succeedingPattern, 
succeedingState);
+   }
+   if (isPatternOptional(succeedingPattern)) {
+   addOptionalTransitions(currentState, 
patternPos, patterns, states);
+   }
+   }
+   }
+
+   private static  void addOptionalTransitions(State currentState, 
int patternPos, ArrayList> patterns, Map 
states) {
+   int firstNonOptionalPattern = 
findFirstNonOptionalPattern(patterns, patternPos + 1);
+
+   for (int optionalPatternPos = patternPos + 2;
+   optionalPatternPos < 
Math.min(firstNonOptionalPattern + 1, patterns.size());
+   optionalPatternPos++) {
+
+   Pattern optionalPattern = 
patterns.get(optionalPatternPos);
+   State optionalState = 
states.get(optionalPattern.getName());
+   currentState.addStateTransition(new StateTransition<>(
+   StateTransitionAction.TAKE,
+   optionalState,
+   (FilterFunction) 
optionalPattern.getFilterFunction()));
}
}
 
/**
+* Expand a pattern number of times and connect expanded states. E.g. 
count(3) wil result in:
+*
+* +-+  +---+  +---+
+* |State+->|State#1+->|State#2+
+* +--+--+  +---+  +--++
+*/
+   private static  void expandRepeatingPattern(State currentState, 
int patternPos,
+   
ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
+   Pattern currentPattern = patterns.get(patternPos);
+
+   State currentRepeatingState = null;
+   State nextRepeatingState = currentState;
+   for (int i = 1; i < currentPattern.getMaxCount(); i++) {
+   currentRepeatingState = nextRepeatingState;
+   nextRepeatingState = new State<>(
+   currentState.getName() + "#" + i,
+   State.StateType.Normal);
+   states.put(nextRepeatingState.getName(), 
nextRepeatingState);
+   

[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97790385
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
@@ -130,26 +114,166 @@
}
 
// add the beginning state
-   final State beginningState;
+   State beginningState = 
states.get(BEGINNING_STATE_NAME);;
+   addTransitions(beginningState, -1, patterns, states);
+   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   }
+   }
 
-   if (states.containsKey(BEGINNING_STATE_NAME)) {
-   beginningState = 
states.get(BEGINNING_STATE_NAME);
-   } else {
-   beginningState = new 
State<>(BEGINNING_STATE_NAME, State.StateType.Start);
-   states.put(BEGINNING_STATE_NAME, 
beginningState);
-   }
+   private static  void addTransitions(State currentState, int 
patternPos, ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
 
-   beginningState.addStateTransition(new 
StateTransition(
+   if (shouldRepeatPattern(patternPos, patterns)) {
+   expandRepeatingPattern(currentState, patternPos, 
patterns, states);
+   } else {
+   currentState.addStateTransition(new StateTransition(
StateTransitionAction.TAKE,
-   currentState,
-   (FilterFunction) 
currentPattern.getFilterFunction()
+   succeedingState,
+   (FilterFunction) 
succeedingPattern.getFilterFunction()
));
 
-   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   if (shouldAddSelfTransition(succeedingPattern))  {
+   addTransitionToSelf(succeedingPattern, 
succeedingState);
+   }
+   if (isPatternOptional(succeedingPattern)) {
+   addOptionalTransitions(currentState, 
patternPos, patterns, states);
+   }
+   }
+   }
+
+   private static  void addOptionalTransitions(State currentState, 
int patternPos, ArrayList> patterns, Map 
states) {
+   int firstNonOptionalPattern = 
findFirstNonOptionalPattern(patterns, patternPos + 1);
+
+   for (int optionalPatternPos = patternPos + 2;
+   optionalPatternPos < 
Math.min(firstNonOptionalPattern + 1, patterns.size());
+   optionalPatternPos++) {
+
+   Pattern optionalPattern = 
patterns.get(optionalPatternPos);
+   State optionalState = 
states.get(optionalPattern.getName());
+   currentState.addStateTransition(new StateTransition<>(
+   StateTransitionAction.TAKE,
+   optionalState,
+   (FilterFunction) 
optionalPattern.getFilterFunction()));
}
}
 
/**
+* Expand a pattern number of times and connect expanded states. E.g. 
count(3) wil result in:
+*
+* +-+  +---+  +---+
+* |State+->|State#1+->|State#2+
+* +--+--+  +---+  +--++
+*/
+   private static  void expandRepeatingPattern(State currentState, 
int patternPos,
+   
ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
+   Pattern currentPattern = patterns.get(patternPos);
+
+   State currentRepeatingState = null;
+   State nextRepeatingState = currentState;
+   for (int i = 1; i < currentPattern.getMaxCount(); i++) {
+   currentRepeatingState = nextRepeatingState;
+   nextRepeatingState = new State<>(
+   currentState.getName() + "#" + i,
+   State.StateType.Normal);
+   states.put(nextRepeatingState.getName(), 
nextRepeatingState);
+   

[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97789988
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
@@ -130,26 +114,166 @@
}
 
// add the beginning state
-   final State beginningState;
+   State beginningState = 
states.get(BEGINNING_STATE_NAME);;
+   addTransitions(beginningState, -1, patterns, states);
+   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   }
+   }
 
-   if (states.containsKey(BEGINNING_STATE_NAME)) {
-   beginningState = 
states.get(BEGINNING_STATE_NAME);
-   } else {
-   beginningState = new 
State<>(BEGINNING_STATE_NAME, State.StateType.Start);
-   states.put(BEGINNING_STATE_NAME, 
beginningState);
-   }
+   private static  void addTransitions(State currentState, int 
patternPos, ArrayList> patterns, Map states) {
+   Pattern succeedingPattern = patterns.get(patternPos + 1);
+   State succeedingState = 
states.get(succeedingPattern.getName());
 
-   beginningState.addStateTransition(new 
StateTransition(
+   if (shouldRepeatPattern(patternPos, patterns)) {
+   expandRepeatingPattern(currentState, patternPos, 
patterns, states);
+   } else {
+   currentState.addStateTransition(new StateTransition(
StateTransitionAction.TAKE,
-   currentState,
-   (FilterFunction) 
currentPattern.getFilterFunction()
+   succeedingState,
+   (FilterFunction) 
succeedingPattern.getFilterFunction()
));
 
-   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   if (shouldAddSelfTransition(succeedingPattern))  {
+   addTransitionToSelf(succeedingPattern, 
succeedingState);
+   }
+   if (isPatternOptional(succeedingPattern)) {
+   addOptionalTransitions(currentState, 
patternPos, patterns, states);
+   }
+   }
+   }
+
+   private static  void addOptionalTransitions(State currentState, 
int patternPos, ArrayList> patterns, Map 
states) {
--- End diff --

The `patterns` can become a `List` instead of `ArrayList`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97789900
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
@@ -130,26 +114,166 @@
}
 
// add the beginning state
-   final State beginningState;
+   State beginningState = 
states.get(BEGINNING_STATE_NAME);;
+   addTransitions(beginningState, -1, patterns, states);
+   return new NFAFactoryImpl(inputTypeSerializer, 
windowTime, new HashSet<>(states.values()), timeoutHandling);
+   }
+   }
 
-   if (states.containsKey(BEGINNING_STATE_NAME)) {
-   beginningState = 
states.get(BEGINNING_STATE_NAME);
-   } else {
-   beginningState = new 
State<>(BEGINNING_STATE_NAME, State.StateType.Start);
-   states.put(BEGINNING_STATE_NAME, 
beginningState);
-   }
+   private static  void addTransitions(State currentState, int 
patternPos, ArrayList> patterns, Map states) {
--- End diff --

The `patterns` can become a `List` instead of `ArrayList`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-25 Thread kl0u
Github user kl0u commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97789775
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
@@ -80,25 +82,17 @@
// return a factory for empty NFAs
return new NFAFactoryImpl(inputTypeSerializer, 0, 
Collections.emptyList(), timeoutHandling);
} else {
+   ArrayList> patterns = 
createPatternsList(pattern);
--- End diff --

The `patterns` can become a `List` instead of `ArrayList`. It is good to 
have the most generic type possible as argument or return type, as 
implementations may change.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2017-01-22 Thread chermenin
Github user chermenin commented on a diff in the pull request:

https://github.com/apache/flink/pull/2361#discussion_r97264252
  
--- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/State.java ---
@@ -43,7 +43,14 @@ public State(final String name, final StateType 
stateType) {
this.name = name;
this.stateType = stateType;
 
-   stateTransitions = new ArrayList();
+   stateTransitions = new ArrayList<>();
+   }
+
+   public State(String name, StateType stateType, 
Collection stateTransitions) {
--- End diff --

It seems that this constructor is never used. What is that for?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2016-08-12 Thread mushketyk
GitHub user mushketyk reopened a pull request:

https://github.com/apache/flink/pull/2361

[FLINK-3318][cep] Add support for quantifiers to CEP's pattern API

Thanks for contributing to Apache Flink. Before you open your pull request, 
please take the following check list into consideration.
If your changes take all of the items into account, feel free to open your 
pull request. For more information and/or questions please refer to the [How To 
Contribute guide](http://flink.apache.org/how-to-contribute.html).
In addition to going through the list, please provide a meaningful 
description of your changes.

- [x] General
  - The pull request references the related JIRA issue ("[FLINK-XXX] Jira 
title text")
  - The pull request addresses only one issue
  - Each commit in the PR has a meaningful commit message (including the 
JIRA id)

- [x] Documentation
  - Documentation has been added for new functionality
  - Old documentation affected by the pull request has been updated
  - JavaDoc for public methods has been added

- [x] Tests & Build
  - Functionality added by the pull request is covered by tests
  - `mvn clean verify` has been executed successfully locally or a Travis 
build has passed


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/mushketyk/flink cep-operators

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/2361.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2361


commit 96c077a4c1c2c1ccba678ec863775402554d6dcf
Author: Ivan Mushketyk 
Date:   2016-08-05T20:05:39Z

[FLINK-3318][cep] Add support for quantifiers to CEP's pattern API

commit 425fa3d94d15ea6b1396e7bf7a901f7318f107b0
Author: Ivan Mushketyk 
Date:   2016-08-11T21:10:43Z

[FLINK-3318][cep] Add documentation about pattern quantifiers




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2016-08-11 Thread mushketyk
Github user mushketyk closed the pull request at:

https://github.com/apache/flink/pull/2361


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2361: [FLINK-3318][cep] Add support for quantifiers to C...

2016-08-11 Thread mushketyk
GitHub user mushketyk opened a pull request:

https://github.com/apache/flink/pull/2361

[FLINK-3318][cep] Add support for quantifiers to CEP's pattern API

Thanks for contributing to Apache Flink. Before you open your pull request, 
please take the following check list into consideration.
If your changes take all of the items into account, feel free to open your 
pull request. For more information and/or questions please refer to the [How To 
Contribute guide](http://flink.apache.org/how-to-contribute.html).
In addition to going through the list, please provide a meaningful 
description of your changes.

- [x] General
  - The pull request references the related JIRA issue ("[FLINK-XXX] Jira 
title text")
  - The pull request addresses only one issue
  - Each commit in the PR has a meaningful commit message (including the 
JIRA id)

- [x] Documentation
  - Documentation has been added for new functionality
  - Old documentation affected by the pull request has been updated
  - JavaDoc for public methods has been added

- [x] Tests & Build
  - Functionality added by the pull request is covered by tests
  - `mvn clean verify` has been executed successfully locally or a Travis 
build has passed


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/mushketyk/flink cep-operators

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/2361.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2361


commit 96c077a4c1c2c1ccba678ec863775402554d6dcf
Author: Ivan Mushketyk 
Date:   2016-08-05T20:05:39Z

[FLINK-3318][cep] Add support for quantifiers to CEP's pattern API

commit 425fa3d94d15ea6b1396e7bf7a901f7318f107b0
Author: Ivan Mushketyk 
Date:   2016-08-11T21:10:43Z

[FLINK-3318][cep] Add documentation about pattern quantifiers




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---