Local search-based pattern matching features in EMF-IncQuery

423 views

Published on

Graph patterns provide a declarative formalism to describe model queries used for several important engineering tasks, such as well-formedness constraint validation or model transformations. As different pattern matching approaches, such as local search or incremental evaluation, have different performance characteristics (smaller memory footprint vs. smaller runtime), a wider range of practical problems can be addressed. The current paper reports on a novel feature of the EMF-IncQuery framework supporting local search-based pattern matching strategy to complement the existing incremental pattern matching capabilities. The reuse of the existing pattern language and query development environment of EMF-IncQuery enables to select the most appropriate strategy separately for each pattern without any modifications to the definitions of existing patterns. Furthermore, a graphical debugger component is introduced that visualizes the execution of the search process, helping to understand how complex patterns behave. This tool paper presents the new pattern matching feature from an end user’s view- point while the scientific details of the pattern matching strategy itself are omitted. The approach is illustrated on a case study of automated identification of anti-patterns over program models created from Java source code.

Published in: Science
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
423
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Local search-based pattern matching features in EMF-IncQuery

  1. 1. Local Search-based Pattern Matching Features in EMF-IncQuery 2015. 07. 22. 1Local search-based pattern matching features in EMF-IncQuery Márton Búr, Zoltán Ujhelyi, Ákos Horváth, Dániel Varró Presenter: Ábel Hegedüs IncQuery Labs Ltd. Budapest University of Technology and Economics
  2. 2. Anti-pattern Detection in Java Programs 2015. 07. 22. 2Local search-based pattern matching features in EMF-IncQuery public class StringLiteralCompareTest { public StringLiteralCompareTest srcVar; @Override public boolean equals(Object other) { return super.equals(other); } public void test() { srcVar.equals("source"); } }
  3. 3. Anti-pattern Detection in Java Programs 2015. 07. 22. 3Local search-based pattern matching features in EMF-IncQuery public class StringLiteralCompareTest { public StringLiteralCompareTest srcVar; @Override public boolean equals(Object other) { return super.equals(other); } public void test() { srcVar.equals("source"); } } EMF metamodel of Java programs (part)
  4. 4. Anti-pattern Detection in Java Programs 2015. 07. 22. 4Local search-based pattern matching features in EMF-IncQuery public class StringLiteralCompareTest { public StringLiteralCompareTest srcVar; @Override public boolean equals(Object other) { return super.equals(other); } public void test() { srcVar.equals("source"); } } Instance model in EMF editor
  5. 5. Anti-pattern Detection in Java Programs 2015. 07. 22. 5Local search-based pattern matching features in EMF-IncQuery public class StringLiteralCompareTest { public StringLiteralCompareTest srcVar; @Override public boolean equals(Object other) { return super.equals(other); } public void test() { srcVar.equals("source"); } } String Literal as Compare Parameter (anti-pattern as graph pattern) inv: MethodInvocation name = “equals” m: NormalMethod arg: StringLiteral op: Literal invokes operand argument check count matches == 1 : Expression
  6. 6. Pattern Matching Strategies 2015. 07. 22. 6Local search-based pattern matching features in EMF-IncQuery Local Search • Executes a search plan • Lower memory requirements • Tools: ATL, GrGen.net, FUJABA, … Incremental • Maintains a cache structure • Efficient recalculation • Tools: EMF-IncQuery, Drools, ...
  7. 7. Local-search Based Pattern Matching 2015. 07. 22. 7Local search-based pattern matching features in EMF-IncQuery Find all m that m ∈ NormalMethod Attribute test: m.name=="equals” Find inv that inv.invokes → m Count of inv.argument → arg is 1 Find arg that inv.argument → arg Instance test: arg is a StringLiteral Find op that inv.operand → op NEG: op is not a Literal8 7 6 5 4 3 2 1
  8. 8. Local-search Based Pattern Matching 2015. 07. 22. 8Local search-based pattern matching features in EMF-IncQuery Normal Method 1 Find all m that m ∈ NormalMethod Attribute test: m.name=="equals” Find inv that inv.invokes → m Count of inv.argument → arg is 1 Find arg that inv.argument → arg Instance test: arg is a StringLiteral Find op that inv.operand → op NEG: op is not a Literal8 7 6 5 4 3 2 1
  9. 9. Local-search Based Pattern Matching 2015. 07. 22. 9Local search-based pattern matching features in EMF-IncQuery Normal Method 1 2 Find all m that m ∈ NormalMethod Attribute test: m.name=="equals” Find inv that inv.invokes → m Count of inv.argument → arg is 1 Find arg that inv.argument → arg Instance test: arg is a StringLiteral Find op that inv.operand → op NEG: op is not a Literal8 7 6 5 4 3 2 1 name: “equals”
  10. 10. Local-search Based Pattern Matching 2015. 07. 22. 10Local search-based pattern matching features in EMF-IncQuery Normal Method Method Invocation invokes 1 2 3 Find all m that m ∈ NormalMethod Attribute test: m.name=="equals” Find inv that inv.invokes → m Count of inv.argument → arg is 1 Find arg that inv.argument → arg Instance test: arg is a StringLiteral Find op that inv.operand → op NEG: op is not a Literal8 7 6 5 4 3 2 1 name: “equals”
  11. 11. Local-search Based Pattern Matching 2015. 07. 22. 11Local search-based pattern matching features in EMF-IncQuery Normal Method StringLiteral Method Invocation invokes 1 2 3 6 Find all m that m ∈ NormalMethod Attribute test: m.name=="equals” Find inv that inv.invokes → m Count of inv.argument → arg is 1 Find arg that inv.argument → arg Instance test: arg is a StringLiteral Find op that inv.operand → op NEG: op is not a Literal8 7 6 5 4 3 2 1 name: “equals”
  12. 12. Local-search Based Pattern Matching 2015. 07. 22. 12Local search-based pattern matching features in EMF-IncQuery Normal Method StringLiteral Identifier Method Invocation invokes 1 2 3 6 8 Find all m that m ∈ NormalMethod Attribute test: m.name=="equals” Find inv that inv.invokes → m Count of inv.argument → arg is 1 Find arg that inv.argument → arg Instance test: arg is a StringLiteral Find op that inv.operand → op NEG: op is not a Literal8 7 6 5 4 3 2 1 name: “equals”
  13. 13. EMF-IncQuery 2015. 07. 22. 13Local search-based pattern matching features in EMF-IncQuery Runtime Incremental queries using Rete backend Local search backend IDE Language Code generator Development tools Query Explorer Local Search Debugger
  14. 14. Local Search Runtime 2015. 07. 22. 14Local search-based pattern matching features in EMF-IncQuery IncQuery Engine Model Graph patterns
  15. 15. Local Search Runtime 2015. 07. 22. 15Local search-based pattern matching features in EMF-IncQuery IncQuery Engine Model Graph patterns • Calculates matches • Manages model indexes
  16. 16. Local Search Runtime 2015. 07. 22. 16Local search-based pattern matching features in EMF-IncQuery IncQuery Engine Model Rete backend Graph patterns
  17. 17. Local Search Runtime 2015. 07. 22. 17Local search-based pattern matching features in EMF-IncQuery IncQuery Engine Model Rete backend Graph patterns Default (incremental) query executor
  18. 18. Local Search Runtime 2015. 07. 22. 18Local search-based pattern matching features in EMF-IncQuery IncQuery Engine Model Rete backend Graph patterns Pattern matches
  19. 19. Local Search Runtime 2015. 07. 22. 19Local search-based pattern matching features in EMF-IncQuery IncQuery Engine Model Local search backend Planner Graph patterns Pattern matches • Initializes search plans • Reuses pre-populated model indexes
  20. 20. Local Search Runtime 2015. 07. 22. 20Local search-based pattern matching features in EMF-IncQuery IncQuery Engine Model Local search backend Planner Matcher Graph patterns Pattern matches • Executes search plans • Based on depth-first search
  21. 21. EMF-IncQuery IDE 2015. 07. 22. 21Local search-based pattern matching features in EMF-IncQuery
  22. 22. EMF-IncQuery IDE 2015. 07. 22. 22Local search-based pattern matching features in EMF-IncQuery Query Editor Defines graph patterns Model Editor EMF-based editor Query Explorer Displays query results
  23. 23. Local Search Debugger 2015. 07. 22. 23Local search-based pattern matching features in EMF-IncQuery Step-by-step execution of search plans • Visualizes search plans • Visualizes (partial) query results
  24. 24. Local Search Debugger 2015. 07. 22. 24Local search-based pattern matching features in EMF-IncQuery Step-by-step execution of search plans • Visualizes search plans • Visualizes (partial) query results Local Search Debugger • Based on local search • Visualizes query structure • Step-by-step execution Query Explorer • Relies on incremental query evaluation • Reacts on model changes • Results can be filtered
  25. 25. DEMO 2015. 07. 22. 25Local search-based pattern matching features in EMF-IncQuery
  26. 26. Performance Characteristics – 1. 2015. 07. 22. 26Local search-based pattern matching features in EMF-IncQuery 1 10 100 1000 10000 100000 SEARCHTIME(S) PROGRAM SIZE (LOC) LS INC LS (100) INC (100) LS INC LS (100) INC (100) Incremental approach is beneficial in case of re-evaluation
  27. 27. Performance Characteristics – 2. 2015. 07. 22. 27Local search-based pattern matching features in EMF-IncQuery 1 10 100 1000 10000 100000 1000 10000 100000 1000000 10000000 MEMORYUSAGE(MB) PROGRAM SIZE (LOC) LS INC LS INC Local search works uses less memory
  28. 28. Summary Local search based pattern matcher • Alternative execution strategy • Reuses existing infrastructure Search Plan Debugger • Step-by-step execution of search plans • Complements Query Explorer Future plans • Enhanced search plan generation • Hybrid pattern matching 2015. 07. 22. 28Local search-based pattern matching features in EMF-IncQuery

×