edu.umass.cs.sase.engine
Class Engine

java.lang.Object
  extended by edu.umass.cs.sase.engine.Engine

public class Engine
extends java.lang.Object

This is the processing engine.

Author:
haopeng

Constructor Summary
Engine()
          The default constructor.
 
Method Summary
 void addEventToRun(Run r, Event e)
          This method adds an event to a run
 void addEventToRunForNegation(Run r, Event e)
          This method adds an event to a run, for queries with a negation component.
 void addRunByPartition(Run newRun)
          This methods add a new run to a partition.
 boolean checkNegation(Event e)
           
 boolean checkPartition(Event e, Run r)
          Checks whether the event satisfies the partition of a run, only used under partition-contiguity selection strategy
 boolean checkPredicate(Event e, Run r)
          Checks whether the event satisfies the predicates of a run
 int checkPredicateOptimized(Event e, Run r)
          Checks the predicate for e against r
 boolean checkProceed(Run r)
          Checks whether a kleene closure state can proceed to the next state
 boolean checkProceedOptimized(Event e, Run r)
          Checks whether the run needs to proceed if we add e to r
 boolean checkTimeWindow(Event e, Run r)
          Checks whether the event satisfies the time window constraint of a run
 void cleanRuns()
          Cleans useless runs
 void cleanRunsByPartition()
          Cleans useless runs by partition.
 Run cloneRun(Run r)
          Clones a run
 void createNewRun(Event e)
          Creates a new run containing the input event.
 void createNewRunByPartition(Event e)
          Creates a new run containing the input event and adds the new run to the corresponding partition
 void deleteRunsOverTimeWindow(int currentTime, int timeWindow, int delayTime)
          Deletes runs violating the time window
 void evaluateEventForNegation(Event e, Run r)
          This method evaluates an event against a run, for queries with a negation component.
 void evaluateEventForPartitonContiguity(Event e, Run r)
          This method evaluates an event against a run.
 void evaluateEventForPartitonContiguityOptimized(Event e, Run r)
          If the selection strategy is partition-contiguity, this method is called, and it evaluates the event for a given run
 void evaluateEventForSkipTillAny(Event e, Run r)
          This method evaluates an event against a run, for skip-till-any-match
 void evaluateEventForSkipTillNext(Event e, Run r)
          This method evaluates an event against a run, for skip-till-next-match
 void evaluateEventOptimizedForNegation(Event e, Run r)
          This method evaluates the event for a given run, for queries with a negation component.
 void evaluateEventOptimizedForSkipTillAny(Event e, Run r)
          This method evaluates the event for a given run, for skip-till-any-match
 void evaluateEventOptimizedForSkipTillNext(Event e, Run r)
          This method evaluates the event for a given run, for skip-till-next-match.
 void evaluateRunsByPartitionForNegation(Event e)
          This method will iterate runs in the same partition for the current event, for queries with a negation component.
 void evaluateRunsByPartitionForSkipTillAny(Event e)
          This method will iterate runs in the same partition for the current event, for skip-till-any-match
 void evaluateRunsByPartitionForSkipTillNext(Event e)
          This method will iterate runs in the same partition for the current event, for skip-till-next-match
 void evaluateRunsForNegation(Event e)
          This method will iterate all existing runs for the current event, for queries with a negation component.
 void evaluateRunsForPartitionContiguity(Event e)
          If the selection strategy is partition-contiguity, this method is called and it will iterate runs in the same partition for the current event
 void evaluateRunsForSkipTillAny(Event e)
          This method will iterate all existing runs for the current event, for skip-till-any-match.
 void evaluateRunsForSkipTillNext(Event e)
          This method will iterate all existing runs for the current event, for skip-till-next-match.
 java.util.ArrayList<Run> getActiveRuns()
           
 java.util.HashMap<java.lang.Integer,java.util.ArrayList<Run>> getActiveRunsByPartition()
           
 java.util.HashMap<java.lang.Integer,java.util.ArrayList<Run>> getActiveRunsByPartiton()
           
 EventBuffer getBuffer()
           
 RunPool getEngineRunController()
           
 Stream getInput()
           
 MatchController getMatches()
           
 java.util.ArrayList<Event> getNegationEvents()
           
 java.util.HashMap<java.lang.Integer,java.util.ArrayList<Event>> getNegationEventsByPartition()
           
 NFA getNfa()
           
 java.util.ArrayList<Run> getToDeleteRuns()
           
 void indexNegationByPartition(Event e)
           
 void initialize()
          This method initializes the engine.
 void outputMatch(Match m)
          Outputs a match, and profiles.
 void outputMatchByPartitionForNegation(Match m, Run r)
          Outputs a match, and profiles, for queries with a negation componengt, with a partition attribute.
 void outputMatchForNegation(Match m, Run r)
          Outputs a match, and profiles, for queries with a negation componengt, without a partition attribute.
 void runEngine()
          This is the main run logic method
 void runNegationEngine()
          The main method when there is a negation component in the query
 void runPartitionContiguityEngine()
          This method is called when the query uses the partition-contiguity selection strategy
 void runSkipTillAnyEngine()
          The main method for skip-till-any-match
 void runSkipTillNextEngine()
          The main method for skip-till-next-match
 boolean searchNegation(int beforeTimestamp, int afterTimestamp, java.util.ArrayList<Event> list)
           
 boolean searchNegationByPartition(int beforeTimestamp, int afterTimestamp, int partitionId)
           
 void setActiveRuns(java.util.ArrayList<Run> activeRuns)
           
 void setActiveRunsByPartition(java.util.HashMap<java.lang.Integer,java.util.ArrayList<Run>> activeRunsByPartition)
           
 void setActiveRunsByPartiton(java.util.HashMap<java.lang.Integer,java.util.ArrayList<Run>> activeRunsByPartiton)
           
 void setBuffer(EventBuffer buffer)
           
 void setEngineRunController(RunPool engineRunController)
           
 void setInput(Stream input)
           
 void setMatches(MatchController matches)
           
 void setNegationEvents(java.util.ArrayList<Event> negationEvents)
           
 void setNegationEventsByPartition(java.util.HashMap<java.lang.Integer,java.util.ArrayList<Event>> negationEventsByPartition)
           
 void setNfa(NFA nfa)
           
 void setToDeleteRuns(java.util.ArrayList<Run> toDeleteRuns)
           
 void warmUp()
          This method is used to warm up the engine.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Engine

