graph - Classic engine

This command is used to create a new Classic graph, truncate an existing Classic graph, or drop an existing Classic graph. A Classic graph is a graph using the schema and data manipulation methods of DSE Graph 6.7 and earlier, which differs from DataStax Graph (DSG) schema and data manipulation. The Classic graph engine is deprecated in DSG 6.8 and is included mainly to facilitate migration to DSG. Contact DataStax Services for help with migration.

Synopsis

system.graph('<graph_name>').
   replication("{'class' : 'NetworkTopologyStrategy', '<data_center_name>' : <replication_factor> }").
   systemReplication("{'class' : 'NetworkTopologyStrategy', '<data_center_name>' : <replication_factor> }").
  [ option('<option_name>').set('<option_value>'). ]
   engine(Classic).
   create() | [ifExists().]truncate() | [ifExists().]drop() | exists()
ifExists

Truncating and dropping a graph can check for existence with ifExists() before attempting the operations.

replication, systemReplication

Set replication class and replication factor for each datacenter using the same guidelines as for CQL keyspaces.

The replication factor cannot be altered once set for the graph, just as the replication factor for a keyspace cannot be changed.

DSE database settings for replication factor are used, either SimpleStrategy for single datacenters or NetworkTopologyStrategy for multiple datacenters. The default replication strategy for a multi-datacenter graph is NetworkTopologyStrategy, whereas for a single datacenter, the replication strategy will default to SimpleStrategy.

The system replication settings can be verified using the cqlsh tool, running the CQL command DESCRIBE keyspace food command:

DESCRIBE KEYSPACE food;

with a result:

CREATE KEYSPACE food_system WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1: '3', 'dc2' : 2 }  AND durable_writes = true;

systemReplication is set similarly, for the graphName_system keyspace that is required for Classic graphs.

create

Create a new graph. The graph_name specified is used to create two DSG Classic database keyspaces, graph_name and graph_name_system, and can only contain alphanumeric and underscore characters.

truncate

Truncate an existing graph using this command. All data will be removed from the graph. ifExists() can be used to check if a graph exists before truncating it.

drop

Drop an existing graph using this command. All data and schema will be lost. For better performance, truncate a graph before dropping it.ifExists() can be used to check if a graph exists before dropping it.

exists

Check existence of a graph using this command.

Examples

Create a graph

Create a new Classic graph without checking for the existence of a graph with the specified name:

system.graph('food_simple').
  classicEngine().
  create()

Either classicEngine() or engine(Classic) can be used to make a Classic graph. The resulting list:

==>food_simple

Create a Classic graph, setting the replication factor for the _name and system replicaton factor for the graph_name_system. It can also include other options to set schema settings.

system.graph('food_classic').
   replication("{'class' : 'NetworkTopologyStrategy', 'SearchGraph' : 1 }").
   systemReplication("{'class' : 'NetworkTopologyStrategy', 'SearchGraph' : 1 }").
   option('graph.schema_mode').
   set('Production').
   option('graph.allow_scan').
   set('true').
   // classicEngine() also works
   engine(Classic).  
   create()

Restriction: The replication factor and system replication factor cannot be altered once set for the graph_name and graph_name_system keyspaces.

Truncate a graph

Truncate a Classic graph using ifExists():

system.graph('food_classic').
  ifExists().
  truncate()

The resulting list:

==> OK

Drop a graph

Drop an existing graph if it exists.

system.graph('food_classic').
  ifExists().
  drop()

The resulting list:

==> OK

Check graph existence

Discover if a particular graph exists. The return value is a boolean value.

system.graph('fridge_sensor').exists()

The resulting list:

==> true

config

How to configure graph options for a Classic graph using the Schema API.

option

How to configure a graph using a system or schema option.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com