8000 PR - Update SmartGraphs (#999) · arangodb/docs@7bfb762 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit 7bfb762

Browse files
nerpaulamchackiansobolevaSimran-B
authored
PR - Update SmartGraphs (#999)
* Update SmartGraphs * updated SmartGraphs * reverted changes for 3.7 * fixed anchor links * removed anchor in 3.10 * updated hybrid smartgraph image and fixed a typo * Update 3.9/graphs-smart-graphs-getting-started.md Co-authored-by: Michael Hackstein <michael@arangodb.com> * Update 3.9/graphs-smart-graphs.md Co-authored-by: Michael Hackstein <michael@arangodb.com> * Update 3.9/graphs-smart-graphs.md Co-authored-by: Michael Hackstein <michael@arangodb.com> * Update graphs-smart-graphs.md * Add files via upload Update Disjoint SmartGraphs image * updated SmartGraphs * changed anchor links for hybrid smartgraphs * fixed typo * trying to fix broken links * updated getting started section * more adjustments * typo * Update 3.9/graphs-smart-graphs-getting-started.md Co-authored-by: Simran <Simran-B@users.noreply.github.com> * Update 3.9/graphs-smart-graphs-getting-started.md Co-authored-by: Simran <Simran-B@users.noreply.github.com> * applied changes to 3.10 and removed "hybrid" * reworked SmartGraphs images * renamed 'hybrid' image Co-authored-by: Michael Hackstein <michael@arangodb.com> Co-authored-by: ansoboleva <93702078+ansoboleva@users.noreply.github.com> Co-authored-by: Simran <Simran-B@users.noreply.github.com>
1 parent f62ca1d commit 7bfb762

23 files 10000 changed

+488
-444
lines changed

3.10/features-enterprise-edition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ features outlined below. For additional information, see
2323
Value-based sharding of large graph datasets for better data locality when
2424
traversing graphs.
2525

26-
- [**SmartGraphs using SatelliteCollections**](graphs-smart-graphs.html#benefits-of-hybrid-smartgraphs):
26+
- [**SmartGraphs using SatelliteCollections**](graphs-smart-graphs.html):
2727
Collections replicated on all cluster nodes can be combined with graphs
2828
sharded by document attributes to enable more local execution of graph queries.
2929

3.10/graphs-general-graphs-management.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ The following edge definition options are supported:
124124

125125
- `satellites` (array):
126126
An array of collection names that will be used to create [SatelliteCollections](satellites.html)
127-
for a Hybrid (Disjoint) SmartGraph (Enterprise Edition only). Each array element
128-
must be a string and a valid collection name. The collection type cannot be
129-
modified later.
127+
for a (Disjoint) SmartGraph using SatelliteCollections (Enterprise Edition only).
128+
Each array element must be a string and a valid collection name. The collection
129+
type cannot be modified later.
130130

131131
Create a Graph
132132
--------------
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
layout: default
3+
description: SmartGraphs enable you to manage graphs at scale.
4+
title: ArangoDB SmartGraphs - Getting Started
5+
---
6+
Getting started
7+
---------------
8+
9+
SmartGraphs **cannot use existing collections**. When switching to SmartGraph from an
10+
existing dataset you have to import the data into a fresh SmartGraph.
11+
12+
All collections that are being used in SmartGraphs need to be part of the same
13+
`distributeShardslike` group. The `smartGraphAttribute` and the number of shards are immutable.
14+
The `smartGraphAttribute` attribute is used to inform the database how to shard data and, as a
15+
consequence, all vertices must have this attribute. The `_from` and `_to` attributes that
16+
point _from_ one document _to_ another document stored in vertex collections are set by
17+
default, following the same smart sharding pattern.
18+
19+
## Create a SmartGraph
20+
21+
In contrast to General Graphs we have to add more options when creating the
22+
SmartGraph. The two options `smartGraphAttribute` and `numberOfShards` are
23+
required and cannot be modified later.
24+
25+
{% arangoshexample examplevar="examplevar" script="script" result="result" %}
26+
@startDocuBlockInline smartGraphCreateGraphHowTo1_cluster
27+
@EXAMPLE_ARANGOSH_OUTPUT{smartGraphCreateGraphHowTo1_cluster}
28+
var graph_module = require("@arangodb/smart-graph");
29+
var graph = graph_module._create("myGraph", [], [], {smartGraphAttribute: "region", numberOfShards: 9});
30+
graph_module._graph("myGraph");
31+
~graph_module._drop("myGraph");
32+
@END_EXAMPLE_ARANGOSH_OUTPUT
33+
@endDocuBlock smartGraphCreateGraphHowTo1_cluster
34+
{% endarangoshexample %}
35+
{% include arangoshexample.html id=examplevar script=script result=result %}
36+
37+
## Create a Disjoint SmartGraph
38+
39+
In contrast to regular SmartGraphs we have to add one option when creating the
40+
graph. The boolean option `isDisjoint` is required, needs to be set to `true`
41+
and cannot be modified later.
42+
43+
{% arangoshexample examplevar="examplevar" script="script" result="result" %}
44+
@startDocuBlockInline smartGraphCreateGraphHowToDisjoint1_cluster
45+
@EXAMPLE_ARANGOSH_OUTPUT{smartGraphCreateGraphHowToDisjoint1_cluster}
46+
var graph_module = require("@arangodb/smart-graph");
47+
var graph = graph_module._create("myGraph", [], [], {smartGraphAttribute: "region", numberOfShards: 9, isDisjoint: true});
48+
graph_module._graph("myGraph");
49+
~graph_module._drop("myGraph");
50+
@END_EXAMPLE_ARANGOSH_OUTPUT
51+
@endDocuBlock smartGraphCreateGraphHowToDisjoint1_cluster
52+
{% endarangoshexample %}
53+
{% include arangoshexample.html id=examplevar script=script result=result %}
54+
55+
## Add vertex collections
56+
57+
This is analogous to General Graphs. Unlike with General Graphs, the
58+
**collections must not exist** when creating the SmartGraph. The SmartGraph
59+
module will create them for you automatically to set up the sharding for all
60+
these collections correctly. If you create collections via the SmartGraph
61+
module and remove them from the graph definition, then you may re-add them
62+
without trouble however, as they will have the correct sharding.
63+
64+
{% arangoshexample examplevar="examplevar" script="script" result="result" %}
65+
@startDocuBlockInline smartGraphCreateGraphHowTo2_cluster
66+
@EXAMPLE_ARANGOSH_OUTPUT{smartGraphCreateGraphHowTo2_cluster}
67+
~var graph_module = require("@arangodb/smart-graph");
68+
~var graph = graph_module._create("myGraph", [], [], {smartGraphAttribute: "region", numberOfShards: 9});
69+
graph._addVertexCollection("shop");
70+
graph._addVertexCollection("customer");
71+
graph._addVertexCollection("pet");
72+
graph_module._graph("myGraph");
73+
~graph_module._drop("myGraph", true);
74+
@END_EXAMPLE_ARANGOSH_OUTPUT
75+
@endDocuBlock smartGraphCreateGraphHowTo2_cluster
76+
{% endarangoshexample %}
77+
{% include arangoshexample.html id=examplevar script=script result=result %}
78+
79+
## Define relations on the Graph
80+
81+
Adding edge collections works the same as with General Graphs, but again, the
82+
collections are created by the SmartGraph module to set up sharding correctly
83+
so they must not exist when creating the SmartGraph (unless they have the
84+
correct sharding already).
85+
86+
{% arangoshexample examplevar="examplevar" script="script" result="result" %}
87+
@startDocuBlockInline smartGraphCreateGraphHowTo3_cluster
88+
@EXAMPLE_ARANGOSH_OUTPUT{smartGraphCreateGraphHowTo3_cluster}
89+
~var graph_module = require("@arangodb/smart-graph");
90+
~var graph = graph_module._create("myGraph", [], [], {smartGraphAttribute: "region", numberOfShards: 9});
91+
~graph._addVertexCollection("shop");
92+
~graph._addVertexCollection("customer");
93+
~graph._addVertexCollection("pet");
94+
var rel = graph_module._relation("isCustomer", ["shop"], ["customer"]);
95+
graph._extendEdgeDefinitions(rel);
96+
graph_module._graph("myGraph");
97+
~graph_module._drop("myGraph", true);
98+
@END_EXAMPLE_ARANGOSH_OUTPUT
99+
@endDocuBlock smartGraphCreateGraphHowTo3_cluster
100+
{% endarangoshexample %}
101+
{% include arangoshexample.html id=examplevar script=script result=result %}
102+
103+
## Using SatelliteCollections in SmartGraphs
104+
105+
When creating a collection, you can decide whether it's a SatelliteCollection
106+
or not. For example, a vertex collection can be satellite as well.
107+
SatelliteCollections don't require sharding as the data will be distributed
108+
globally on all DB-Servers. The `smartGraphAttribute` is also not required.
109+
110+
### Create a SmartGraph using SatelliteCollections
111+
112+
In addition to the attributes you would set to create a SmartGraph, there is an
113+
additional attribute `satellites` you can optionally set. It needs to be an array of
114+
one or more collection names. These names can be used in edge definitions
115+
(relations) and these collections will be created as SatelliteCollections.
116+
However, all vertex collections on one side of the relation have to be of
117+
the same type - either all satellite or all smart. This is because `_from`
118+
and `_to` can have different types based on the sharding pattern.
119+
120+
In this example, both vertex collections are created as SatelliteCollections.
121+
122+
{% hint 'info' %}
123+
When providing a satellite collection that is not used in a relation,
124+
it will not be created. If you create the collection in a following
125+
request, only then the option will count.
126+
{% endhint %}
127+
128+
{% arangoshexample examplevar="examplevar" script="script" result="result" %}
129+
@startDocuBlockInline hybridSmartGraphCreateGraphHowTo1_cluster
130+
@EXAMPLE_ARANGOSH_OUTPUT{hybridSmartGraphCreateGraphHowTo1_cluster}
131+
var graph_module = require("@arangodb/smart-graph");
132+
var rel = graph_module._relation("isCustomer", "shop", "customer")
133+
var graph = graph_module._create("myGraph", [rel], [], {satellites: ["shop", "customer"], smartGraphAttribute: "region", numberOfShards: 9});
134+
graph_module._graph("myGraph");
135+
~graph_module._drop("myGraph", true);
136+
@END_EXAMPLE_ARANGOSH_OUTPUT
137+
@endDocuBlock hybridSmartGraphCreateGraphHowTo1_cluster
138+
{% endarangoshexample %}
139+
{% include arangoshexample.html id=examplevar script=script result=result %}
140+
141+
### Create a Disjoint SmartGraph using SatelliteCollections
142+
143+
The option `isDisjoint` needs to be set to `true` in addition to the other
144+
options for a SmartGraph using SatelliteCollections. Only the `shop` vertex collection is created
145+
as a SatelliteCollection in this example:
146+
147+
{% arangoshexample examplevar="examplevar" script="script" result="result" %}
148+
@startDocuBlockInline hybridSmartGraphCreateGraphHowTo2_cluster
149+
@EXAMPLE_ARANGOSH_OUTPUT{hybridSmartGraphCreateGraphHowTo2_cluster}
150+
var graph_module = require("@arangodb/smart-graph");
151+
var rel = graph_module._relation("isCustomer", "shop", "customer")
152+
var graph = graph_module._create("myGraph", [rel], [], {satellites: ["shop"], smartGraphAttribute: "region", isDisjoint: true, numberOfShards: 9});
153+
graph_module._graph("myGraph");
154+
~graph_module._drop("myGraph", true);
155+
@END_EXAMPLE_ARANGOSH_OUTPUT
156+
@endDocuBlock hybridSmartGraphCreateGraphHowTo2_cluster
157+
{% endarangoshexample %}
158+
{% include arangoshexample.html id=examplevar script=script result=result %}

0 commit comments

Comments
 (0)
0