cassandra.graph
- Graph Statements, Options, and Row Factories¶
Note
This module is only for backward compatibility for dse-driver users. Consider using cassandra.datastax.graph.
-
cassandra.graph.
single_object_row_factory
(column_names, rows)[source]¶ returns the JSON string value of graph results
-
cassandra.graph.
graph_result_row_factory
(column_names, rows)[source]¶ Returns a
Result
object that can load graph results and produce specific types. The Result JSON is deserialized and unpacked from the top-level ‘result’ dict.
-
cassandra.graph.
graph_object_row_factory
(column_names, rows)[source]¶ Like
graph_result_row_factory()
, except known element types (Vertex
,Edge
) are converted to their simplified objects. Some low-level metadata is shed in this conversion. Unknown result types are still returned asResult
.
-
cassandra.graph.
graph_graphson2_row_factory
(cluster)¶ Row factory to deserialize GraphSON2 results.
-
cassandra.graph.
graph_graphson3_row_factory
(cluster)¶ Row factory to deserialize GraphSON3 results.
-
cassandra.graph.
to_int
(value)¶ Wraps a value to be explicitly serialized as a graphson Int.
-
cassandra.graph.
to_bigint
(value)¶ Wraps a value to be explicitly serialized as a graphson Bigint.
-
cassandra.graph.
to_smallint
(value)¶ Wraps a value to be explicitly serialized as a graphson Smallint.
-
cassandra.graph.
to_float
(value)¶ Wraps a value to be explicitly serialized as a graphson Float.
-
cassandra.graph.
to_double
(value)¶ Wraps a value to be explicitly serialized as a graphson Double.
-
class
cassandra.graph.
GraphProtocol
[source]¶ -
GRAPHSON_1_0
= b'graphson-1.0'¶ GraphSON1
-
GRAPHSON_2_0
= b'graphson-2.0'¶ GraphSON2
-
GRAPHSON_3_0
= b'graphson-3.0'¶ GraphSON3
-
-
class
cassandra.graph.
GraphOptions
(**kwargs)[source]¶ Options for DSE Graph Query handler.
-
graph_name
¶ name of the targeted graph.
-
graph_source
¶ choose the graph traversal source, configured on the server side.
-
graph_language
¶ the language used in the queries (default “gremlin-groovy”)
-
graph_read_consistency_level
¶ read cassandra.ConsistencyLevel for graph queries (if distinct from session default). Setting this overrides the native Statement.consistency_level for read operations from Cassandra persistence
-
graph_write_consistency_level
¶ write cassandra.ConsistencyLevel for graph queries (if distinct from session default). Setting this overrides the native Statement.consistency_level for write operations to Cassandra persistence.
-
is_default_source
¶
-
is_analytics_source
¶ True if
graph_source
is set to the server-defined analytics traversal source (‘a’)
-
is_graph_source
¶ True if
graph_source
is set to the server-defined graph traversal source (‘g’)
-
set_source_default
()[source]¶ Sets
graph_source
to the server-defined default traversal source (‘default’)
-
-
class
cassandra.graph.
SimpleGraphStatement
(query_string, retry_policy=None, consistency_level=None, routing_key=None, serial_consistency_level=None, fetch_size=<object object>, keyspace=None, custom_payload=None, is_idempotent=False)[source]¶ Simple graph statement for
Session.execute_graph()
. Takes the same parameters asSimpleStatement
.query_string should be a literal CQL statement with the exception of parameter placeholders that will be filled through the parameters argument of
Session.execute()
.See
Statement
attributes for a description of the other parameters.
-
class
cassandra.graph.
Result
(value)[source]¶ Represents deserialized graph results. Property and item getters are provided for convenience.
-
value
= None¶ Deserialized value from the result
-
as_vertex
()[source]¶ Return a
Vertex
parsed from this resultRaises TypeError if parsing fails (i.e. the result structure is not valid).
-
-
class
cassandra.graph.
Vertex
(id, label, type, properties)[source]¶ Represents a Vertex element from a graph query.
Vertex
properties
are extracted into adict
of property names to list ofVertexProperty
(list because they are always encoded that way, and sometimes have multiple cardinality; VertexProperty because sometimes the properties themselves have property maps).
-
class
cassandra.graph.
VertexProperty
(label, value, properties=None)[source]¶ Vertex properties have a top-level value and an optional
dict
of properties.-
label
= None¶ label of the property
-
value
= None¶ Value of the property
-
properties
= None¶ dict of properties attached to the property
-
-
class
cassandra.graph.
Edge
(id, label, type, properties, inV, inVLabel, outV, outVLabel)[source]¶ Represents an Edge element from a graph query.
Attributes match initializer parameters.
-
class
cassandra.graph.
Path
(labels, objects)[source]¶ Represents a graph path.
Labels list is taken verbatim from the results.
Objects are either
Result
orVertex
/Edge
for recognized types-
labels
= None¶ List of labels in the path
-
objects
= None¶ List of objects in the path
-
-
class
cassandra.graph.
GraphSON1Deserializer
[source]¶ Deserialize graphson1 types to python objects.
-
classmethod
deserialize_float
(value)¶
-
classmethod
-
class
cassandra.graph.
GraphSON2Reader
(context, extra_deserializer_map=None)[source]¶ GraphSON2 Reader that parse json and deserialize to python objects.
- Parameters
extra_deserializer_map – map from GraphSON type tag to deserializer instance implementing deserialize
-
class
cassandra.graph.
GraphSON3Reader
(context, extra_deserializer_map=None)[source]¶ GraphSON3 Reader that parse json and deserialize to python objects.
- Parameters
context – A dict of the context, mostly used as context for udt deserialization.
extra_deserializer_map – map from GraphSON type tag to deserializer instance implementing deserialize