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 orNetworkTopologyStrategy
for multiple datacenters. The default replication strategy for a multi-datacenter graph isNetworkTopologyStrategy
, whereas for a single datacenter, the replication strategy will default toSimpleStrategy
.The system replication settings can be verified using the
cqlsh
tool, running the CQL commandDESCRIBE 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
andgraph_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