Overview
You can create one or multiple HDC graphs for a graphset as needed. Each HDC graph is hosted on a single HDC server.
Showing HDC Graphs
Retrieves information about all HDC graphs of the current graphset:
hdc.graph.show()
Or retrieves a specific HDC graph, such as the one named hdcGraph_1
:
hdc.graph.show("hdcGraph_1")
It returns a table _hdcGraphList
with the following fields:
Field |
Description |
---|---|
name |
Name of the HDC graph. |
graph_name |
Name of the current graphset from which the data was loaded. |
status |
Current state of the HDC graph, which can be DONE or CREATING , FAILED or UNKNOWN . |
stats |
Statistics about nodes and edges included in the HDC graph, including their schemas, properties and total counts. |
is_default |
Indicates if it is the default HDC graph for the current graphset. |
hdc_server_name |
Name of the HDC server hosting the HDC graph. |
hdc_server_status |
Current state of this HDC server, which can be ACTIVE or DEAD . |
config |
Configurations for the HDC graph. |
When retrieving a specific HDC graph using hdc.graph.show("<name>")
, two supplementary tables are returned:
_graph_from_<hdcServerName>
: Shows all HDC graphs hosted by<hdcServerName>
._algoList_from_<hdcServerName>
: Lists all algorithms installed on<hdcServerName>
.
Here, <hdcServerName>
is the HDC server hosting the specified HDC graph.
Creating an HDC Graph
The hdc.graph.create().to()
statement creates an HDC graph for the current graphset. The HDC graph creation is executed as a job, you may run show().job(<id?>)
afterward to verify the success of the creation.
Syntax
hdc.graph.create("<hdcGraphName>", {
nodes: {
"<schema1?>": ["<property1?>", "<property2?>", ...],
"<schema2?>": ["<property1?>", "<property2?>", ...],
...
},
edges: {
"<schema1?>": ["<property1?>", "<property2?>", ...],
"<schema2?>": ["<property1?>", "<property2?>", ...],
...
},
direction: "<edgeDirection?>",
load_id: <boolean?>,
update: "<dataSyncMode>",
query: "query",
default: <boolean?>
}).to("<hdcServerName>")
Method | Param | Description | Optional | |
---|---|---|---|---|
create() |
<hdcGraphName> |
Name of the HDC graph. Each HDC graph name within an HDC server must be unique and cannot duplicate the name of any distributed projection of the same graphset. | No | |
Config Map | nodes |
Specifies nodes to load 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 load 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 load only incoming edges with in , only outgoing edges with out , or both (the default setting) with undirected . Please note that in or out restricts graph traversal during computation to the specified direction. |
Yes | ||
load_id |
Sets to false to load nodes without _id values to save the memory space; it defaults to true . |
Yes | ||
update |
Sets the data sync mode. Only static (default) is supported now where any data change in the physical storage will not be synchronized to the HDC graph. |
Yes | ||
query |
This is a reserved parameter to set a query to specify the data to load. Now it can be set to query only. |
No | ||
default |
Sets to true to specify this HDC graph as the default one for the current graphset; it defaults to false . |
Yes | ||
to() |
<hdcServerName> |
Name of the HDC server to host the HDC graph. | No |
Examples
To load the entire current graphset to hdc-server-1
as hdcGraph
:
hdc.graph.create("hdcGraph", {
nodes: {"*": ["*"]},
edges: {"*": ["*"]},
direction: "undirected",
load_id: true,
update: "static",
query: "query",
default: true
}).to("hdc-server-1")
To load @account
and @movie
nodes with selected properties and incoming @rate
edges in the current graphset to hdc-server-1
as hdcGraph_1
, while omitting nodes' _id
values:
hdc.graph.create("hdcGraph_1", {
nodes: {
"account": ["name", "gender"],
"movie": ["name", "year"]
},
edges: {"rate": ["*"]},
direction: "in",
load_id: false,
update: "static",
query: "query",
default: false
}).to("hdc-server-1")
Dropping an HDC Graph
You can drop any HDC graph of the current graphset from the HDC server using the hdc.graph.drop()
statement.
The following example deletes the HDC graph named hdcGraph_1
:
hdc.graph.drop("hdcGraph_1")
HDC Graph List Synchronization
HDC graphs are managed by the database's meta server. The latest HDC graph list is synchronized from the meta server to the name server during each heartbeat cycle. This list on the name server is referenced whenever HDC queries or algorithms are executed.
After creating or dropping an HDC graph, it is advisable to wait for two heartbeat intervals before performing further operations on the affected HDC graph. To adjust the heartbeat interval, update the heartbeat_interval_s
setting (defaults to 3 seconds) in the Server
section of the name server configuration.