groimp-platform:extents
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
groimp-platform:extents [2024/12/16 17:20] – gaetan | groimp-platform:extents [2025/01/14 15:29] (current) – gaetan | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Graph Extents ====== | ====== Graph Extents ====== | ||
- | A special feature of the graph management is the manipulation of [[https:// | + | A special feature of the graph management is the manipulation of [[https:// |
Line 11: | Line 11: | ||
If a Node is added to the graph and it extends several level of Nodes, an extent for each intermediate NTypes is created. | If a Node is added to the graph and it extends several level of Nodes, an extent for each intermediate NTypes is created. | ||
- | E.g. the following (the init method is simplified, and we assume that there are not other nodes in the graph): | + | |
+ | [[https:// | ||
+ | * getType(): return the type of the node of this extent. | ||
+ | * getSubExtents(): | ||
+ | * getFirstNode(): | ||
+ | * getNextNode(): | ||
+ | * getTotalSize(): | ||
+ | |||
+ | === Example === | ||
+ | |||
+ | E.g. in the following: (the init method is simplified, and we assume that there are not other nodes in the graph) | ||
<code java> | <code java> | ||
module A; | module A; | ||
Line 20: | Line 30: | ||
</ | </ | ||
- | The graph only contains the root: Node, the RGGRoot, and one C node. GroIMP will create the following extents: | + | the graph only contains the root: Node, the RGGRoot, and one C node. GroIMP will create the following extents: |
* one for Node of size 1 | * one for Node of size 1 | ||
* one for RGGRoot of size 1 | * one for RGGRoot of size 1 | ||
Line 29: | Line 39: | ||
+ | ===== Extent index ===== | ||
- | It implements | + | An extent collects its nodes not by a single list, but by a number of (doubly linked) lists. Currently, eight lists are used, but this can easily be changed. This feature is used to partition |
- | <uml> | + | The extent indexes are defined from 0 to 7. By default most nodes added to the graph are added with the index 0. There are two exceptions (by default. You can manually set index of Node): |
- | @startuml | + | - //meta objects//: Nodes of the meta graph. Added at index 7. |
+ | - //GUI inserted objects//: Nodes inserted from the GUI. Added at index 6 (since GroIMP 2.1.5, they where added to index 7 before). | ||
- | Extent: Type getType() | + | The most common example of extent |
- | Extent: getSubExtents(list: | + | |
- | Extent: Node getFirstNode(index: int) | + | |
- | Extent: Node getNextNode(node: Node) | + | |
- | Extent: int totalSize() | + | |
- | @enduml | + | **Note**: before GroIMP version 2.1.5, all objects added through the GUI>objects> |
- | </uml> | + | |
- | * getType(): return the type of the node of this extent. | + | An index is visible, if it is included in the queries. A Node can be added in the scene with a geometrical representation, |
- | * getSubExtents(): | + | |
- | * getFirstNode(): | + | |
- | * getNextNode(): return the next element in the chain. | + | |
- | * getTotalSize(): return the size of the extent including the size of its sub extent. | + | |
- | The Extent works as a linked list. When a Node is added to the graph, it is also added in the chain of the extent of this type of node. If the extent do not exist, it is created. | + | It is possible |
+ | === Example === | ||
+ | For instance, let's consider the following method in an empty project. Notice that we set the visible extent value to 1: | ||
- | For instance the following graph, where //RGGRoot// extends //Node//, and //Model.A// extends //Node//: | + | <code java> |
+ | public void run(){ | ||
+ | de.grogra.rgg.model.Runtime.INSTANCE.currentGraph().setVisibleExtents(1); | ||
+ | println((*Node*)); | ||
+ | } | ||
+ | </code> | ||
- | <uml> | + | The method output: |
- | @startuml | + | <code> |
- | (Model.A) as a1 | + | de.grogra.rgg.RGGRoot[id=99]@2e86af42 |
- | (Model.A) as a2 | + | de.grogra.rgg.Axiom[id=100]@59f1c976 |
- | (Node) --> (RGGRoot) | + | </code> |
- | (RGGRoot) --> a1 | + | |
- | (RGGRoot) --> a2 | + | |
- | @enduml | + | |
- | </uml> | + | |
- | GroIMP creates three extents, one for each type: Node, RGGRoot, and Model.A. | + | Only the " |
- | Extents work as linked list. | + | Let's change the visible extent value to **255**. Now the method output: |
+ | < | ||
+ | de.grogra.graph.impl.Node[id=0]@5add4889 | ||
+ | de.grogra.graph.impl.Node[id=1]@4f690d55 | ||
+ | de.grogra.rgg.RGGRoot[id=103]@621de1a6 | ||
+ | Model[id=101]@331e288e | ||
+ | parameters[id=102]@cd97a89 | ||
+ | de.grogra.rgg.Axiom[id=104]@4cface1f | ||
+ | </ | ||
+ | |||
+ | Some additional nodes are now visible: | ||
+ | * the roots (id 0 and 1). id 0 is the root of the main graph. id 1 is the root of the meta graph. | ||
+ | * the nodes from the meta graph: the compiled version of the files: Model, and parameters. | ||
+ | |||
+ | Notice that: | ||
+ | * Once the setVisibleExtents is called. The value remains until a new value is set. | ||
+ | * setVisibleExtents use as parameter the decimal value of a binary number of 8 values where each 1 mean that the index is visible, the 0 to 7 index visibility are defined from left to right. E.g. to have all indexes visible, we use 11111111 (eight 1), which is equal in decimal to 255. To have all indexes visible except for the 1rst one, we use 11111110 (=254). The default value is 01111111 (=127). | ||
+ | |||
+ | |||
+ | |||
+ | ===== Extent in XL queries ===== | ||
+ | |||
+ | === Graph complexity === | ||
+ | |||
+ | Extent are used in RGG for queries that involve Node types. E.g. the query '' | ||
+ | |||
+ | Such a query will **not** visit the graph. It will loop over the extents data. Thus, the complexity of the graph //might// not affect the query. | ||
+ | |||
+ | Speed up queries by using more specific Node type: As the query loop over the extents content, '' | ||
+ | |||
+ | |||
+ | === Indexes === | ||
+ | |||
+ | Additionally, | ||
+ | |||
+ | === Examples === | ||
+ | |||
+ | The following code will create a chain of 8 cylinders, then stop growing. | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | module A(int i) extends F { | ||
+ | {setExtentIndex(i); | ||
+ | } | ||
+ | |||
+ | static int i = 0; | ||
+ | {de.grogra.rgg.model.Runtime.INSTANCE.currentGraph().setVisibleExtents(127); | ||
+ | |||
+ | public void init()[ Axiom ==> A(i); ] | ||
+ | |||
+ | public void run() [ a:A(x), (x==i) ==> a A(++i); ] | ||
+ | </ | ||
+ | |||
+ | Indeed, the last F added as an extent index of 7, thus not visible (setVisibleExtents(127) means 0 to 6 visible). In this case, the query search for F that have a extent index of 7, but the index is not visible, thus, not used in the query. | ||
- | ===== Extent index ===== |
groimp-platform/extents.1734366043.txt.gz · Last modified: 2024/12/16 17:20 by gaetan