local search-based pattern matching features in emf-incquery

12
Local Search-based Pattern Matching Features in EMF-IncQuery 2015. 07. 22. 1 Local 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

Upload: akos-horvath

Post on 13-Apr-2017

429 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Local search-based pattern matching features in EMF-IncQuery

1Local search-based pattern matching features in EMF-IncQuery

Local Search-basedPattern Matching Features in

EMF-IncQuery

2015. 07. 22.

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

Page 2: Local search-based pattern matching features in EMF-IncQuery

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"); }}

EMF metamodel of Java programs (part)

Instance model in EMF editor

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

Page 3: Local search-based pattern matching features in EMF-IncQuery

Pattern Matching Strategies

2015. 07. 22. 3Local 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, ...

Page 4: Local search-based pattern matching features in EMF-IncQuery

Local-search Based Pattern Matching

2015. 07. 22. 4Local search-based pattern matching features in EMF-IncQuery

Normal Method

StringLiteral

IdentifierMethod

Invocation

invokes

operand

argument

1

2

3 5 6

7 8

4

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 Literal87654321

name: “equals”

Page 5: Local search-based pattern matching features in EMF-IncQuery

EMF-IncQuery

2015. 07. 22. 5Local 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

Page 6: Local search-based pattern matching features in EMF-IncQuery

Local Search Runtime

2015. 07. 22. 6Local search-based pattern matching features in EMF-IncQuery

IncQuery Engine

Model

Local search backend

Rete backend

Planner Matcher

Graph patterns

Pattern matches

• Calculates matches• Manages model indexes

Default (incremental) query executor

• Initializes search plans• Reuses pre-populated

model indexes• Executes search plans• Based on depth-first

search

Page 7: Local search-based pattern matching features in EMF-IncQuery

EMF-IncQuery IDE

2015. 07. 22. 7Local search-based pattern matching features in EMF-IncQuery

Query Editor

Defines graph patterns

Model Editor

EMF-based editor

Query Explorer

Displays query results

Page 8: Local search-based pattern matching features in EMF-IncQuery

Local Search Debugger

2015. 07. 22. 8Local 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

Page 9: Local search-based pattern matching features in EMF-IncQuery

DEMO

2015. 07. 22. 9Local search-based pattern matching features in EMF-IncQuery

Page 10: Local search-based pattern matching features in EMF-IncQuery

Performance Characteristics – 1.

2015. 07. 22. 10Local search-based pattern matching features in EMF-IncQuery

1000 10000 1000001

10

100

LS LS INC INCLS (100) LS (100) INC (100) INC (100)

Program Size (LOC)

Sear

ch T

ime

(s)

Incremental approach is beneficial in case of re-evaluation

Page 11: Local search-based pattern matching features in EMF-IncQuery

Performance Characteristics – 2.

2015. 07. 22. 11Local search-based pattern matching features in EMF-IncQuery

1000 10000 100000 1000000 1000000010

100

1000

10000

100000

LS LS INC INC

Program Size (LOC)

Mem

ory

Usag

e (M

B)

Local search works uses less memory

Page 12: Local search-based pattern matching features in EMF-IncQuery

12Local search-based pattern matching features in EMF-IncQuery

SummaryLocal search based pattern matcher• Alternative execution strategy• Reuses existing infrastructureSearch Plan Debugger• Step-by-step execution of search plans• Complements Query ExplorerFuture plans• Enhanced search plan generation• Hybrid pattern matching

2015. 07. 22.