Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Event Language

The Event Language

Rule Based Complex-Event Processing on Distributed Networks

Andreas Pfohl

June 09, 2015
Tweet

More Decks by Andreas Pfohl

Other Decks in Research

Transcript

  1. The Event Language Rule Based Complex-Event Processing on Distributed Networks

    Andreas Pfohl and Robert Heumüller June, 9th 2015 1
  2. Challenges • High-level language • Runs on different architectures •

    Compiled and Just-in-Time-Compiled • Means of distribution 3
  3. Event Processing event PositionEvent { time = [0], pos =

    [1] } pos_a; event PositionEvent { time = [2], pos = [6] } pos_b; + event VelocityEvent { v = [2.5] } velocity; 4
  4. Vector Calculation • Vectors for information • Vector Calculator •

    Collections Library 5 event PositionEvent { time = [0], pos = [1] } pos_a; f = 1.123; v = [1, 2, f]; s = 3 * v; u = v + s;
  5. Event Language 6 Event Definition: event TimedEvent { time };

    event PositionEvent extends TimedEvent { position }; event VelocityEvent { velocity };
  6. Event Language 7 Function Definition: VelocityEvent calculateVelocity(PositionEvent posEv1, PositionEvent posEv2)

    := { velocity = (posEv2.time - posEv1.time)^(-1) * (posEv2.position - posEv1.position) };
  7. Event Language 8 Predicate Definition: predicate positionCheck(PositionEvent posEv1, PositionEvent posEv2)

    := posEv2.position > posEv1.position; predicate timeCheck(PositionEvent posEv1, PositionEvent posEv2) := posEv2.time > posEv1.time;
  8. Event Language 10 event TimedEvent { time }; event PositionEvent

    extends TimedEvent { position }; event VelocityEvent { velocity }; VelocityEvent calculateVelocity(PositionEvent posEv1, PositionEvent posEv2) := { velocity = (posEv2.time - posEv1.time)^(-1) * (posEv2.position - posEv1.position) }; predicate positionCheck(PositionEvent posEv1, PositionEvent posEv2) := posEv2.position > posEv1.position; predicate timeCheck(PositionEvent posEv1, PositionEvent posEv2) := posEv2.time > posEv1.time; VelocityRule: [PositionEvent, PositionEvent : positionCheck, timeCheck] -> calculateVelocity;
  9. Challenges • High-level language • Runs on different architectures •

    Compiled and Just-in-Time-Compiled • Means of distribution 11
  10. LLVM • Formerly Low Level Virtual Machine • Compiler Infrastructure

    • Compiled and JIT • Different Target Architectures 12
  11. Challenges • High-level language • Runs on different architectures •

    Compiled and Just-in-Time-Compiled • Means of distribution 13
  12. Challenges • High-level language • Runs on different architectures •

    Compiled and Just-in-Time-Compiled • Means of distribution 14
  13. Challenges • High-level language • Runs on different architectures •

    Compiled and Just-in-Time-Compiled • Means of distribution 15
  14. Lexer / Parser Toolchains: • Lex / Yacc • Flex

    / Bison • Antlr • … 18 Jobs: • Parse Language • Build AST Flex / Lemon
  15. Lemon • Context Free • LALR(1) Parser • Robust Syntax

    • Error Handling • LibCollect AST 19 rule_declaration(NODE) ::= TYPE(T) COLON rule_signature(RS) RARROW IDENTIFIER(I). { struct payload *payload = malloc(sizeof(struct payload)); payload->type = N_RULE_DECLARATION; payload->alternative = ALT_RULE_SIGNATURE; payload->rule_declaration.name = strdup(T); payload->rule_declaration.identifier = strdup(I); NODE = tree_create_node(payload, 1, RS); }
  16. Validation • Parser: Syntactic Validity • Validation: Semantic Validity •

    Check: • References Resolved • Type Constraints 22 Unexpected Behavior Invalid Input
  17. Code Generation Tasks: • For each event: • Structure definition

    • For each Predicate / Function: • Function • For each Rule: • Activation Function • Processing Function 24 Options: • C • “Highlevel” • Complex • No JIT • Assembler • Lowlevel • Less Complex • Plattform Specific LLVM is Middle Ground
  18. LLVM-IR 26 %PositionEvent = type <{ i16, double*, i16, double*

    }> %VelocityEvent = type <{ i16, double* }> define %VelocityEvent* @VelocityRule_function(%PositionEvent*, %PositionEvent*) {
 %3 = call %VelocityEvent* @calculateVelocity(%PositionEvent* %0, %PositionEvent* %1) ret %VelocityEvent* %3 } define %VelocityEvent* @calculateVelocity(%PositionEvent*, %PositionEvent*) { %3 = alloca %VelocityEvent*
 %malloccall = tail call i8* @malloc(i32 ptrtoint (%VelocityEvent* getelementptr (%VelocityEvent* null, i32 1) to i32)) %4 = bitcast i8* %malloccall to %VelocityEvent* %5 = getelementptr inbounds %VelocityEvent* %4, i32 0, i32 0
 %6 = alloca double
 %7 = alloca <{ i16, double* }>
 %8 = getelementptr inbounds <{ i16, double*
  19. Conclusion • Rule-Based language for Event-Processing • Created complete compiler

    toolchain • Knowledge about compiler construction • Improved low level programming and understanding 27