public Engine()
The default constructor.

Method Detail

initialize

public void initialize()
This method initializes the engine.


warmUp

public void warmUp()
            throws java.lang.CloneNotSupportedException,
                   net.sourceforge.jeval.EvaluationException
This method is used to warm up the engine.

Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

runEngine

public void runEngine()
               throws java.lang.CloneNotSupportedException,
                      net.sourceforge.jeval.EvaluationException
This is the main run logic method

Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

runSkipTillAnyEngine

public void runSkipTillAnyEngine()
                          throws java.lang.CloneNotSupportedException,
                                 net.sourceforge.jeval.EvaluationException
The main method for skip-till-any-match

Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

runSkipTillNextEngine

public void runSkipTillNextEngine()
                           throws java.lang.CloneNotSupportedException,
                                  net.sourceforge.jeval.EvaluationException
The main method for skip-till-next-match

Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

runPartitionContiguityEngine

public void runPartitionContiguityEngine()
                                  throws net.sourceforge.jeval.EvaluationException,
                                         java.lang.CloneNotSupportedException
This method is called when the query uses the partition-contiguity selection strategy

Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

runNegationEngine

public void runNegationEngine()
                       throws java.lang.CloneNotSupportedException,
                              net.sourceforge.jeval.EvaluationException
The main method when there is a negation component in the query

Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

evaluateRunsForSkipTillAny

public void evaluateRunsForSkipTillAny(Event e)
                                throws java.lang.CloneNotSupportedException,
                                       net.sourceforge.jeval.EvaluationException
This method will iterate all existing runs for the current event, for skip-till-any-match.

Parameters:
e - The current event which is being evaluated.
Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

evaluateRunsForSkipTillNext

