Difference between revisions of "Modifying the Universe"

From AtlasWiki
Jump to: navigation, search
(Remove link to notable features)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
The universe is mutable.  You have the power to change it!  Let’s create a new node using the [[Atlas Shell]].
 
The universe is mutable.  You have the power to change it!  Let’s create a new node using the [[Atlas Shell]].
  
<pre>GraphElement bob = Graph.U.createNode();
+
<syntaxhighlight lang="scala">var bob = Graph.U.createNode();
bob.attr().put(Node.NAME, "bob");
+
bob.attr().put(XCSG.name, "bob");
bob.tags().add("PERSON");
+
bob.tags().add("Person");
show(universe.nodesTaggedWithAny("PERSON"))</pre>
+
show(universe.nodesTaggedWithAny("Person"));</syntaxhighlight>
  
You've now changed the original index created by Atlas.  To keep the universe somewhat sane, Atlas keeps track of what was originally in the universe and what was not.  Atlas does this by providing two sets <code>Common.universe()</code> and <code>Common.index()</code>, where index is the universe before changes were made.
+
You've now changed the original index created by Atlas.  To keep the universe somewhat sane, Atlas keeps track of what was originally in the universe and what was not.  Atlas does this by providing two sets <code>Query.universe()</code> and <code>Common.codemap()</code>, where codemap is the universe before changes were made.
  
 
The following query will show an empty graph, even though "bob" exists in the universe.
 
The following query will show an empty graph, even though "bob" exists in the universe.
  
<code>show(index.nodesTaggedWithAny("PERSON"))</code>
+
<code>show(codemap.nodesTaggedWithAny("Person"))</code>
  
 
Since "bob" exists in the universe and not in the index, we should query for the new node using the universe.
 
Since "bob" exists in the universe and not in the index, we should query for the new node using the universe.
  
<code>show(universe.nodesTaggedWithAny("PERSON"))</code>
+
<code>show(universe.nodesTaggedWithAny("Person"))</code>
  
This is important to remember when using convenience methods provided by Atlas such as <code>Common.edges()</code>.  The convenience wrappers will use <code>Common.index()</code> not <code>Common.universe()</code>.
+
This is important to remember when using convenience methods provided by Atlas such as <code>Common.edges()</code>.  The convenience wrappers will use <code>Common.codemap()</code> not <code>Query.universe()</code>.
  
 
Let’s create one more node and add an edge between the two nodes.
 
Let’s create one more node and add an edge between the two nodes.
  
<pre>GraphElement bill = Graph.U.createNode();
+
<syntaxhighlight lang="scala">var bill = Graph.U.createNode();
bill.attr().put(Node.NAME, "bill");
+
bill.attr().put(XCSG.name, "bill");
bill.tags().add("PERSON");</pre>
+
bill.tags().add("Person");</syntaxhighlight>
  
<pre>GraphElement friends = Graph.U.createEdge(bill, bob);
+
<syntaxhighlight lang="scala">var friends = Graph.U.createEdge(bill, bob);
friends.attr().put(Edge.NAME, "FRIENDS");
+
friends.attr().put(XCSG.name, "Friends");
friends.tags().add("FRIENDS");</pre>
+
friends.tags().add("Friends");</syntaxhighlight>
  
<code>show(universe.edgesTaggedWithAny("FRIENDS").retainEdges())</code>
+
<code>show(universe.edgesTaggedWithAny("Friends").retainEdges())</code>
  
 
''Important'': Changes to the Atlas index are only made to the index in memory.  If you have saved a copy of the index before the changes were made those changes will not be present in the serialized index.  You will need to re-saved you modified indexes if you wish to save the modifications.  You should also be careful to avoid concurrent writes to the Atlas index.  Concurrent writing is not supported at this time.
 
''Important'': Changes to the Atlas index are only made to the index in memory.  If you have saved a copy of the index before the changes were made those changes will not be present in the serialized index.  You will need to re-saved you modified indexes if you wish to save the modifications.  You should also be careful to avoid concurrent writes to the Atlas index.  Concurrent writing is not supported at this time.
Line 34: Line 34:
 
''Warning'': This is an advanced usage of the Atlas index and the decision to do so should not be taken lightly.  Typically you won't need to modify the index, but some analysis tasks may become easier with this ability.  Example uses might be to add a new custom tag to <code>GraphElement</code>s in the universe as a way to saving the result of some first pass analysis.  Another use might be to add missing program elements that exist outside the Atlas index, such as XML resources for domain specific applications like Android.  A word of caution however, changing the index may violate assumptions in the [[Atlas Schema]].  Think through the ramifications of your modifications to the index before you make them.
 
''Warning'': This is an advanced usage of the Atlas index and the decision to do so should not be taken lightly.  Typically you won't need to modify the index, but some analysis tasks may become easier with this ability.  Example uses might be to add a new custom tag to <code>GraphElement</code>s in the universe as a way to saving the result of some first pass analysis.  Another use might be to add missing program elements that exist outside the Atlas index, such as XML resources for domain specific applications like Android.  A word of caution however, changing the index may violate assumptions in the [[Atlas Schema]].  Think through the ramifications of your modifications to the index before you make them.
  
<br /><center>[[Toolbox Analyzers|&larr;&nbsp;Toolbox Analyzers]]&nbsp;|&nbsp;[[Learning Atlas]]</center>
+
<br /><center>[[Atlas Schema|&larr;&nbsp;Atlas Schema]]&nbsp;|&nbsp;[[Learning Atlas]]&nbsp;</center>

Latest revision as of 15:24, 15 October 2015

The universe is mutable. You have the power to change it! Let’s create a new node using the Atlas Shell.

var bob = Graph.U.createNode();
bob.attr().put(XCSG.name, "bob");
bob.tags().add("Person");
show(universe.nodesTaggedWithAny("Person"));

You've now changed the original index created by Atlas. To keep the universe somewhat sane, Atlas keeps track of what was originally in the universe and what was not. Atlas does this by providing two sets Query.universe() and Common.codemap(), where codemap is the universe before changes were made.

The following query will show an empty graph, even though "bob" exists in the universe.

show(codemap.nodesTaggedWithAny("Person"))

Since "bob" exists in the universe and not in the index, we should query for the new node using the universe.

show(universe.nodesTaggedWithAny("Person"))

This is important to remember when using convenience methods provided by Atlas such as Common.edges(). The convenience wrappers will use Common.codemap() not Query.universe().

Let’s create one more node and add an edge between the two nodes.

var bill = Graph.U.createNode();
bill.attr().put(XCSG.name, "bill");
bill.tags().add("Person");
var friends = Graph.U.createEdge(bill, bob);
friends.attr().put(XCSG.name, "Friends");
friends.tags().add("Friends");

show(universe.edgesTaggedWithAny("Friends").retainEdges())

Important: Changes to the Atlas index are only made to the index in memory. If you have saved a copy of the index before the changes were made those changes will not be present in the serialized index. You will need to re-saved you modified indexes if you wish to save the modifications. You should also be careful to avoid concurrent writes to the Atlas index. Concurrent writing is not supported at this time.

Warning: This is an advanced usage of the Atlas index and the decision to do so should not be taken lightly. Typically you won't need to modify the index, but some analysis tasks may become easier with this ability. Example uses might be to add a new custom tag to GraphElements in the universe as a way to saving the result of some first pass analysis. Another use might be to add missing program elements that exist outside the Atlas index, such as XML resources for domain specific applications like Android. A word of caution however, changing the index may violate assumptions in the Atlas Schema. Think through the ramifications of your modifications to the index before you make them.


← Atlas Schema | Learning Atlas