GraphSet is the graph structure composed of nodes and edges, as well as the definition of schema and property structure of nodes and edges, tasks, indexes and other information.
During the initial launch of Ultipa instance, a GraphSet named default is created automatically (non-deletable). Every Ultipa instance may contain multiple GraphSets.
Temporarily unused GraphSets can be unmounted to save server memory, during which period the LTE-ed properties are unloaded, and only commands alter().graph()
, drop().graph()
, mount().graph()
are valid. Other operations are valid after re-mounting the GraphSet, and the engine index will be auto-created as previous.
Command of UNMOUNT, MOUNT and TRANCATE will be sent to the leader of the server cluster.
Naming Conventions
GraphSets are named by developers. A same name cannot be shared between GraphSets in an Ultipa instance.
- 2 ~ 64 characters
- Must start with letters
- Allow to use letters, underscore and numbers ( _ , A-Z, a-z, 0-9)
Show Graph
Returned table name: _graph
Returned table header: id
| name
| totalNodes
| totalEdges
| description
| status
(the ID, name, number of nodes, number of edges, description and status of the graph; status of graph can be mounted, unmounted and mounting; only mounted graph shows the real number of nodes and edges)
Syntax:
// To show all graphsets in the current Ultipa instance (via listGraph API)
show().graph()
// To show all graphsets in the current Ultipa instance
show().graph("")
// To show a certain graphset in the current Ultipa instance
show().graph("<name>")
Create Graph
Syntax:
// To create a graphset in the current Ultipa instance
create().graph("<name>", "<desc?>")
// To create multiple graphsets at one time by reusing the method above
create()
.graph("<name>", "<desc?>")
.graph("<name>", "<desc?>")
...
Example: Create graphset 'test', given that graphset 'test' already exists
create().graph("test")
Duplicated db name!
Analysis: This query will give no return if using prefix TRY try create().graph("test")
.
Alter Graph (Name, Description)
Syntax:
// To modify the name, description of a certain graphset in the current Ultipa instance
alter().graph("<name>")
.set({name: "<new_name?>", description: "<new_desc?>"})
Drop Graph
Except for the default GraphSet, which is not allowed to be deleted, all the other GraphSets in the current Ultipa instance can be deleted.
Syntax:
// To delete a certain graphset from the current Ultipa instance
drop().graph("<name>")
// To delete multiple graphsets from the current Ultipa instance
drop().graph("<name>").graph("<name>")...
Mount Graph
Syntax:
// To mount a certain graphset from the current Ultipa instance
mount().graph("<name>")
Unmount Graph
Except for the default GraphSet, which is not allowed to be unmounted, all the other Graphsets in the current Ultipa instance can be unmounted.
If the current GraphSet is unmounted
, user cannot perform any operations on the schema, property, metadata and so on within itself.
Syntax:
// To unmount a certain graphset from the current Ultipa instance
unmount().graph("<name>")
Truncate Graph
Truncate only deletes all or part of the nodes and edges in a certain GraphSet, without removing the definition of schema or property.
Syntax:
// To truncate all the nodes and edges in a certain graphset in the current Ultipa instance
truncate().graph("<graphset>")
// To truncate all the nodes of certain schema in a certain graphset in the current Ultipa instance
truncate().graph("<graphSet>").nodes(@<schema>)
// To truncate all the edges of certain schema in a certain graphset in the current Ultipa instance
truncate().graph("<graphSet>").edges(@<schema>)
// To truncate all the nodes in a certain graphset in the current Ultipa instance
truncate().graph("<graphset>").nodes("*")
// To truncate all the edges in a certain graphset in the current Ultipa instance
truncate().graph("<graphset>").edges("*")
Example: Erase all the data from GraphSet "test"
truncate().graph("test")
Example: Erase all edges from GraphSet "test"
truncate().graph("test").edges("*")
Compact Graph
Compact only clears invalid and redundant data in a certain GraphSet, without changing any valid data.
Almost all of operations will generate invalid data, such as the old records retained after an update or delete operation. These invalid data are suggested to be cleared on a regular basis since they will reduce the query efficiency.
Syntax:
// To defragment a certain graphset in the current Ultipa instance
compact().graph("<graphset>")