Skip to main content
Loading
Version: Graph 2.3.0

Graph Metadata

Overview

Aerospike Graph Service (AGS) provides tools for retrieving summary information and metadata about existing graph databases.

Retrieve summary information

You can retrieve summary information about a graph database, including the number of edges and vertices, without scanning the entire graph. 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.

Use the g.call("aerospike.graph.admin.metadata.summary").next() step to return a Map with the following elements:

ElementData TypeNotes
Total vertex countlongTotal vertex count.
Total edge countlongTotal edge count.
Vertex count by labelMap<String, Long>Total vertex count for a given vertex label.
Edge count by labelMap<String, Long>Total edge count for a given edge label.
Vertex properties by labelMap<String, Set<String>>Union of vertex property keys for a given vertex label.
Edge properties by labelMap<String, Set<String>>Union of edge property keys for a given edge label.

To refresh the graph's property metadata, 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);

Expected 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);

Expected 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:

ElementDescription
Gremlin Server ConfigurationYAML file used to initialize the Gremlin server.
Unified ConfigurationCombined environment variables and properties file input used to generate graph properties and Gremlin server configuration.
Graph PropertiesProperties file used to initialize AGS.

Version information

To view the AGS and Aerospike Database 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:

ElementDescription
Aerospike versionAerospike version string in the format of "NODE_1:VERSION_1,...,NODE_n:VERSION_n" for n total Aerospike nodes.
Aerospike Graph Service versionAGS version