Overview
A distributed projection resides in the memory of the corresponding shard servers where the data is persistently stored. It can hold either full or partial data from a graph. The term "distributed projection" indicates that data within it can be distributed across the memory of multiple shards.
All distributed projections of a graph are lost when the data in the graph is migrated to different shards.
Showing Distributed Projections
Retrieves information about all distributed projections of the current graph:
SHOW PROJECTION
show().projection()
It returns a table _projectionList with the following fields:
Field |
Description |
|---|---|
name |
Name of the projection. |
graph_name |
Name of the current graphset from which the data was loaded. |
status |
Current state of the projection, which can be DONE or CREATING, FAILED or UNKNOWN. |
stats |
Node and edge statistics per shard, including address of the leader replica of the current graphset, edge_in_count, edge_out_count and node_count. |
config |
Configurations for the distributed projection. |
Creating a Distributed Projection
The projection creation is executed as a job, you may run SHOW JOB <id?> (GQL) or show().job(<id?>) (UQL) afterward to verify the success of the creation.
Syntax
CREATE PROJECTION <projectionName> OPTIONS {
nodes: {
"<schema1>": ["<property1>", "<property2>", ...],
"<schema2>": ["<property1>", "<property2>", ...],
...
},
edges: {
"<schema1>": ["<property1>", "<property2>", ...],
"<schema2>": ["<property1>", "<property2>", ...],
...
},
direction: "<edgeDirection>",
load_id: <boolean>
}
create().projection("<projectionName>", {
nodes: {
"<schema1>": ["<property1>", "<property2>", ...],
"<schema2>": ["<property1>", "<property2>", ...],
...
},
edges: {
"<schema1>": ["<property1>", "<property2>", ...],
"<schema2>": ["<property1>", "<property2>", ...],
...
},
direction: "<edgeDirection>",
load_id: <boolean>
})
| Param | Description | Optional |
|---|---|---|
<projectionName> |
Name of the projection. Projections of the same graph cannot have duplicate names. Projections and HDC graphs of the same graph cannot have duplicate names. | No |
nodes |
Specifies nodes to project based on schemas and properties. The _uuid is loaded by default, while _id is configurable with load_id. Sets to "*": ["*"] to load all nodes. |
Yes |
edges |
Specifies edges to project based on schemas and properties. All system properties are loaded by default. Sets to "*": ["*"] to load all edges. |
Yes |
direction |
Since each edge is physically stored twice - as an incoming edge along its destination node and an outgoing edge with its source node - you can choose to project only incoming edges with in, only outgoing edges with out, or both with undirected (the default setting). Please note that in or out restricts graph traversal during computation to the specified direction. |
No |
load_id |
Sets to false to project nodes without _id values to save the memory space; it defaults to true. |
Yes |
Examples
To project the entire current graphset to its shard servers as distGraph:
CREATE PROJECTION distGraph OPTIONS {
nodes: {"*": ["*"]},
edges: {"*": ["*"]},
direction: "undirected",
load_id: true
}
create().projection("distGraph", {
nodes: {"*": ["*"]},
edges: {"*": ["*"]},
direction: "undirected",
load_id: true
})
To project account and movie nodes with selected properties and incoming rate edges in the current graph to its shard servers as distGraph_1, while omitting nodes' _id values:
CREATE PROJECTION distGraph_1 OPTIONS {
nodes: {
"account": ["name", "gender"],
"movie": ["name", "year"]
},
edges: {"rate": ["*"]},
direction: "in",
load_id: false
}
create().projection("distGraph_1", {
nodes: {
"account": ["name", "gender"],
"movie": ["name", "year"]
},
edges: {"rate": ["*"]},
direction: "in",
load_id: false
})
Dropping a Distributed Projection
Deletes the distributed projection named distGraph_1:
DROP PROJECTION distGraph_1
drop().projection("distGraph_1")