Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JDD2014: Using ASCII art to analyzeyour source code with NEO4J and OSS tools - Michael Hunger

419 views

Published on

If you ever looked at compiler’s AST’s, module dependencies and call graphs you’ve long realized that all the stuff we write is actually easily representable as a graph.
Some years ago I had the idea to pull the essence of Java Projects into the graph to have some fun. Nowadays there are several tools which help me do that and
I can wield the power of Ascii-Art to query these interesting structures.
Join me for a peek into the JDK that you might not have ever done before. I’ll also show some OSS tools that help you with quickly getting started gaining insights.
I’ll talk about some cool applications that use this approach to gain insights that they were not easily able to otherwise.

Published in: Technology
  • Be the first to comment

JDD2014: Using ASCII art to analyzeyour source code with NEO4J and OSS tools - Michael Hunger

  1. 1. Using AsciiArt to Analyse your SourceCode with Neo4j and OSS Tools
  2. 2. _ l! Içurfgfl; IVho **che hell Is *thls guv? J a Michael Hunger a Developer Advocate Neo Technology a Love People and Graphs * @mesirii |
  3. 3. _ l! Iaçrfgfl. ? IVl1a't il/ IH h e 'tselk eeboLrt?
  4. 4. a? w "a IVl1a't ii/ lil he 'tselk eeboLrt? > i What is this Neo4j Graphdatabase thing?
  5. 5. a? w "a IVl1a't fi/ lil he 'tselk eeboLrt? > i What is this Neo4j Graphdatabase thing? i Ascii-Art Rocks
  6. 6. _ l! Içurfgfi. ? IVl1a't fi/ lil he 'tselk eeboLrt? > i What is this Neo4j Graphdatabase thing? i Ascii-Art Rocks i Graphs in Your Code - The Idea
  7. 7. _ l! lanai? IVI1a't ii/ III he 'tesik eeboLrt? > i What is this Neo4j Graphdatabase thing? i Ascii-Art Rocks i Graphs in Your Code - The Idea i* Having Fun with your Code and jQAssistant
  8. 8. _ l! lanai? IVI1a't ii/ III he 'tesik eeboLrt? > i What is this Neo4j Graphdatabase thing? i Ascii-Art Rocks i Graphs in Your Code - The Idea i* Having Fun with your Code and jQAssistant i* Gimme More
  9. 9. _ lemorai. ? IiIha't is ph base 7 *i
  10. 10. _ lemorai. ? IiIha't is ph base 7 > i Iabeled Nodes
  11. 11. What is a Graph Database ? o Iabeled Nodes 0 directed, typed Relationships IJ a, , m
  12. 12. What is a Graph Database 7 o Iabeled Nodes 0 directed, typed Relationships o arbitrary Properties on each IJ ag, , m
  13. 13. lllln Imam . .Puncmseo m, , . an SW dale:0302-20|1 PURCHASED dale:09-09-20|| PURCHASED dnle:05-07-201| I I ~ II' name Alan IH HJVJWA Ou' MAI! © All Rights Reserved ZOM i Neo Technology, Inc 5 s" 47
  14. 14. _ l! lanai. ? fi/ hat* makrss it sgaecival 7 A*
  15. 15. a? w "a fi/ hat* makrss it sgaecival 7 > i close to the object model
  16. 16. _ l! lanai? fi/ hat* makrss it siaecival 7 > i close to the object model i prematerialize relationships
  17. 17. a? w "a fi/ hat* makrss it siaecival 7 > i close to the object model i prematerialize relationships i traversals in linear time
  18. 18. a? w "a fi/ hat* makrss it siaecival 7 > i close to the object model i prematerialize relationships i traversals in linear time i* sparse, heterogenous data + schema free
  19. 19. a? w "a fi/ hat* makrss it siaecival 7 > i close to the object model i prematerialize relationships i traversals in linear time i* sparse, heterogenous data + schema free i* local queries - explore the neighbourhood
  20. 20. a? w "a fi/ hat* makrss it siaecival 7 > i close to the object model i prematerialize relationships i traversals in linear time i* sparse, heterogenous data + schema free i* local queries - explore the neighbourhood i whiteboard-friendly
  21. 21. a? w "a ii/ here can/ shouid i use it > i Impact Analysis (Network, Software) i Routing/ Logistics i Recommendation, Dating, Job-Search i* Sciene (Metadata, Drug Research) i* Masterdata, Hierarchy-Mgmt i Fraud-Detection, Market-Analysis i Social, and many more
  22. 22. Ivy-H* q l! lanai - u K _ gm I/ rg _a I . .` Ch ", ` L/ QD "4 CCU f`<~ r x i ' R P i I p. r X' __ V ` w C `° l a) T 'I I L v' i? f I I " I C L/ b - a GUI( v "HKQ j j x l V* _ a' ? i -Iilnplv ui-: I »s ': =*I`~i. r . ` Jak) HPE-lgi H`| '~F, `A}fs{ . t l / rx ' r( i ' / NlQc/ Tea'
  23. 23. wr _' i ` [Haram Hugo Weavinç ACTED_IN ACTED_IN ACTED_IN IThe Matrix Cloud Atlas M DIRECTE Lana Wachowski DIRECTED
  24. 24. wr _' i ` [Hanim Hugo Weañinç ACTED_IN ACTED_IN ACTED_IN IThe Matrix Cloud Atlas y DIRECTE Lana Wachowski DIRECTED
  25. 25. E23!! name: Tom Hanks nationality: USA won: Oscar, Emmy nationality: Austra won: MTV Movie Awai ACTED IN role: Bill-Smoke ACTED_I ACTED IN role: Agent 1 role: Zazhry IEEE title: Cloud Atlas genre: drama, sci-fi title: The Matri genre: sci-fi DIRECTED E933 name: Lana Wachowski nationality: USA won: Razzie, Hugo DIRECTED
  26. 26. ,Asciinélrt Rocks > _ lñlaorai. ?
  27. 27. ,Asciinélrt Rocks ° _ l! lanai? i Turn text into pictures
  28. 28. ,Asciinélrt Rocks ° _ l! lanai? i Turn text into pictures i Turn picture into text
  29. 29. ,Asciinélrt Rocks t: _ l! lanai? i Turn text into pictures i Turn picture into text i The Power of Symbols
  30. 30. ,Asciinélrt Rocks ° _ l! lanai? i Turn text into pictures i Turn picture into text i The Power of Symbols i* Graph Patterns Made easy
  31. 31. ,Asciinélrt Rocks ° _ l! lanai? i Turn text into pictures i Turn picture into text i The Power of Symbols i* Graph Patterns Made easy i* Hacker and Mudder Friendly
  32. 32. _ l! lanai? , Asciinélrt Rocks ° i Turn text into pictures i Turn picture into text i The Power of Symbols i* Graph Patterns Made easy i* Hacker and Mudder Friendly i Diffs, VCS
  33. 33. Ascii-Art Rocks _ > (( )> ( (@) / I ))_(( / I _ | -|` / I (/ I/ ) / I (@) | | ----------------- --/ --| -voV---`| '/--Vov-| -- ------------------- --| -| - '^` (o o) '^` I | `Y/ ' welcome to the Mages Lair Multiple User Dungeon welcome to the Addiction. | | | | | I | I | | | | | | ( ) 6 1 / x/ (( x/ x 1 *x 1 / v v 1 @ 1/ I
  34. 34. w a w l! la! Q
  35. 35. ,Ir I I`, _u I J phe@F[USE (f) T r I. ll l" I I H -Illx II`IQAS Cl 'Fian
  36. 36. t-yphe@F[USE Ip* (f) I'm3. Declarative Graph Query Language ' _I . .-. _I-"I"""llrQ. u
  37. 37. lemorai. ? I ” ' ' " . ' m" ' (fyp Ir e r) [ 1 LI S E Sl-wgrr-xsci iz-. rti i i Declarative Graph Query Language i Graph Pattern Matching
  38. 38. t-yphe@F[USE Ip* (f) r g ? I ? T I I T T? Glllx _I -riir. '-*, scii A u i Declarative Graph Query Language i Graph Pattern Matching i Humane, Readable
  39. 39. t-yphe@F[USE Ip* (f) r g ? I ? T I I T T? Glllx _I -riir. '-*, scii A u i Declarative Graph Query Language i Graph Pattern Matching i Humane, Readable i* Expressive
  40. 40. t-yphe@F[USE Ip* (f) r g ? I ? T I I T T? Glllx _I -riir. '-*, scii A u i Declarative Graph Query Language i Graph Pattern Matching i Humane, Readable i* Expressive i* Read and Write Graphs
  41. 41. t-yphe@F[USE Ip* (f) r g ? I ? T I I T T? Glllx _I -riir. '-*, scii A u i Declarative Graph Query Language i Graph Pattern Matching i Humane, Readable i* Expressive i* Read and Write Graphs i Tabular Results
  42. 42. ?"(__)Neo4j @IAYIllllililsiilauanuailllllllBlanñlsuiul-ll-myilnlc '4-**7
  43. 43. @Hal| Illkliltiktaianuac-HUIEIINanñlsuiiui-ll-mydlnic igçNeolijij
  44. 44. _ ljlaorali i7“Z)Ii3 her jama'i' Exezmple eeko ut
  45. 45. Cypher Query - Example Geeko Setup . CREATE (: Year {year:2014})<-[: IN_YEAR]-(geekoutzconference {name: "Geekout"H L -[: LOCATION]->(: City {name: "Tal1inn"H CREATE (track: Track {name: "Room 1"))-[: TRACK_OF]->(geekout) ' MERGE (speaker: Attendee: Speaker {name: "Hadi Hariri")) MERGE (geekout)<-[: ATTENDS]-(speaker) T CREATE (speaker)-[: PRESENTS]->(session: Session {title: "Mouseless IDE"})<-[: IN_TRACK]-(track) FOREACH (name in ["Java", "IDE", "Development"] | LC MERGE (topic: Topic (name: name}) la CREATE (session)-[: HAS_TOPIC]->(topic))) © All Rggliis Reaeixed ; im I Neo ramia ag, , Inc | 8 r” 47
  46. 46. Cypher Query - Example Geeko Setup CREATE (: Year (year:2014})<-[: IN_YEAR]-(geekoutzconference {name: "Geekout"H -[: LOCATION]->(: City {name: “Tal1inn"H CREATE (track: Track (name: "Room l"))-[: TRACK_OF]->(geekout) IILJ* -l f MERGE (speaker: Attendee: Speaker {name: "Hadi Hariri")) MERGE (geekout)<-[: ATTENDS]-(speaker) T CREATE (speaker)-[: PRESENTs]->(session: Session {title: "Mouseless IDE"})<-[: IN_TRACK]-(track) [i 3 FOREACH (name in ["Java", "IDE", "Development"] | LC MERGE (topic: Topic {name: name}) la CREATE (session)-[: HAS_TOPIC]->(topic))) Query / / Which Speakers entertain you with Java ? MATCH (t: Topic (name: "Java"})<-[: HAs_TOPIC]-(session)<-[: PRESENTSJ-(speaker), (session)<-[: IN_TRACK]-(track) 'iuatipi RETURN speaker. name as speaker, {time: session. time, session: session. title} as session, track. name as track 7 ORDER BY session. time © All agri-r Reserved LCIII I Neo Tema ag, , I'm | 8 r" 47
  47. 47. IJ Ian! : 1 ~ "All Let me graph that for you: Geekout 2014 What bdhnr way lo show what I ; rmh dinding is good at, is to : how how i! huh: you la cannot people, salsions, topics, limo and mon. nunyxannquqnnuumumnmnnnmu. " I I H : u. t {q: -nas, mvc: -rau q? __pnzssm. j_ em ` mam 54% m, , "bu b, q, _m_rom- m. .. , 4-4?"'E“'“5' Pin **Prime I , wahh 4 - V r uang unsssmshmm-? Anmip l 5 z W w m, «, ` J” u: ^° 3979! °" Rum / g Ko# | w Mnun -. x g; y. . , f' t”, wm/ ”War DN f? l , oc/ x, * , m 2 l @a: 0 . y* w +- "M x. T" . f ”s” * 3 ' m' , H *Mioma Muaro ñ l/ s. , _` mmm . ..ñ V i I »um Which Speakers : Mamin yun with Java ? hany! " WH h r* . , m s; .u . w. E ' umum: n Inna udan ? w NNIPUM IMU'| |.15'. JNCWII'MGAIBS DVPICIDOVEWOW) um. rm qmxuozao-. uumau-mummumnm-n t' _ un. . Llprvun (one'|5.5D'. snum. '1he usum anucz-annnqmmgqawmmmuyq _ f Interactive GraphGist Doçument WorlcLCup
  48. 48. f' K. nw: oftxrxna re , Aneelgrtwcs App rogaciw
  49. 49. SCTFIEVKLE re Aii1t2e|3rttcs . Ap p roiaciw l. look at one interesting aspect
  50. 50. Sio'i"'tvwa re Ai1çE2|y"L'iCS . i-xi) p roaclw l. |ool< at one interesting aspect 2. which insights would be cool?
  51. 51. Sio'i"'tvwa re Ai1çE2|y"L'iCS . i-xi) p roaclw l. |ool< at one interesting aspect 2. which insights would be cool? 3. model it as a graph
  52. 52. Sioftxrxna re Ai1çE2|y"L'iCS . f-xi) p roaclw l. |ool< at one interesting aspect 2. which insights would be cool? 3. model it as a graph 4. get data
  53. 53. Sioftxrxna re Ai1çE2|y"L'iCS . f-xi) p roaclw l. |ool< at one interesting aspect 2. which insights would be cool? 3. model it as a graph 4. get data 5. import into graph model
  54. 54. Sioftxrxna re An . szlgrtics . f-xi) p roaclw l. |ool< at one interesting aspect 2. which insights would be cool? 3. model it as a graph 4. get data 5. import into graph model 6. enrich graph model with concepts / structure
  55. 55. Sioftxrxna re An . szlgrtics . f-xi) p roaclw l. |ool< at one interesting aspect which insights would be cool? model it as a graph get data import into graph model enrich graph model with concepts / structure 510917590!” query for insights
  56. 56. (Code)-[I| S_A]->(Graph)
  57. 57. (Code)-[: IS_A]->(Graph) o AST, ByteCode, Source-Code
  58. 58. _ l! lanai. ? (TocEeHilS_, A.]->(~i3raph) i AST, ByteCode, Source-Code lnheritance, Composition, Dependencies
  59. 59. _ l! lanai. ? (TocEeHilS_, A.]->(~i3raph) > i AST, ByteCode, Source-Code i lnheritance, Composition, Dependencies i Transitive Module and Library dependencies
  60. 60. If I - " " r I ATI i . Za l: ~; i-oc: e)e[. lS_, A._I-><, ii. :raph) i i AST, ByteCode, Source-Code i lnheritance, Composition, Dependencies i Transitive Module and Library dependencies i* Dependency injection conñg
  61. 61. F* r" , Wifxfh (fodeHilS_, A._I->(~i: raph) i i AST, ByteCode, Source-Code i lnheritance, Composition, Dependencies i Transitive Module and Library dependencies i* Dependency injection conñg i* Data model (db) <-> object model
  62. 62. F* r" , Wifxfh (fodeHilS_, A._I->(~i: raph) i i AST, ByteCode, Source-Code i lnheritance, Composition, Dependencies i Transitive Module and Library dependencies i* Dependency injection conñg i* Data model (db) <-> object model i Runtime characteristics: call graph, heap
  63. 63. terangi-i (cacian: is_, e,; i-»: «3ramia) “ i AST, ByteCode, Source-Code i lnheritance, Composition, Dependencies i Transitive Module and Library dependencies i* Dependency injection conñg i* Data model (db) <-> object model i Runtime characteristics: call graph, heap i Version control, repositories, issues
  64. 64. jQAssista nt
  65. 65. _ 'T, _ _ ylñlaorfti. ? Jl , il-SSISIZEVYC i” Open Source Software Analytics Tool
  66. 66. a? w "a jfgixssista nt *i i Open Source Software Analytics Tool i Plugins forJava, JEE, JPA, Maven, Gradle, Sonarj
  67. 67. _ l! laçrffj. ? jfgixssista nt “i i Open Source Software Analytics Tool i Plugins forJava, JEE, JPA, Maven, Gradle, Sonarj i All Cypher based
  68. 68. a? w "a jfgixssista nt *i i Open Source Software Analytics Tool i Plugins forJava, JEE, JPA, Maven, Gradle, Sonarj i All Cypher based i* Technical and Domain Concept Deñnitions
  69. 69. a? w "a jfgixssista nt *i i Open Source Software Analytics Tool i Plugins forJava, JEE, JPA, Maven, Gradle, Sonarj i All Cypher based i* Technical and Domain Concept Deñnitions i* Compute Software Metrics
  70. 70. a? w "a jfgixssista nt *i i Open Source Software Analytics Tool i Plugins forJava, JEE, JPA, Maven, Gradle, Sonarj i All Cypher based i* Technical and Domain Concept Deñnitions i* Compute Software Metrics i Declare and Validate Architectural Rules
  71. 71. _ _ j : ljlaorfzfilé Ji: ,AssistaiTt “i i Open Source Software Analytics Tool i Plugins forJava, JEE, JPA, Maven, Gradle, Sonarj i All Cypher based i* Technical and Domain Concept Deñnitions i* Compute Software Metrics i Declare and Validate Architectural Rules i Integrated in Build Process
  72. 72. Actively Looking for Contributions [I] _ Ulangi. ?
  73. 73. &TI li ii n o u ricr-z -e Modeling Software Structures As A Graph public class Customer extends Person { private int number; public int getNumber() { return thismumber; RETURNS signaturezint number visibilitvzprivate fqn: int DECLARES I "Lt r, r: i r 't'_ "a " , j r. "` l ` ` `C~ 3 ` aj j j' ` “J” J- y. . a- buschmais Beratung Technologie Innovation fqnzcom. buschmais. mode| .Person EXTENDS fqn: com. buschmais. mode| .Customer visibilityzpublic
  74. 74. Java software graph model : oiiiNeoi/ *j o Artifact 0 Package o Type, Class, Interface, Annotation, Enum 0 Method, Constructor, Parameter 0 Field o Value, Class, Annotation, Enum, Primitive, Array
  75. 75. _ Ulangi. ? . iava so'f'txi“ira re graph motzielte i ftc-: isttioi1sltijss i* CONTAINS, DECLARES i EXTENDS, IMPLEMENTS i RETURNS, THROWS, INVOKES, HAS, lS i ANNOTATED_BY, OF_TYPE
  76. 76. _ lilaorfzi. ? Ap p roaclw *i
  77. 77. _ l! lanffj. ? Ap p roaclw “i l. Scan your project with Plugins for Code (Java-ASM), Config, Metadata
  78. 78. _ l! lanffj. ? Ap p roaclw “i l. Scan your project with Plugins for Code (Java-ASM), Config, Metadata 2. Import into Neo4j
  79. 79. _ l! lanffj. ? Ap p roaclw “i l. Scan your project with Plugins for Code (Java-ASM), Config, Metadata 2. Import into Neo4j 3. Enrich with declared technical and domain concepts
  80. 80. _ l! lanffj. ? Ap p roaclw l. Scan your project with Plugins for Code (Java-ASM), Config, Metadata 2. Import into Neo4j 3. Enrich with declared technical and domain concepts 4. On top of those concepts
  81. 81. Ap p ro c h @Hei/ UN Scan your project with Plugins for Code (Java-ASM), Config, Metadata Import into Neo4j Enrich with declared technical and domain concepts On top of those concepts Software-Metrics queries _ l! lanffj. ?
  82. 82. Ap p ro c h 0`*. U". -'>. WN Scan your project with Plugins for Code (Java-ASM), Config, Metadata Import into Neo4j Enrich with declared technical and domain concepts On top of those concepts Software-Metrics queries . Architectural-Rules queries _ l! lanffj. ?
  83. 83. Query the Data EXTEN DS Pattern matching is the core principle of Cypher! MATCH (c1:C1ass)-[: EXTENDS]->(c2:Type) RETURN c1.fqn, c2.fqn
  84. 84. Demo
  85. 85. ,i ~*'+i_iis: l)Izii*i lsyeri F= '-: *3ios*"iorv ji llluoraq Rickard Oberg This little nifty tool will allow you to import your local Maven repositoiy information into a Neo4j graph, in particular dependencies between aitifacts. You can then take this graph and put it into a Neo4j sen/ er, and perform Cypher queries on it. Or whatever else awesome you want to do. mvn compile exec: java -Dexec. mainC1ass= com. gtthub. rfckardoberg. neomvn. Main -Dexec. arguments= "$HOME/ .m2/repository" httpsz/ /githubcom/ rickardoberg/ neomvn#example-queries
  86. 86. _ l! lanfgj. ? N eo iviV N L : xa m p le i u e ri es
  87. 87. NeoMVN: Example Queries Find all transitive dependencies of all artifacts with "org. neo4j" groups 1 MATCH (group: Group {groupId: 'org. neo4j'}), (group) - l : HAS_ARTIFACT] -> (artifact) - [ : HAS_VERSION] -> (version) <- [ : HAS_DEPENDENCY] - (dependent) J 4 WHERE left(dependent. groupId,9)<>group. groupId F. RETURN DISTINCT dependenLartifactId, dependenLgroupId © All Rights Reserved ZOM j Neo Technologi, , Inc 3 l i' 47
  88. 88. NeoMVN: Example Queries Find all transitive dependencies of all artifacts with "org. neo4j" groups 1 MATCH (group: Group {qroupId: 'orq. neo4j'}), 2 (group) - l : HAS_ARTIFACT] -> (artifact) - [ : HAS_VERSION] -> (version) <- [ : HAS_DEPENDENCY] - (dependent) 1 4 WHERE left(dependent. groupId,9)<>group. groupId 5 RETURN DISTINCT dependent. artifactId, dependent. groupId Which version of JUnit is the most popular MATCH (group: Group {qroupId: 'junit'H MATCH (group)-[: HAS ARTIFACT]->(artifact)-[: HAS_VERSION]->(version)<-[: HAS_DEPENDENCY]-(dependent) RETURN version. versIon, count(dependent) as depcount ORDER BY depcount DESC . .ntu i`~J^-* © All &gm Reserved 20 l 4 j Neo Technology, Inc 3 I i' 47
  89. 89. uery a . iVivi iilea p c! u m p _ [Hanafi: . il s
  90. 90. _ l! lanffj. ? i* “UGEY a . iVivi iilea p c! u m p “i I i , a s l. Get a heap-dump with jmap jmap -dump: format= b,ñle= dump. hprof <pid>
  91. 91. _ l! lanffj. ? uery a . iVivi iilea p c! u m p “i l. Get a heap-dump with jmap jmap -dump: format= b,ñle= dump. hprof <pid> 2. Use jhat dumphprofñnd the / oql endpoint
  92. 92. _ l! lanffj. ? uery a . iVivi iilea p c! u m p “i l. Get a heap-dump with jmap jmap -dump: format= b,ñle= dump. hprof <pid> 2. Use jhat dumphprofñnd the / oql endpoint 3. run the OQL script to generate Cypher code
  93. 93. _ l! lanffj. ? uery a . iVivi iilea p c! u m p “i l. Get a heap-dump with jmap jmap -dump: format= b,ñle= dump. hprof <pid> 2. Use jhat dumphprofñnd the / oql endpoint 3. run the OQL script to generate Cypher code 4. import into Neo4j
  94. 94. 17'* uery a . iVivi ii: ea p c! u m p l. Get a heap-dump with jmap jmap -dump: format= b,ñle= dump. hprof <pid> Use jhat dumphprofñnd the / oql endpoint run the OQL script to generate Cypher code import into Neo4j @Hei/ UN Run arbitrary queries _ l! lanffj. ?
  95. 95. _ l! lanffj. ? uery a . iVivi iilea p c! u m p “i l. Get a heap-dump with jmap jmap -dump: format= b,ñle= dump. hprof <pid> Use jhat dumphprofñnd the / oql endpoint run the OQL script to generate Cypher code 2. 3. 4. import into Neo4j 5. Run arbitrary queries 6. Visualize
  96. 96. [Mandiri Uu I . .ii ph omiagrn iviior-: l * WrimbleTnnsacdonSnte WñtmbleTI-anncuonsuu T, LodtElsnent I LodtType l LodtManagerlmpl I RWLod: Melasgllmquired #releases #relaseWñteLodn tkelasewriteLoc-k i. i lawn Txkelener #akngxnplnion Ram, " , hmm Dem Badudu
  97. 97. QQL to Generate Cypher A select (function () ( n lL lilJlJiJ 1 4r4r~ »rere PiHi% % ur i , l i . : l) var entries = filter(p. waitingTxMap. data. table, function(it) ( return it; }); var resources = ""; var idseq = 0; for ( var i = O; i < entries. length; i++ ) { var resource = entries[i]. value. resource; var index = resource. index. toString(); var key = resource. key. toString(); var indexNameIndexKey = index + “_" + key; var indexName = "n" + idSeq++; var resourceName = ""; var tx : entries[i]. key; var txName = "n" + idSeq++; var Cypher = "MERGE (" + txName + ": Tx ltxldz" + tx. eventIdentifier + "))<br / >"; Cypher += "MERGE (" + indexName + ": IndexLock (indexLockId: '" + indexNameIndexKey + "'l)<bI Cypher += "CREATE (" + txName + ")-[: WAITING_ON]->(" + indexName + ")<br / >"; resources += Cypher + "<br / >"; return resources; O from org. neo4j. kernel. impl. transaction. RagManaqer p ci All kami. Re “P ed ; iziii j mat» Tetlwu ap, , I'll
  98. 98. .. C I”IsL! .3JI2A~. -'*= «“ron cf esadack Sc3 mw ; :a %a ; Node Tx o* di 5%* lndexLock y' **g 95' 39 ` . .r Mowsmcx on p* k y E `4o-°5"Sç( 10 _v a E : y ha, g s! ” **ank *ma* 4' oy WAITING , ON wmwqm 41,) "Wis Locx m é a” * " s" s* 5 3 q ` uv news LOCKON , 1% E *w V' q' a S a 9 ê s @km k
  99. 99. .lvlx/ i heap açnszlglsls using lxteoéi-J > Nat Pryce, James Richardson (Software Engineers, Sky) Use Neo4j for ad-hoc analysis of heap use in a proprietary embedded JVM that's deployed in one ofthe most widely used consumer products in the UK (Sky Box). Used Cypher queries that uncovered surprising aspects of their code, platform and the Java compiler. AA. A[`. T.i: |r`, 'Filfwliffig a. mñwettñcry' lceratlzfmg l? l l [y: 3.F“*'. T~3F” +`«_'F'~'ll'i. a Zyi: .me <: ~`F. F~3E”)'i- l
  100. 100. Heap Model Heart dumpname: String address: long mmm: : Il an array ol object references. elemanls appear as ñelds l! named '[0]', '[11', length: int Sting length: int value: String In& name: String relationships are static ñelds of the class From Nafs Gr | ingApprQach ti; ur'- Re; 7~`l l i ma» leclwu ap. . n;
  101. 101. Software Analytics & Evolution Analytics of (legacy) Software Systems for modemization, insight gathering, testing, architecture retrieval o Domain Knowledge Extraction o Software Architecture Analysis 0 Query Software Systems 0 Knowledge Driven Testing 0 Measure Software Systems o Domain Specific Programming SQfU/ vace CompetencevCenw Hagen imagezzhttpz/ /scchat/ ñ|es/ assets/ images/ scch-Iogo. gif[right] o All &gli-s Reseined ; cm i Neo Tetlwu ap, ,
  102. 102. terawat. ? . r; ' s' - p h ueryi n c: > ul
  103. 103. _ limonit. ; p h ueryi n c: > ul l Parsing of C, FORTRAN - source-code using Antlr
  104. 104. i c p h ~I u e ryi n c: mer] I ul l Parsing of C, FORTRAN - source-code using Antlr l Building ofa graph model
  105. 105. i c p h ~I u e wi n @r: C; ul l Parsing of C, FORTRAN - source-code using Antlr l Building ofa graph model l Allow for querying, software analytics, metrics, Visualization
  106. 106. _ ljlçiçrzgt re; p h i u e njt n c: u, l Parsing of C, FORTRAN - source-code using Antlr l Building ofa graph model l Allow for querying, software analytics, metrics, Visualization Quick Demo Demo
  107. 107. Putty Source Code -functions reading structures one last visu for @GraphConnect #ShowMeYourGraph putty source code functions reading structures, complexity + effort pic. twitter. com/ etN495kVkB - Wolfgang Beer (@wolfgangscch) October 1, 2014
  108. 108. Using graphs for source code analysis (PhD in Computer Science, The University of Cambridge) Did you know that the source code of software that you engineer every day can also be represented as graphs? In this talk, we demonstrate how you can perform program analysis using Neo4j. We describe a prototype that stores a graph representation of the source code of Java programs in Neo4j. We can then query the graph using Cypher and we'll show Various examples of possible queries such as "find me all recursive methods" and "ñnd me all subtypes ofa given type". This talk is based on Raoul-Gabrie| `s research paper E a E i . © All Rights Reserved ZOM i Neo Technologi. , Inc 4 i i' 47
  109. 109. Source Control, Issues, Social Coding 0 What can you learn from commits 0 about the code o Class To><icity, Frequency of Change (Feathers) o about the people o chec| <in times, collaboration, commit-size, commit-frequency o Issues m0 bug-rich classes (separation of concerns? )
  110. 110. _ terangi. ? Exa m izlei import iZErt Com mit i-o gs into N reoéi-i * git log --format emits CSV l Graph Model l LOAD CSV with Cypher l Create / Update complex Graph Structure Blogiost
  111. 111. q lilairflft ' “nu Visua; 17 ; tion l - (t MATCH patlirltuUst-i illsl"li'l"f`izlih ilcetlliaWH HAUTHORED] "iIEUW ti] lA. .3] »izmail RETURN palu Comm it User Day Month Year 'cv. _'__lll'~y liiil i
  112. 112. _ Ulangi& Finallyi Some Eye Candy > Isaac 8( Nash (Software Engineers at Leap Motion) Leap Motion Software lnheritance Hierarchy, Call Graph Render to . dot ñle * Use dotparse. js to read it in * WebGL enabled Three. js rendering LeapMotion SDK 2.>< beta Let's have a look: Demo Source
  113. 113. Questions ? Thank You!
  114. 114. Status of the presenation Cypher queries execution Done with errors. statement: CREATE (: Year {year:2014})<-[: IN_YEAR]-(geekoutrconference {name "Geekout"}) -[ LOCATION]->( City {name: "Ta11inn“}) CREATE (track: Track {name: “Room 1"})-[: TRACK_OF]->(geekout) MERGE (speaker: Attendee: Speaker {name: "Hadi Hariri"}) MERGE (geekout)<- [: ATTENDS]-(speaker) CREATE (speaker)-[: PRESENTS]->(session Session {tit1e: "Mouse1ess IDE"})<- [: IN_TRACK]-(track) FOREACH (name in [“Java", “IDE“, “Deve1opment"] | MERGE (topic: Topic {name name}) CREATE (session)-[: HAS_TOPIC]->(topic))) Message: Invalid input ')': expected whitespace, LOAD CSV, START, MATCH, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, RETURN, UNION, '; ' or end of input (line 11, © All Pi'i i : Za II rnrATr 47 l" 47 lL ---. '^. . r. LIAC' -rnnrr1 /4.^. ..*-II

×