1 / 56

Navigation in Object Graphs

Perform object graph navigation to find objects of a specific type that are reachable from a given object. Utilize meta information and class structure to optimize the search.

hund
Télécharger la présentation

Navigation in Object Graphs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Navigation in Object Graphs Mitch Wand and Karl Lieberherr Navigation in Object Graphs

  2. Searching for Reachable Objects • Task: Given an object o1 of class c1 in an object graph, find all objects of type c2 that are reachable from o1. • Assumptions: we know the class structure that describes the object graph, but we know nothing else about the object graph except the class of the current object. Navigation in Object Graphs

  3. Search using meta information • we could visit the entire object but that • would be wasteful or • might lead to wrong results Navigation in Object Graphs

  4. Classes and Objects: Basic Notations e c1 c2 Class c1 has a part e of type c2 c1 c2 Class c1 inherits from class c2 o1:c1 c1 Object o1 is of class c1 o1:c1 c1 c2 Object o1 is of type c2 (i.e., its class is a subclass of c2) e o1: o2: Object o1 has a part e which is object o2 Navigation in Object Graphs

  5. Finding the first step for the search C1 C2 ObjectGraph-object o2: o1:C1 o4: o3: Which arrows might lead to an object of type C2? Traversal Strategy: (// C1 C2) Navigation in Object Graphs

  6. Relations between Classes e C1 C2 e(C1,C2) C1 C2 C(C1,C2) (that is, e(C1,C2) for some e) C1 C2 <=(C1,C2), =>(C2,C1) o1:C1 C1 Class(o1) = C1 o1:C1 C1 C2 Object o1 is of type C2: Class(o1) <= C2 Navigation in Object Graphs

  7. Relations between Objects e o1: o2: e(o1,o2) o1: o2: O(o1,o2) (that is, e(o1,o2) for some e) Navigation in Object Graphs

  8. Operations on Relations • R.S = {(x,z) | exists y s.t. R(x,y) and S(y,z)} • R* = reflexive, transitive closure of R Navigation in Object Graphs

  9. Write graph in terms of relations Set: {S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3} Relations are sets of pairs, ordering is irrelevant. Relations: x,y,z,t,<=,=> x(S,X1) y(X2,Y2) z(Y1,Z1) t(Z2,T) <=(Y2,Y1) <=(X2,X1) <=(X3,X2) … =>(X2,X3) =>(X1,X2) =>(Z1,Z2) … z x X1 Y1 Z1 T y t S X2 Y2 Z2 X3 Y3 Z3 Navigation in Object Graphs

  10. Possible edges in the object graph e C1 C2 e(o1, o2) implies class(o1) (<= .e .=> ) class(o2) in the class graph “up, over, and down” O(o1, o2) implies class(o1) (<= .C .=> ) class(o2) in the class graph e o1: o2: Navigation in Object Graphs

  11. Which edges to follow to C2? C2 • From o1 of class C1, follow edge e iff there is some object graph O and some o2, o3 s.t. • e(o1,o2), • O*(o2,o3), and • class(o3) <= C2 C1 o1:C1 * o3: o2: e The existential quantifier “there is some object graph” represents our lack of knowledge about the rest of the object graph Navigation in Object Graphs

  12. from Basket to Orange = (from-to Basket Orange) = (// Basket Orange) Example f Fruit Basket Orange class graph v Vegetable Apple premature termination f a1:Apple f b1:Basket b1:Basket v object graph v1:Vegetable object graph slice Navigation in Object Graphs

  13. (// Basket Orange) mapping: o1 b1 o2 a1 o3 a1 e f Example f Fruit Basket Orange class graph v Vegetable Apple f a1:Orange b1:Basket object graph v object graph slice v1:Vegetable Navigation in Object Graphs

  14. Example B1 strategy from A via T to D= (join (// A T) (// T D)) 0..1 X 0..1 B D A C 0..1 :D :C R S T a1:A 0..1 class graph object graph r1:R s1:S Navigation in Object Graphs

  15. Example B1 strategy from A via T to D= (join (// A T) (// T D)) 0..1 X 0..1 B D A C 0..1 object graph slice :D :C R S T a1:A 0..1 class graph object graph r1:R s1:S Navigation in Object Graphs

  16. strategy from A via T to D= (join (// A T) (// T D)) Example B2 a1:A 0..1 :D r1:R X 0..1 B c1:C s1:S D A C s2:S t1:T 0..1 r2:R object graph R S T 0..1 c2:C class graph d2:D Navigation in Object Graphs

  17. from A via T to D= (join (// A T) (// T D)) strategy Example B2 object graph slice a1:A 0..1 :D r1:R X 0..1 B c1:C s1:S D A C s2:S t1:T 0..1 r2:R object graph R S T 0..1 c2:C class graph d2:D Navigation in Object Graphs

  18. Lack of Knowledge • Objects of a given class may be very different. • We want to go down edges without looking ahead! • We don’t want to go down edges that are guaranteed to be unsuccessful (never reaching a target object). Navigation in Object Graphs

  19. Object graph conforms to class graph • The object graph O must follow the rules of the class graph: the object graph cannot contain more information than the class graph allows. For all edges e(o1,o2) in the object graph: e(o1, o2) implies class(o1) (<= .e .=> ) class(o2) in the class graph Navigation in Object Graphs

  20. From dynamic to static characterization • From o1 of class c1, follow edge e iff there is some object graph O and some o2, o3 s.t. • e(o1,o2), • O*(o2,o3), and • class(o3) <= c2 • From o1 of class c1, follow edge e iff there are classes c’, c’’ s.t. • c1 <=.e.=> c’ • c’ (<=.C.=>)* c’’ and • c’’ <= c2 Let c’ be class(o2), c’’ be class(o3) Navigation in Object Graphs

  21. static characterization from Basket to Orange Example f Fruit Basket Orange class graph v Vegetable Apple premature termination f a1:Apple f b1:Basket b1:Basket v object graph v1:Vegetable object graph slice Navigation in Object Graphs

  22. static characterization from Basket to Orange mapping: c1 Basket c’ Orange c’’ Orange e f Example f Fruit Basket Orange class graph v Vegetable Apple f a1:Orange b1:Basket object graph v object graph slice v1:Vegetable Navigation in Object Graphs

  23. from x1 to x2 Relational Formulation From object o of class x1, to get to x2, follow edges in the set POSS(x1,x2)={e | x1 <=.e.=>.(<=.C.=>)*.<= x2 } Can easily compute these sets for every x1, x2 via transitive-closure algorithms. POSS = abbreviation for: following these edges it is still possible to reach a x2-object for some x1-object rooted at o. Navigation in Object Graphs

  24. from x1 to x2 Relational Formulation From object o of class x1, to get to x2, follow edges in the set POSS(x1,x2)={e | x1 <=.e.=>.(<=.C.=>)*.<= x2 } Simplification for class graphs obtained from hw class graphs: POSS(x1,x2)={e | x1 e.=>.(C.=>)*.<= x2 } (flat) up-over-and-down becomes over-and-down => means only one edge <= means only one edge Navigation in Object Graphs

  25. Negative formulation Positive Formulation: From object o of class x1, to get to x2, follow edges e in the set POSS(x1,x2)={e | x1 <=.e.=>.(<=.C.=>)*.<= x2 } Build paths anyway you like but don’t follow => (down) immediately after <= (up) and the first has-a edge must have label e. Edge kinds: Is-a (down, up) Has-a down ok up down up Forbidden ok Navigation in Object Graphs

  26. Followed-by relationships Navigation in Object Graphs

  27. Linking the terminologies Navigation in Object Graphs

  28. Generalizations • More complex strategies • “from c1 through c2 to c3” • Use “waypoint navigation”; get to a c2 object, then search for a c3 object. • More complex strategy graphs also doable in this framework Navigation in Object Graphs

  29. Examples Navigation in Object Graphs

  30. Example A z Strategy S -> T x X1 Y1 Z1 T Relations: x(S,X1) =>(X1,X2) y(X2,Y2) <=(Y2,Y1) z(Y1,Z1) =>(Z1,Z2) t(Z2,T) <=(X2,X1) <=(X3,X2) =>(X2,X3) … t y S X2 Y2 Z2 X3 Y3 Z3 x y z t s1:S x31:X3 y31:Y3 z31:Z3 t1:T go down x iff S and T are in relation: <=.x. =>.(<=.C.=>)*.<= Navigation in Object Graphs

  31. Example A z Strategy S -> T x X1 Y1 Z1 Relations: x(S,X1) =>(X1,X2) y(X2,Y2) <=(Y2,Y1) z(Y1,Z1) =>(Z1,Z2) t(Z2,T) <=(X2,X1) … T t y S X2 Y2 Z2 X3 Y3 Z3 x y z t s1:S x31:X3 y31:Y3 z31:Z3 t1:T <=,=> not used go down x iff S <=.x. =>.(<=.C.=>)*.<= T Navigation in Object Graphs

  32. Example A z Strategy S -> T x X1 Y1 Z1 T Relations: x(S,X1) =>(X1,X2) y(X2,Y2) <=(Y2,Y1) z(Y1,Z1) =>(Z1,Z2) t(Z2,T) <=(X2,X1) … y t S X2 Y2 Z2 X3 Y3 Z3 x y z t s1:S x31:X3 y31:Y3 z31:Z3 t1:T <=,=> not used go down x iff S <=.x. =>.(<=.C.=>.<=.C.=>.<=.C=>).<= T Navigation in Object Graphs

  33. Just in terms of relations Relations are sets of pairs, ordering is irrelevant. z x X1 Y1 Z1 T y t S X2 Y2 Z2 X3 Y3 Z3 Set: {S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3} Navigation in Object Graphs

  34. Write graph in terms of relations Set: {S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3} Relations are sets of pairs, ordering is irrelevant. Relations: x,y,z,t,<=,=> x(S,X1) y(X2,Y2) z(Y1,Z1) t(Z2,T) <=(Y2,Y1) <=(X2,X1) <=(X3,X2) … =>(X2,X3) =>(X1,X2) =>(Z1,Z2) … z x X1 Y1 Z1 T y t S X2 Y2 Z2 X3 Y3 Z3 Navigation in Object Graphs

  35. Set: {S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3} Compose relations Relations are sets of pairs, ordering is irrelevant. inheritance in reverse Relations: x,y,z,t,<=,=> x(S,X1) y(X2,Y2) z(Y1,Z1) t(Z2,T) <=(Y2,Y1) <=(X2,X1) <=(X3,X2) … =>(X2,X3) =>(X1,X2) =>(Z1,Z2) … inheritance Are S and T in the relation:<=.x. =>.(<=.C.=><=.C.=>.<=.C=>).<= Navigation in Object Graphs

  36. Set: {S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3} Just in terms of relations Relations are sets of pairs, ordering is irrelevant. The order in which we consume the pairs Relations: x,y,z,t,<=,=> x(S,X1) y(X2,Y2) z(Y1,Z1) t(Z2,T) <=(Y2,Y1) <=(X2,X1) <=(X3,X2) … =>(X2,X3) =>(X1,X2) =>(Z1,Z2) … Relations: x(S,X1) =>(X1,X2) y(X2,Y2) <=(Y2,Y1) z(Y1,Z1) =>(Z1,Z2) t(Z2,T) go down x iff S <=.x. =>.(<=.C.=><=.C.=>.<=.C=>).<= T Navigation in Object Graphs

  37. How big is the relation? How many pairs does the relation contain in this example? <=.x. =>.(<=.C.=><=.C.=>.<=.C=>).<= Navigation in Object Graphs

  38. What is disallowed? E Where can you go from A? e A B x C D go down x iff S and T are in relation: <=.x. =>.(<=.C.=>)*.<= Navigation in Object Graphs

  39. class dictionary strategy A = [“x” X] [“r” R]. B = [“b” B] D. R = S. S = [“t” T] C C = D. X = B. T = R. D = . Example B A -> T T -> D 0..1 POSS(x1,x2)={e | x1 e.C* x2 } X 0..1 B D A C 0..1 :D :C R S T :A 0..1 class graph object graph “r” :R :S Navigation in Object Graphs

  40. class dictionary strategy A = [“x” X] [“r” R]. B = [“b” B] D. R = S. S = [“t” T] C C = D. X = B. T = R. D = . Example B1 A -> T T -> D POSS(A,T) = 1 edge POSS(R,T) = 1 edge POSS(S,T) = 0 edges 0..1 X 0..1 B D A C 0..1 :D :C R S T a1:A 0..1 class graph object graph “r” r1:R s1:S POSS(c1,c2)={e | c1 e.C* c2 } Navigation in Object Graphs

  41. class dictionary strategy A = [“x” X] [“r” R]. B = [“b” B] D. R = S. S = [“t” T] C C = D. X = B. T = R. D = . Example B1 A -> T T -> D POSS(A,T) = 1 edge POSS(R,T) = 1 edge POSS(S,T) = 0 edges 0..1 X 0..1 B D A C 0..1 object graph slice :D :C R S T a1:A 0..1 class graph object graph “r” r1:R s1:S POSS(c1,c2)={e | c1 e.C* c2 } Navigation in Object Graphs

  42. strategy POSS(A,T) = 1 edge POSS(R,T) = 1 edge POSS(S,T) = 1 edge POSS(T,D) = 1 edge POSS(R,D) = 1 edge Example B2 A -> T T -> D object graph slice a1:A 0..1 :D r1:R X 0..1 B c1:C s1:S D A C s2:S t1:T 0..1 object graph “r t” r2:R R S T 0..1 c2:C class graph d2:D POSS(c1,c2)={e | c1 e.C* c2 } Navigation in Object Graphs

  43. strategy POSS(A,T) = 1 edge POSS(R,T) = 1 edge POSS(S,T) = 1 edge POSS(T,D) = 1 edge POSS(R,D) = 1 edge Example B2 A -> T T -> D object graph slice a1:A 0..1 :D r1:R X 0..1 B c1:C s1:S D A C s2:S t1:T 0..1 object graph “r t” r2:R R S T 0..1 c2:C class graph d2:D POSS(c1,c2)={e | c1 e.C* c2 } Navigation in Object Graphs

  44. Only node paths shown for space reasons Example C strategy SG: {A -> B B -> C} Object graph Strategy s t :A A B C x1:X class graph S e1:Empty :R R A x2:X Empty B x c x c1:C X b OG : A X R X C OG’: A X B X C SG : A B C c2:C BOpt c c3:C C Navigation in Object Graphs

  45. Write Java code that does the traversal Example C strategy: {A -> B B -> C} Object graph Strategy s t :A A B C x1:X class graph S e1:Empty :R R A x2:X Empty B x c x c1:C X b c2:C BOpt c c3:C C Navigation in Object Graphs

  46. Not the complete story Example C strategy: {A -> B B -> C} Object graph From A to B Strategy s t :A A B C x1:X class graph S e1:Empty :R R A x2:X Empty B x c x c1:C X b From B to C c2:C BOpt c c3:C C Navigation in Object Graphs

  47. Not the complete story: traversal must look for further B Example C strategy: {A -> B B -> C} Object graph From A to B Strategy s t :A A B C x1:X class graph S e1:Empty :R R A x2:X Empty B x c x c1:C X b From B to C c2:C BOpt c c3:C C Navigation in Object Graphs

  48. Not the complete story: traversal must look for further B Example C strategy: {A -> B B -> C} Object graph From A to B Strategy s t :A A B C First B found x1:X class graph S e1:Empty :R R A x2:X Empty B x c x c1:C X b Premature Termination: No more B c2:C BOpt c c3:C C Navigation in Object Graphs

  49. Only node paths shown for space reasons Example C1 strategy SG: {A -> S S -> C} Object graph early termination Strategy s t :A A S C x1:X class graph S e1:Empty :R R A x2:X Empty B x c x c1:C X b OG : A X R X OG’: A X B X SG : A B CG : A X Bopt B X c2:C BOpt c c3:C C Navigation in Object Graphs

  50. S = from BusRoute through Bus to Person Example D busStops BusRoute BusStopList buses 0..* NGasPowered BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* DieselPowered Navigation in Object Graphs

More Related