public void evaluateRunsForSkipTillNext(Event e)
                                 throws java.lang.CloneNotSupportedException,
                                        net.sourceforge.jeval.EvaluationException
This method will iterate all existing runs for the current event, for skip-till-next-match.

Parameters:
e - The current event which is being evaluated.
Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

evaluateRunsForNegation

public void evaluateRunsForNegation(Event e)
                             throws java.lang.CloneNotSupportedException,
                                    net.sourceforge.jeval.EvaluationException
This method will iterate all existing runs for the current event, for queries with a negation component.

Parameters:
e - The current event which is being evaluated.
Throws:
java.lang.CloneNotSupportedException
net.sourceforge.jeval.EvaluationException

evaluateRunsByPartitionForSkipTillAny

public void evaluateRunsByPartitionForSkipTillAny(Event e)
                                           throws java.lang.CloneNotSupportedException
This method will iterate runs in the same partition for the current event, for skip-till-any-match

Parameters:
e - The current event which is being evaluated.
Throws:
java.lang.CloneNotSupportedException

evaluateRunsByPartitionForSkipTillNext

public void evaluateRunsByPartitionForSkipTillNext(Event e)
                                            throws java.lang.CloneNotSupportedException
This method will iterate runs in the same partition for the current event, for skip-till-next-match

Parameters:
e - The current event which is being evaluated.
Throws:
java.lang.CloneNotSupportedException

evaluateRunsByPartitionForNegation

public void evaluateRunsByPartitionForNegation(Event e)
                                        throws java.lang.CloneNotSupportedException
This method will iterate runs in the same partition for the current event, for queries with a negation component.

Parameters:
e - The current event which is being evaluated.
Throws:
java.lang.CloneNotSupportedException

evaluateRunsForPartitionContiguity

public void evaluateRunsForPartitionContiguity(Event e)
                                        throws java.lang.CloneNotSupportedException
If the selection strategy is partition-contiguity, this method is called and it will iterate runs in the same partition for the current event

Parameters:
e - The current event which is being evaluated.
Throws:
java.lang.CloneNotSupportedException

evaluateEventOptimizedForSkipTillAny

public void evaluateEventOptimizedForSkipTillAny(Event e,
                                                 Run r)
                                          throws java.lang.CloneNotSupportedException
This method evaluates the event for a given run, for skip-till-any-match

Parameters:
e - The current event which is being evaluated.
r - The run against which the evaluation goes
Throws:
java.lang.CloneNotSupportedException

evaluateEventOptimizedForSkipTillNext

public void evaluateEventOptimizedForSkipTillNext(Event e,
                                                  Run r)
This method evaluates the event for a given run, for skip-till-next-match.

Parameters:
e - The current event which is being evaluated.
r - The run against which the evaluation goes

evaluateEventOptimizedForNegation

public void evaluateEventOptimizedForNegation(Event e,
                                              Run r)
                                       throws java.lang.CloneNotSupportedException
This method evaluates the event for a given run, for queries with a negation component.

Parameters:
e - The current event which is being evaluated.
r - The run against which the evaluation goes
Throws:
java.lang.CloneNotSupportedException

evaluateEventForPartitonContiguityOptimized

public void evaluateEventForPartitonContiguityOptimized(Event e,
                                                        Run r)
                                                 throws java.lang.CloneNotSupportedException
If the selection strategy is partition-contiguity, this method is called, and it evaluates the event for a given run

Parameters:
e - The current event which is being evaluated
r - The run against which the evaluation goes
Throws:
java.lang.CloneNotSupportedException

evaluateEventForSkipTillAny

public void evaluateEventForSkipTillAny(Event e,
                                        Run r)
                                 throws java.lang.CloneNotSupportedException
This method evaluates an event against a run, for skip-till-any-match

Parameters:
e - The event which is being evaluated.
r - The run which the event is being evaluated against.
Throws:
java.lang.CloneNotSupportedException

evaluateEventForSkipTillNext

public void evaluateEventForSkipTillNext(Event e,
                                         Run r)
                                  throws java.lang.CloneNotSupportedException
This method evaluates an event against a run, for skip-till-next-match

Parameters:
e - The event which is being evaluated.
r - The run which the event is being evaluated against.
Throws:
java.lang.CloneNotSupportedException

evaluateEventForNegation

public void evaluateEventForNegation(Event e,
                                     Run r)
                              throws java.lang.CloneNotSupportedException
This method evaluates an event against a run, for queries with a negation component.

Parameters:
e - The event which is being evaluated.
r - The run which the event is being evaluated against.
Throws:
java.lang.CloneNotSupportedException

addRunByPartition

public void addRunByPartition(Run newRun)
This methods add a new run to a partition.

Parameters:
newRun - The run to be added

evaluateEventForPartitonContiguity

public void evaluateEventForPartitonContiguity(Event e,
                                               Run r)
                                        throws java.lang.CloneNotSupportedException
This method evaluates an event against a run.

Parameters:
e - The event which is being evaluated.
r - The run which the event is being evaluated against.
Throws:
java.lang.CloneNotSupportedException

addEventToRun

public void addEventToRun(Run r,
                          Event e)
This method adds an event to a run

Parameters:
r - The event to be added
e - The run to which the event is added

addEventToRunForNegation

public void addEventToRunForNegation(Run r,
                                     Event e)
This method adds an event to a run, for queries with a negation component.

Parameters:
r - The event to be added
e - The run to which the event is added

createNewRun

public void createNewRun(Event e)
                  throws net.sourceforge.jeval.EvaluationException
Creates a new run containing the input event.

Parameters:
e - The current event.
Throws:
net.sourceforge.jeval.EvaluationException

createNewRunByPartition

public void createNewRunByPartition(Event e)
                             throws net.sourceforge.jeval.EvaluationException,
                                    java.lang.CloneNotSupportedException
Creates a new run containing the input event and adds the new run to the corresponding partition

Parameters:
e - The current event
Throws:
net.sourceforge.jeval.EvaluationException
java.lang.CloneNotSupportedException

checkPredicateOptimized

public int checkPredicateOptimized(Event e,
                                   Run r)
Checks the predicate for e against r

Parameters:
e - The current event
r - The run against which e is evaluated
Returns:
The check result, 0 for false, 1 for take or begin, 2 for proceed

checkProceedOptimized

public boolean checkProceedOptimized(Event e,
                                     Run r)
Checks whether the run needs to proceed if we add e to r

Parameters:
e - The current event
r - The run against which e is evaluated
Returns:
The checking result, TRUE for OK to proceed

checkPredicate

public boolean checkPredicate(Event e,
                              Run r)
Checks whether the event satisfies the predicates of a run

Parameters:
e - the current event
r - the current run
Returns:
the check result

checkPartition

public boolean checkPartition(Event e,
                              Run r)
Checks whether the event satisfies the partition of a run, only used under partition-contiguity selection strategy

Parameters:
e - the current event
r - the current run
Returns:
the check result, boolean format

checkProceed

public boolean checkProceed(Run r)
Checks whether a kleene closure state can proceed to the next state

Parameters:
r - the current run
Returns:
the check result, boolean format

checkNegation

public boolean checkNegation(Event e)
                      throws net.sourceforge.jeval.EvaluationException
Throws:
net.sourceforge.jeval.EvaluationException

indexNegationByPartition

public void indexNegationByPartition(Event e)

searchNegation

public boolean searchNegation(int beforeTimestamp,
                              int afterTimestamp,
                              java.util.ArrayList<Event> list)

searchNegationByPartition

public boolean searchNegationByPartition(int beforeTimestamp,
                                         int afterTimestamp,
                                         int partitionId)

cloneRun

public Run cloneRun(Run r)
             throws java.lang.CloneNotSupportedException
Clones a run

Parameters:
r - the run to be cloned
Returns:
the new run cloned from the input run.
Throws:
java.lang.CloneNotSupportedException

checkTimeWindow

public boolean checkTimeWindow(Event e,
                               Run r)
Checks whether the event satisfies the time window constraint of a run

