An Ultipa Graph instance allows for the existence of multiple graphsets. Each graphset includes the definition of the graph structure (schemas and properties), graph metadata (nodes and edges), various indexes, processes, tasks, and so on. Sometimes, the terms "graphset" and "graph" are used interchangeably.
A graphset named default is automatically created during the creation of an Ultipa Graph instance. This default graphset is initially empty and can be freely utilized. However, the default graphset is not allowed to be altered (name and description), dropped, or unmounted.
NOTEIn a cluster environment, the unmounting, mounting, and truncating UQLs will be sent to the leader node for execution.
UQL// Show all graphsets in the instance (via listGraph API) show().graph() // Show all graphsets in the instance (via listGraph API) show().graph("") // Show the graphset named Sample in the instance show().graph("Sample")
Example result:
id | name | totalNodes | totalEdges | description | status |
|---|---|---|---|---|---|
| 0 | default | 0 | 0 | System default graph! | MOUNTED |
| 1 | Sample | 112 | 125 | MOUNTED |
The status of a graphset can be mounted, unmounted or mounting. Large graphsets may take some time to finish mounting.
A mounted graphset displays the total number of nodes and edges within it. An unmounted graphset displays 0 for both totalNodes and totalEdges. During the unmounting process, the graphset displays the number of nodes and edges that are currently mounted.
UQL// Create a graphset named social, and provide description create().graph("social", "Campus social graph") // Create a graphset named social create().graph("social") // Create multiple graphsets at one time create() .graph("social") .graph("transaction", "Bank Card Transaction")
Here are the naming conventions for graphsets:
_), and numbers (0-9).You cannot have two graphsets with the same name.
Create three graphsets at the same time, but one of the names (default) is duplicated with an existing graphset.
UQLcreate().graph("newGraph_1").graph("default").graph("newGraph_2")
The creation of the graphset newGraph_1, which was specified before the duplicated graphset, succeeds. However, the one (newGraph_2) specified after the duplicated graphset fails, with the error message Duplicated db name! returned.
UQLTRY create().graph("newGraph_1").graph("default").graph("newGraph_2")
The creation of the graphsets is the same as above, though the error message is shielded by the TRY prefix, while returning the message SUCCEED.
UQL// Alter name and description of the graphset currently named "miniCircle" alter().graph("miniCircle").set({name: "movieCommunity", description: "Unix Movie Platform"}) // Remove description of the graphset named "movieCommunity" alter().graph("movieCommunity").set({description: ""}) // Rename the graphset named "movieCommunity" alter().graph("movieCommunity").set({name: "movComm"})
You may unmount temporarily unused graphsets (except the default graphset) to save instance memory. For example, the LTE-ed properties will be unloaded from the memory.
When a graph is unmounted, it’s not allowed to modify or read the schemas, properties, data, etc. within the graph. Unmounted graph can only be mounted, altered or dropped.
UQL// Unmount a graphset named "LDCC" from the instance memory unmount().graph("LDCC")
Newly created graphsets are mounted by default. You may need to manually re-mount any unmounted graphsets.
When a graphset is remounted, its previously LTE-ed properties will be reloaded into the memory; the indexes and full-text indexes will also be automatically recreated as before.
UQL// Mount a graphset named "LDCC" back to the instance memory mount().graph("LDCC")
Dropping a graphset means to delete the entire graphset. The default graphset cannot be dropped.
UQL// Drop the graphset named "test0831" drop().graph("test0831") // Drop multiple graphsets at one time drop().graph("test0831").graph("test0925")
Truncating a graphset only deletes the specified data within the graph, while the graphset itself and its structure (schemas & properties) are retained.
UQL// Truncate all nodes and edges in the graphset named "PowerGrid" truncate().graph("PowerGrid") // Truncate all @bus nodes (and their adjacent edges) in the graphset named "PowerGrid" truncate().graph("PowerGrid").nodes(@bus) // Truncate all @connectsTo edges in the graphset named "PowerGrid" truncate().graph("PowerGrid").edges(@connectsTo) // Truncate all nodes (and edges) in the graphset named "PowerGrid" truncate().graph("PowerGrid").nodes("*") // Truncate all edges in the graphset named "PowerGrid" truncate().graph("PowerGrid").edges("*")
NOTENote that deleting a node leads to the removal of all edges that are connected to it.
Compacting a graphset clears invalid and redundant data from the graph on the server disk but does not make any changes to other valid data.
UQL// Compact the graphset named "PowerGrid" compact().graph("PowerGrid")
NOTEOperations related to data manipulation can generate redundant data, such as old records retained after an update or deletion operation. It's suggested to regularly compact graphsets to improve query efficiency.