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

laconic object query language using features of object
SMART_READER_LITE
LIVE PREVIEW

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 *


slide-1
SLIDE 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

slide-2
SLIDE 2

Object model SON

Network Spatial Organizational NetworkInterface LinkInterface

1 *

Network

0..1 1..* link 0..1 0..1

Device

1 *

Occupancy

0..1 *

EthernetInterface VLANInterface

* 1

IPv4Interface IPNetwork Building Floor

1 1..*

Room

1 *

Person SimpleOU

1 *

AbstractOU CompositeOU

* 0..1 0..1 * 0..1 *

  • V. Dimitrov

LaOQL 14 may 2015 2 / 29

slide-3
SLIDE 3

Example queries on SON (JP-QL)

Find router for specified 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.floor.building.name = “Main Building”

  • V. Dimitrov

LaOQL 14 may 2015 3 / 29

slide-4
SLIDE 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

slide-5
SLIDE 5

Tasks and requirements Simple tool for working with domain (search, select and so on). Independence from storage (SQL DB, no-SQL DB,

  • bject DB, file system storage and so on).

Uniform access to storage and extra source of information. The tool should provide fast generation of large amount of different types of queries. Laconic text of query.

  • V. Dimitrov

LaOQL 14 may 2015 5 / 29

slide-6
SLIDE 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

slide-7
SLIDE 7

Main idea

Creating base map with paths due to breadth-first search algorithm into class graph for using into object graph. Manual changing DOM due to domain expert opinion.

UML Diagram of classes Class graph Rules Domain Object Map Breadth-first searching

  • V. Dimitrov

LaOQL 14 may 2015 7 / 29

slide-8
SLIDE 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

slide-9
SLIDE 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.

A

p1: B pn: B

B

p1 1 1 pn 1 1

... ...

P = {p1, . . . , pn} Paths: [[p1], . . . , [pn]] DOM: {A {B [[p1], . . . , [pn]]}} Example from SON: EthernetInterface→EthernetInterface DOM: {EthernetInterface {EthernetInterface [[link]]}}

EI

link: EI

EI

0..1 0..1

  • V. Dimitrov

LaOQL 14 may 2015 9 / 29

slide-10
SLIDE 10

2 (set of associations)

If class X1 has link to class Xn throught set of classes X2, . . . , Xn−1 due to attributes pr1, . . . , prn−1 respectively, then path is transition throught attributes pr1, . . . , prn−1.

X1

pr1: X2

X2

pr2: X3

Xn

...

Path: [[pr1, . . . , prn−1]] DOM: {A {B [[pr1, . . . , prn−1]]}} Example from SON: SimpleOU→Building DOM: {SimpleOU {Building [[occupancies room floor building]]}}

SimpleOU

  • ccupancies: Set<Occupancy>

Occupancy

room: Room

Room

floor: Floor

Floor

building: Building

Building

  • V. Dimitrov

LaOQL 14 may 2015 10 / 29

slide-11
SLIDE 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”]]} }

ClassA ClassB ClassC

LinkInterface

device: Device

Device

linkInterfaces: List

EthernetInterface

  • V. Dimitrov

LaOQL 14 may 2015 11 / 29

slide-12
SLIDE 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 ClassB ClassC

Note: this rule executes in runtime.

  • V. Dimitrov

LaOQL 14 may 2015 12 / 29

slide-13
SLIDE 13

4 (example from SON)

sonelement (room)

SonElement Floor Building Room

sonelement — is building

Floor Building (SonElement) Room

sonelement — is floor

Floor (SonElement) Building Room

Order: define class; get path from DOM for this class.

  • V. Dimitrov

LaOQL 14 may 2015 13 / 29

slide-14
SLIDE 14

Class graph of SON

COU SOU

parent OUs OUs parent

Occup Room Floor Building Device VLAN EI IPv4I IPNet UI UNI UNet

link link link

  • V. Dimitrov

LaOQL 14 may 2015 14 / 29

slide-15
SLIDE 15

Algorithm (main function)

Algorithm 1 Algorithm for creating DOM

1: CLASSES — list of classes 2: DOM — map 3: for all source ∈ CLASSES do 4:

for all target ∈ CLASSES do

5:

paths ← (get-paths source target)

6:

DOM ← (assoc-in DOM [source target] paths)

7:

end for

8: end for

  • V. Dimitrov

LaOQL 14 may 2015 15 / 29

slide-16
SLIDE 16

Path-expression

  • V. Dimitrov

LaOQL 14 may 2015 16 / 29

slide-17
SLIDE 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

slide-18
SLIDE 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

slide-19
SLIDE 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

slide-20
SLIDE 20

Implementation

  • V. Dimitrov

LaOQL 14 may 2015 20 / 29

slide-21
SLIDE 21

Query language

selecting objects by class name; selecting values of objects; filtering due to specified 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

slide-22
SLIDE 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

slide-23
SLIDE 23

Eleminating links

Selecting objects which are linked: select b, f.rooms from Building as b join left b.floors as f building (room) Nesting is not limit: building (room (floor (device (simpleou)))) Selecting multible objects of different classes: building, room building (room, device) building (room, device (simpleou))

  • V. Dimitrov

LaOQL 14 may 2015 23 / 29

slide-24
SLIDE 24

Query language: example

Using laconic class name: select li from LinkInterface as li li Default property: room#(floor=1) Simplification complex conditions: floor#(number=1 || number=2) floor#(number=(1 || 2))

  • V. Dimitrov

LaOQL 14 may 2015 24 / 29

slide-25
SLIDE 25

Handling selecting objects

Calling user function: device@traffic Parameter — list of elements: device@@traffic Parameters of function (first — is result of query): device@(traffic “01.10.2011” “10.10.2011”) Calling function for each element from result of query: device@@(traffic %)

  • V. Dimitrov

LaOQL 14 may 2015 25 / 29

slide-26
SLIDE 26

Architecture

  • V. Dimitrov

LaOQL 14 may 2015 26 / 29

slide-27
SLIDE 27

Example of queries into Nest

builging (floor) building (floor (room)) building (floor (room (device)))

  • V. Dimitrov

LaOQL 14 may 2015 27 / 29

slide-28
SLIDE 28

Example of queries into Nest

builging, floor building (floor, room) building (floor, room, device)

  • V. Dimitrov

LaOQL 14 may 2015 28 / 29

slide-29
SLIDE 29

GUI of Query Nestling

  • V. Dimitrov

LaOQL 14 may 2015 29 / 29