Parameters:
e - the current event
r - the current run
Returns:
the check result

outputMatch

public void outputMatch(Match m)
Outputs a match, and profiles.

Parameters:
m - the match to be output

outputMatchForNegation

public void outputMatchForNegation(Match m,
                                   Run r)
Outputs a match, and profiles, for queries with a negation componengt, without a partition attribute.

Parameters:
m - the match to be output

outputMatchByPartitionForNegation

public void outputMatchByPartitionForNegation(Match m,
                                              Run r)
Outputs a match, and profiles, for queries with a negation componengt, with a partition attribute.

Parameters:
m - the match to be output

deleteRunsOverTimeWindow

public void deleteRunsOverTimeWindow(int currentTime,
                                     int timeWindow,
                                     int delayTime)
Deletes runs violating the time window

Parameters:
currentTime - current time
timeWindow - time window of the query
delayTime - specified delay period, any run which has been past the time window by this value would be deleted.

cleanRuns

public void cleanRuns()
Cleans useless runs


cleanRunsByPartition

public void cleanRunsByPartition()
Cleans useless runs by partition.


getInput

public Stream getInput()
Returns:
the input

setInput

public void setInput(Stream input)
Parameters:
input - the input to set

getBuffer

public EventBuffer getBuffer()
Returns:
the buffer

setBuffer

public void setBuffer(EventBuffer buffer)
Parameters:
buffer - the buffer to set

getNfa

public NFA getNfa()
Returns:
the nfa

setNfa

public void setNfa(NFA nfa)
Parameters:
nfa - the nfa to set

getEngineRunController

public RunPool getEngineRunController()
Returns:
the engineRunController

setEngineRunController

public void setEngineRunController(RunPool engineRunController)
Parameters:
engineRunController - the engineRunController to set

getActiveRuns

public java.util.ArrayList<Run> getActiveRuns()
Returns:
the activeRuns

setActiveRuns

public void setActiveRuns(java.util.ArrayList<Run> activeRuns)
Parameters:
activeRuns - the activeRuns to set

getMatches

public MatchController getMatches()
Returns:
the matches

setMatches

public void setMatches(MatchController matches)
Parameters:
matches - the matches to set

getToDeleteRuns

public java.util.ArrayList<Run> getToDeleteRuns()
Returns:
the toDeleteRuns

setToDeleteRuns

public void setToDeleteRuns(java.util.ArrayList<Run> toDeleteRuns)
Parameters:
toDeleteRuns - the toDeleteRuns to set

getActiveRunsByPartiton

public java.util.HashMap<java.lang.Integer,java.util.ArrayList<Run>> getActiveRunsByPartiton()
Returns:
the activeRunsByPartiton

setActiveRunsByPartiton

public void setActiveRunsByPartiton(java.util.HashMap<java.lang.Integer,java.util.ArrayList<Run>> activeRunsByPartiton)
Parameters:
activeRunsByPartiton - the activeRunsByPartiton to set

getActiveRunsByPartition

public java.util.HashMap<java.lang.Integer,java.util.ArrayList<Run>> getActiveRunsByPartition()
Returns:
the activeRunsByPartition

setActiveRunsByPartition

public void setActiveRunsByPartition(java.util.HashMap<java.lang.Integer,java.util.ArrayList<Run>> activeRunsByPartition)
Parameters:
activeRunsByPartition - the activeRunsByPartition to set

getNegationEvents

public java.util.ArrayList<Event> getNegationEvents()
Returns:
the negationEvents

setNegationEvents

public void setNegationEvents(java.util.ArrayList<Event> negationEvents)
Parameters:
negationEvents - the negationEvents to set

getNegationEventsByPartition

public java.util.HashMap<java.lang.Integer,java.util.ArrayList<Event>> getNegationEventsByPartition()
Returns:
the negationEventsByPartition

setNegationEventsByPartition

public void setNegationEventsByPartition(java.util.HashMap<java.lang.Integer,java.util.ArrayList<Event>> negationEventsByPartition)
Parameters:
negationEventsByPartition - the negationEventsByPartition to set