Loading
Version: Graph 2.4.2User-supplied IDs
This page describes the user-supplied IDs for vertices which are supported by Aerospike Graph Service (AGS).
Overview
AGS supports user-supplied IDs for vertices. Edges and vertex properties must use auto-generated IDs.
Any value for a vertex id
field that is unique across an
application may be used as an ID. For example, vertices that represent
user accounts could use the account ID as a user-supplied id
field.
Record access by id
lookup is very efficient.
Supported data types
The following data types are supported as user-supplied IDs:
- Integer
- Long
- String
To represent UUIDs, use the String data type. To represent timestamps, use the Long data type.
Java example
The following example demonstrates creating and accessing vertices
with user-supplied id
fields.
// Insert vertex with Integer type user-supplied ID.
g.addV("person").property(T.id, 0).next();
// Insert vertex with Long type user-supplied ID.
g.addV("person").property(T.id, 1L).next();
// Insert vertex with String type user-supplied ID.
g.addV("person").property(T.id, "foo").next()
// Output: [0, "foo", 1, 2.0]
System.out.println(g.V().id().toList());
// Retrieve vertex with integer type user-supplied ID.
final Vertex v0 = g.V(0).next();
// Retrieve vertex with long type user-supplied ID.
final Vertex v1 = g.V(1L).next();
// Retrieve vertex with string type user-supplied ID.
final Vertex v3 = g.V("foo").next();