DEX: Seminar Tutorial

18,191 views

Published on

Take an expanded view of the DEX API and examples of how to use it with this Tutorial froma Seminar of DEX.

Published in: Technology, Education
  • Be the first to comment

DEX: Seminar Tutorial

  1. 1. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com DEX Seminar Tutorial 27 / October / 2010
  2. 2. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com DEX API  Java library: jdex.jar  public API  Native library • Linux: libjdex.so • Windows: jdex.dll  System requirements:  Java Runtime Environment, v1.5 or higher.  Operative system: • Windows – 32 bits • Linux – 32 and 64 bits
  3. 3. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Basic Concepts  Persistent and temporary graph management library.  Data model: Typed and attributed directed multigraph.  Node and edge instances belong to a type.  Node and edge instances have attribute values.  Edge can be directed or undirected.  Multiple edges between two nodes.  Use of identifiers.  Object (node and edge) identifiers: long  Attribute identifiers: long  Type identifiers: int
  4. 4. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Core API – Class Diagram DEX GraphPool1 N DbGraph1 1 RGraph 1 N Graph Graph factory Persistent DB Temporary Objects 1 N
  5. 5. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Core API – Main Methods DEX open(filename)  GraphPool create(filename)  GraphPool close() GraphPool getDbGraph()  DbGraph newGraph()  Rgraph flush() close() Graph newNodeType(name)  int newEdgeType(name)  int newNode(type)  long newEdge(type)  long newAttribute(type, name)  long setAttribute(oid, attr, value) getAttribute(oid, attr)  value select(type)  Objects select(attr, op, value)  Objects explode(oid, type)  Objects Objects.Iterator hasNext()  boolean next()  long Objects add(long) exists(long) copy(objs) union(objs) Intersection(objs) difference(objs)
  6. 6. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Running Example DEX dex = new DEX(); GraphPool gpool = dex.create(“C:/image.dex”); … … gpool.close(); dex.close();
  7. 7. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Running Example … DbGraph dbg = gpool.getDbGraph(); int person = dbg.newNodeType(“PERSON”); long name = dbg.newAttribute(person, “NAME”, STRING); long age= dbg.newAttribute(person, “AGE”, INT); long p1 = dbg.newNode(person); dbg.setAttribute(p1, name, “JOHN”); dbg.setAttribute(p1, age, 18); long p2 = dbg.newNode(person); dbg.setAttribute(p2, name, “KELLY”); long p3 = dbg.newNode(person); dbg.setAttribute(p3, name, “MARY”); … JOHN 18 KELLY MARY
  8. 8. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Running Example … int friend = dbg.newUndirectedEdgeType(“FRIEND”); int since = dbg.newAttribute(friend, “SINCE”, INT); long e1 = dbg.newEdge(p1, p2, friend); dbg.setAttribute(e1, since, 2000); long e2 = dbg.newEdge(p2, p3, friend); dbg.setAttribute(e2, since, 1995); … int loves = dbg.newEdgeType(“LOVES”); long e3 = dbg.newEdge(p1, p3, loves); … JOHN 18 KELLY MARY 2000 1995
  9. 9. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Running Example … int phones = dbg.newEdgeType(“PHONES”); int when = dbg.newAttribute(phones, “WHEN”, TIMESTAMP); long e4 = dbg.newEdge(p1, p3, phones); dbg.setAttribute(e4, when, 4pm); long e5 = dbg.newEdge(p1, p3, phones); dbg.setAttribute(e5, when, 5pm); long e6 = dbg.newEdge(p3, p2, phones); dbg.setAttribute(e6, when, 6pm); … JOHN 18 KELLY MARY 2000 1995 4pm 5pm 6pm
  10. 10. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Running Example … Objects persons = dbg.select(person); Objects.Iterator it = persons.iterator(); While (it.hasNext()) { long p = it.next(); String name = dbg.getAttribute(p, name); } it.close(); persons.close(); … 2000 1995 4pm 5pm 6pm JOHN 18 KELLY MARY
  11. 11. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Running Example … Objects objs1 = dbg.select(when, >=, 5pm); // objs1 = { e5, e6 } Objects objs2 = dbg.explode(p1, phones, OUT); // objs2 = { e4, e5 } Objects objs = objs1.intersection(objs2); // objs = { e5, e6 } ∩ { e4, e5 } = { e5 } … objs.close(); objs1.close(); objs2.close(); … JOHN 18 KELLY MARY 2000 1995 4pm 5pm 6pm
  12. 12. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Extension Modules  Extension Java Packages with higher-level features  Schema  Exploral  Input  Output  Visualization  Graph operations
  13. 13. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Schema Module  A high-level logical view of the graph structure  Encapsulates graph generation and maintenance  Definition of schemas through script files dbgraph WIKIPEDIA ( datasource WIKIPEDIA ( dataset TITLES ( ID int, NLC string, TITLE string ) dataset IMAGES ( ID int, NLC string, FILENAME string ) ) edge REFS ( NLC string, TYPE string ) // TITLES --> TITLES edge IMGS ( ) // TITLES --> IMAGES )
  14. 14. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Exploral Module  Framework for complex queries  Extracts data from the DbGraph to return multiple graph results  Multiple phases and tasks  Querying: selects objects and explodes relationships  Preparing: transforms and filters the candidate graphs  Mining: finds the graphs that match a condition  Browsing: prepares the result graph for the visualization tool A B
  15. 15. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Input Module  Loads data from external data sources  Automatically converts the input data to a DEX graph  Supported data formats:  Plain text files: CSV  XML files • Standard Java interface for XML processing  Relational databases • JDBC  RDF graphs
  16. 16. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Output Module  Automatically export DEX graphs to different graph file formats  GRAPHML • Standard XML-based graph representation format  Graphviz • Open source graph definition language
  17. 17. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com  Automatically generate Java Swing visualization components  Prefuse • A visualization framework for the Java programming language Visualization Module
  18. 18. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Graph Operations Module  Connected components  Clustering  Paths  Communities  Importance measures  Graph statistics  Graph transformations
  19. 19. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Application Architecture Presentation Network Application Logic Data Desktop application DEX Data Sources Graphs Java Swing Application Browser HTML + Javascript DEX Graphs Data Sources Query Servlet INTERNET Web application API DEX Load and Query API DEX
  20. 20. DEX:GraphDatabaseManagementSystem http://www.sparsity-technologies.com Pere Baleta Ferrer CEO pbaleta@sparsity-technologies.com Josep Lluís Larriba Pey Founder larri@sparsity-technologies.com SPARSITY-TECHNOLOGIES Jordi Girona, 1-3, Edifici K2M 08034 Barcelona info@sparsity-technologies.com http://www.sparsity-technologies.com Thanks for your attention Any questions?

×