laconic object query language using features of object
play

Laconic Object Query Language Using Features of Object Model V. - PowerPoint PPT Presentation

Laconic Object Query Language Using Features of Object Model V. Dimitrov Petrozavodsk State University Department of Computer Science V. Dimitrov LaOQL 14 may 2015 1 / 29 Object model SON Organizational Spatial AbstractOU Building 1 *


  1. Laconic Object Query Language Using Features of Object Model V. Dimitrov Petrozavodsk State University Department of Computer Science V. Dimitrov LaOQL 14 may 2015 1 / 29

  2. Object model SON Organizational Spatial AbstractOU Building 1 * 1..* 0..1 CompositeOU SimpleOU Floor 0..1 1 1 * * * * Person Occupancy Room 0..1 0..1 Network * Network Device 0..1 1 * 1..* 0..1 * IPNetwork NetworkInterface LinkInterface link 0..1 1 * 1 IPv4Interface VLANInterface EthernetInterface V. Dimitrov LaOQL 14 may 2015 2 / 29

  3. Example queries on SON (JP-QL) Find router for speci fi ed device: select d from Device as d left join d.linkInterfaces as lis left join lis.networkInterfaces as nis left join nis.network.networkInterfaces as nis2 where nis2.linkInterface.device.forwarding = true and d.id = 25 Find devices into main building: select d from Device as d left join d.occupancies as os where os.room. fl oor.building.name = “Main Building” V. Dimitrov LaOQL 14 may 2015 3 / 29

  4. Example queries on SON (Criteria Query 2.0) Find devices into main building: C r i t e r i a B u i l d e r b u i l d e r = em. g e t C r i t e r i a B u i l d e r ( ) ; CriteriaQuery <Tuple> cr = b u i l d e r . createTupleQuery ( ) ; Root<Device> root = cr . from ( Device . class ) ; Join <?, ?> j o i n = root . j o i n ( " occupancy " ) . j o i n ( "room" ) ; j o i n = j o i n . j o i n ( " f l o o r " ) . j o i n ( " b u i l d i n g " ) ; cr . where ( b u i l d e r . equal ( j o i n . get ( "name" ) , "TK" ) ) ; cr . m u l t i s e l e c t ( root . get ( " id " ) ) ; V. Dimitrov LaOQL 14 may 2015 4 / 29

  5. Tasks and requirements Simple tool for working with domain (search, select and so on). Independence from storage (SQL DB, no-SQL DB, object DB, fi le system storage and so on). Uniform access to storage and extra source of information. The tool should provide fast generation of large amount of di ff erent types of queries. Laconic text of query. V. Dimitrov LaOQL 14 may 2015 5 / 29

  6. Problems How to laconic query text? Description of domain. Path-expression. Problems of links. Performance of tool. V. Dimitrov LaOQL 14 may 2015 6 / 29

  7. Main idea Creating base map with paths due to breadth- fi rst search algorithm into class graph for using into object graph. Manual changing DOM due to domain expert opinion. UML Diagram of classes Rules Class graph Breadth- fi rst searching Domain Object Map V. Dimitrov LaOQL 14 may 2015 7 / 29

  8. Using links from class diagram for searching in object graph Links LaOQL support Association types: simple DOM composition DOM aggregation DOM class association DOM attributes: direction DOM multiplicity DOM,runtime Generalizaion types: single DOM, runtime multiple DOM Implementation runtime Dependency - V. Dimitrov LaOQL 14 may 2015 8 / 29

  9. 1 (association) if class A has association link with class B throught not empty set attributes P , then path is transitions throught attributes from P . 1 p1 1 ... A B 1 pn 1 p1: B ... pn: B P = { p 1 , . . . , p n } Paths: [[ p 1 ] , . . . , [ p n ]] DOM: {A {B [[ p 1 ] , . . . , [ p n ]] }} Example from SON: EthernetInterface → EthernetInterface DOM: {EthernetInterface {EthernetInterface [[ link ]] }} 0..1 0..1 EI EI link: EI V. Dimitrov LaOQL 14 may 2015 9 / 29

  10. 2 (set of associations) If class X 1 has link to class X n throught set of classes X 2 , . . . , X n − 1 due to attributes pr 1 , . . . , pr n − 1 respectively, then path is transition throught attributes pr 1 , . . . , pr n − 1 . ... X1 X2 Xn pr1: X2 pr2: X3 Path: [[ pr 1 , . . . , pr n − 1 ]] DOM: {A {B [[ pr 1 , . . . , pr n − 1 ]]}} Example from SON: SimpleOU → Building DOM: {SimpleOU {Building [[occupancies room fl oor building]]}} SimpleOU Occupancy Room Floor Building occupancies: Set<Occupancy> room: Room floor: Floor building: Building V. Dimitrov LaOQL 14 may 2015 10 / 29

  11. 3 (generalization and association with parent) If class C extends from class A and A has association link with B and C and B have not direct association link then path from C → B (or B → C ) is path A → B ( B → A ). Example from SON: EthernetInterface → Device и Device → EthernetInterface DOM: {EthernetInterface {Device [[“device”]]} Device {EthernetInterface [[“linkInterfaces”]]} } LinkInterface Device ClassA ClassB device: Device linkInterfaces: List EthernetInterface ClassC V. Dimitrov LaOQL 14 may 2015 11 / 29

  12. 4 (generalization and association with children) If class C extends from A and class C has association with class B and A and B have not direct association link, then if class A is class C , then path from C → A is path C → B . ClassA ClassC ClassB Note: this rule executes in runtime. V. Dimitrov LaOQL 14 may 2015 12 / 29

  13. 4 (example from SON) sonelement (room) SonElement Building Floor Room sonelement — is building Building (SonElement) Floor Room sonelement — is fl oor Building Floor (SonElement) Room Order: de fi ne class; get path from DOM for this class. V. Dimitrov LaOQL 14 may 2015 13 / 29

  14. Class graph of SON OUs link EI OUs COU SOU parent IPNet IPv4I link parent Device VLAN Occup UNI UNet Building Floor Room UI link V. Dimitrov LaOQL 14 may 2015 14 / 29

  15. Algorithm (main function) Algorithm 1 Algorithm for creating DOM 1: CLASSES — list of classes 2: DOM — map 3: for all source ∈ CLASSES do for all target ∈ CLASSES do 4: paths ← ( get - paths source target ) 5: DOM ← ( assoc - in DOM [ source target ] paths ) 6: end for 7: 8: end for V. Dimitrov LaOQL 14 may 2015 15 / 29

  16. Path-expression V. Dimitrov LaOQL 14 may 2015 16 / 29

  17. Our version of path-expression Path from class to class by associations links: clazz1.clazz2 clazz1 and clazz2 have association link Eliminate intermediate classes in paths: clazz1.clazz3 clazz1 and clazz3 have association link throught intermediate class class2 . Full path: clazz1.clazz2.clazz3 Path to children of some class without direct link from other some class to this class. Recursive paths: clazz* While object not equals nil (if list, while list is not empty). V. Dimitrov LaOQL 14 may 2015 17 / 29

  18. Our version of path-expression Name of attribute into the end of path: clazz.attr Results are values of this attribute. Name of attribute as intermediate piece of path. clazz.attr.clazz Type of this attribute must be class from domain. Object as piece of path: clazz1 (clazz2.$.clazz3) V. Dimitrov LaOQL 14 may 2015 18 / 29

  19. How to laconic query text? exclude links between objects; using laconic names for classes of objects; default property for classes; complex conditions; user function. V. Dimitrov LaOQL 14 may 2015 19 / 29

  20. Implementation V. Dimitrov LaOQL 14 may 2015 20 / 29

  21. Query language selecting objects by class name; selecting values of objects; fi ltering due to speci fi ed conditions; selecting objects which are linked; union results of selecting; sorting (by objects, value of properties or user functions); calling user function; recursive queries; subqueries. V. Dimitrov LaOQL 14 may 2015 21 / 29

  22. Query language: example Selecting objects: select b from Building as b building Selecting attributes: select b.name, b.description from Building as b building[name description] Filtering: select b from Building as b where b.name=’s-name’ building#(name=“s-name”) Sorting: select b from Building as b order by b.name desc { ↑ name}building V. Dimitrov LaOQL 14 may 2015 22 / 29

  23. Eleminating links Selecting objects which are linked: select b, f.rooms from Building as b join left b. fl oors as f building (room) Nesting is not limit: building (room ( fl oor (device (simpleou)))) Selecting multible objects of di ff erent classes: building, room building (room, device) building (room, device (simpleou)) V. Dimitrov LaOQL 14 may 2015 23 / 29

  24. Query language: example Using laconic class name: select li from LinkInterface as li li Default property: room#( fl oor=1) Simpli fi cation complex conditions: fl oor#(number=1 || number=2) fl oor#(number=(1 || 2)) V. Dimitrov LaOQL 14 may 2015 24 / 29

  25. Handling selecting objects Calling user function: device@tra ffi c Parameter — list of elements: device@@tra ffi c Parameters of function ( fi rst — is result of query): device@(tra ffi c “01.10.2011” “10.10.2011”) Calling function for each element from result of query: device@@(tra ffi c %) V. Dimitrov LaOQL 14 may 2015 25 / 29

  26. Architecture V. Dimitrov LaOQL 14 may 2015 26 / 29

  27. Example of queries into Nest builging ( fl oor) building ( fl oor (room)) building ( fl oor (room (device))) V. Dimitrov LaOQL 14 may 2015 27 / 29

  28. Example of queries into Nest builging, fl oor building ( fl oor, room) building ( fl oor, room, device) V. Dimitrov LaOQL 14 may 2015 28 / 29

  29. GUI of Query Nestling V. Dimitrov LaOQL 14 may 2015 29 / 29

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend