Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Die The Rule-Engine stellt die Basis-Technologien für die regelbasierte Verarbeitung einiger Komponenten bereit.
Diese wird unter anderem von der Rewrite-Komponente und der Transformations-Komponente verwendetprovides basic concepts for a rule-based processing for other compoents. For instance, it is used during rewriting and transformation of queries.

Components and semantics

...

The rule engine consists of a two-stage hierarchy: First, there is a list of RuleFlowGroups and, secondly, each RuleFlowGroup has a set of Rules.

RuleFlowGroup

Die Rule-Engine ermöglicht es Gruppen zu definieren, die als RuleFlowGroup bezeichnet werden. Jede Regel wird einer dieser Gruppen zugeordnet.
Die Engine führt dann jede Gruppe hintereinander aus. Aus diesem Grund gibt es eine feste Ordnung aller Gruppe. Dabei darf jedoch eine Gruppe mehrmals innerhalb dieser Liste vorkommen.

Bei der Ausführung einer RuleFlowGroup wird jede Regel innerhalb einer Gruppe getestet, ob sie ausgeführt werden kann. Dabei gibt es folgende zwei Möglichkeiten:

  • Wenn keine ausgeführt werden konnte, dann ist die RuleFlowGroup beendet und die nächste RuleFlowGroup wird gestartet.
  • Wurde eine Regel innerhalb einer RuleFlowGroup ausgeführt, wird der aktuelle Durchgang der RuleFlowGroup abgebrochen und die gesamte RuleFlowGroup von vorne wiederholt. Das heißt, dass auch Regeln erneut geprüft werden, die ggf. vorher noch nicht ausführbar waren.

Rules

Jede Regel ist einer RuleFlowGroup zugeordnet.
Bei einem Durchlauf der RuleFlowGroup wird folgendes für jede Regel in der RuleFlowGroup gemacht:

  • zunächst geprüft, ob der generische Typ der Regel einem Objekt im Working Memory entspricht.
  • Entspricht ein Objekt dem generischen Typ
    • Nein: Prüfe das nächste Objekt im Working Memory
    • Ja: führe die Methode isExecutable der Regel mit dem Objekt aus
  • Ist isExecutable nicht gegeben, dann breche ab und prüfe das nächste Objekt aus dem Working Memory
  • Ist isExecutable wahr, dann rufe execute aus
  • Wie oben beschrieben wird danach die RuleFlowGroup neugestartet.

...

The rule enginge allows to create groups of rules, which are named RuleFlowGroups. Each Rule has to be assigned to such a group. The rule engine runs one group after another group. Therefore, each instance of the rule engine (e.g. the one for the transformation) has a fixed ordered list for this groups . However, a rule group may occur more than one in this ordered list.

If the rule engine is executed, it runs each group in succession. For each rule flow group, each rule of this group is tested if it is executable. Therefore, there are two possibilities:

  • If none of the rules of the current rule flow group was executed, the rule flow group is finished and the next rule flow group is started
  • If at least one of the rules of the current group was executed, the current run of the grouped is discontinued and the whole group is started from the beginning. This means, rules that were not executable before are tested again.

Rules

Each rules belongs to a RuleFlowGroup. Furthermore, each rule is responsible for a dedicated type, which is defined by a generic within the rule (this might be, for example, a certain operator).

For each run of a RuleFlowGroup, the following steps are performed for each rule of the group:

  • It is checked, if one of the objects in the working memory fits to the dedicated type of the rule
    • If it does not match the type: check the next object in the working memory
    • If it matches the type: run the isExecutable method
      • if isExecutable returns false, break and run the rule for the next object in the working memory
      • if isExecutable returns true, run execute and (like it is written above) the RuleFlowGroup is restarted.