Graph Metadata
Aerospike Graph Service (AGS) provides tools for retrieving summary information and metadata about existing graph databases.
Summary information
You can get summary information about a graph database, including the number of edges and vertices, without scanning the entire graph. Use the following Gremlin command to retrieve summary information:
g.call("aerospike.graph.admin.metadata.summary").next()
The aerospike.graph.admin.metadata.summary
step returns a Map with the following elements:
Element | Data Type | Notes |
---|---|---|
Total vertex count | long | Total vertex count. |
Total edge count | long | Total edge count. |
Vertex count by label | Map<String, Long> | Total vertex count for a given vertex label. |
Edge count by label | Map<String, Long> | Total edge count for a given edge label. |
Vertex properties by label | Map<String, Set<String>> | Union of vertex property keys for a given vertex label. |
Edge properties by label | Map<String, Set<String>> | Union of edge property keys for a given edge label. |
Vertex and edge property keys are recorded as a union. They are stored as persistent data, and are not removed if the associated property is removed from all vertices or edges in the graph. To refresh the graph's property metadata, you must delete the entire database. You can delete the entire database with the following command:
g.V().drop().iterate();
The summary collection task runs asynchronously and is intended to provide approximate statistics very quickly without having to scan the entire graph. The summary metadata may lag behind the actual graph, and may be skewed if the write load on any given node is high.
The following Java example demonstrates usage of the summary vertex:
// Add vertices and edges.
final Vertex alfred = g.addV("person").property("name", "Alfred Simmons").property("age", 30).next();
final Vertex susan = g.addV("person").property("name", "Susan Field").property("location", "Vancouver").next();
final Vertex terence = g.addV("person").property("name", "Terence Tom").next();
final Vertex mycroft = g.addV("cat").property("breed", "Maine Coone").next();
g.addE("knows").from(alfred).to(susan).property("weight", 1.0).iterate();
g.addE("knows").from(alfred).to(terence).property("since", "2022").iterate();
g.addE("knows").from(susan).to(terence).iterate();
g.addE("swonk").from(terence).to(alfred).iterate();
g.addE("owns").from(alfred).to(mycroft).iterate();
// Add a sleep to allow the summary task to run.
Thread.sleep(1000);
// Get summary vertex.
final Object summary = g.call("aerospike.graph.admin.metadata.summary").next();
System.out.println(summary);
The above example produces the following output:
{Edge properties by label={swonk=[], owns=[], knows=[weight, since]}, Total vertex count=4, Vertex count by label={person=3, cat=1}, Vertex properties by label={person=[name, location, age], cat=[breed]}, Total edge count=5, Edge count by label={swonk=1, owns=1, knows=3}}
You can also use pretty print support for more readable output:
// Get summary vertex.
final Object summary = g.call("aerospike.graph.admin.metadata.summary").with("pretty").next();
System.out.println(summary);
Output:
Total vertex count: 4.
Vertex count by label: {person=3, cat=1}.
Vertex properties by label: {person=[name, location, age], cat=[breed]}.
Total edge count: 5.
Edge count by label: {swonk=1, owns=1, knows=3}.
Edge properties by label: {swonk=[], owns=[], knows=[weight, since]}.
Configuration information
To view the configuration setup for an existing graph database, use
the aerospike.graph.admin.metadata.config
Gremlin command.
`g.call("aerospike.graph.admin.metadata.config").next()`
The aerospike.graph.admin.metadata.config
step returns a Map with the following elements:
Element | Description |
---|---|
Gremlin Server Configuration | YAML file used to initialize the Gremlin server. |
Unified Configuration | Combined environment variables and properties file input used to generate graph properties and Gremlin server configuration. |
Graph Properties | Properties file used to initialize AGS. |
Version information
To view the AGS and Aerospike Server version information for an existing graph database, use
the aerospike.graph.admin.metadata.version
Gremlin command.
`g.call("aerospike.graph.admin.metadata.version").next()`
The aerospike.graph.admin.metadata.version
step returns a Map with the following elements:
Element | Description |
---|---|
Aerospike version | Aerospike version string in the format of "<node_1>:<version_1>,...,<node_n>:<version_n>" for n total Aerospike nodes. |
Aerospike Graph Service version | AGS version |