Creating a custom vertex id 

How and when to create a custom vertex id.

A custom vertex id can be created to replace the standard vertex id generated when a vertex is created. The use cases for creating a custom vertex id are:
  • When the data stored in DSE Graph is aligned with other data sources, such as other Cassandra keyspaces or another database.
  • When custom graph partitioning is desired.
Note: Standard auto-generated ids are deprecated with DSE 6.0. Custom ids will undergo changes, and specifying vertex ids with partitionKey and clusteringKey will likely become the normal method.
For example, sensor time series data is stored in Cassandra. In addition to the time series queries to Cassandra, relationship information about the sensors is desired, such as how the sensors are networked and where the sensors are located. To load the data into a graph to explore the relationships, but retain the ability to write an application that accesses both the time series data and the graph data, custom vertex ids are created that span across both database models.
CAUTION:
Keep in mind that if custom vertex ids are used, they must be globally unique within the graph, or duplicate vertices can potentially be loaded into a graph. DSE Graph does not verify the custom vertex ids.

Procedure

  1. Create a vertex label with a custom partitioning key sensor_id. The property key sensor_id must exist prior to use in creating the vertex label and cannot be a multiple cardinality property.
    schema.vertexLabel('FridgeSensor').partitionKey('sensor_id').create()
  2. Add a vertex using the vertex label FridgeSensor.
    graph.addVertex(label, 'FridgeSensor','sensor_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66')
  3. Create a vertex label with a custom partitioning key city_id and clustering key sensor_id.
    schema.vertexLabel('FridgeSensor').partitionKey('city_id').clusteringKey('sensor_id').create()
  4. Add a vertex using the vertex label FridgeSensor with both a partition key and clustering key.
    graph.addVertex(label, 'FridgeSensor','sensor_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66', 'city_id', 100)
  5. Create a vertex label with a custom composite partition, using both city_id and sensor_id as part of the partitioning key.
    schema.vertexLabel('FridgeSensor').partitionKey('city_id', 'sensor_id').create()