@@ -13,6 +13,10 @@ class Graph:
13
13
def __init__ (self , name , redis_con ):
14
14
"""
15
15
Create a new graph.
16
+
17
+ Args:
18
+ name: string that represents the name of the graph
19
+ redis_con: connection to Redis
16
20
"""
17
21
self .name = name # Graph key
18
22
self .redis_con = redis_con
@@ -59,6 +63,12 @@ def _refresh_attributes(self):
59
63
self ._properties [i ] = p [0 ]
60
64
61
65
def get_label (self , idx ):
66
+ """
67
+ Returns a label by it's index
68
+
69
+ Args:
70
+ idx: The index of the label
71
+ """
62
72
try :
63
73
label = self ._labels [idx ]
64
74
except IndexError :
@@ -68,6 +78,12 @@ def get_label(self, idx):
68
78
return label
69
79
70
80
def get_relation (self , idx ):
81
+ """
82
+ Returns a relationship type by it's index
83
+
84
+ Args:
85
+ idx: The index of the relation
86
+ """
71
87
try :
72
88
relationshipType = self ._relationshipTypes [idx ]
73
89
except IndexError :
@@ -77,6 +93,12 @@ def get_relation(self, idx):
77
93
return relationshipType
78
94
79
95
def get_property (self , idx ):
96
+ """
97
+ Returns a property by it's index
98
+
99
+ Args:
100
+ idx: The index of the property
101
+ """
80
102
try :
81
103
propertie = self ._properties [idx ]
82
104
except IndexError :
@@ -130,7 +152,7 @@ def flush(self):
130
152
self .nodes = {}
131
153
self .edges = []
132
154
133
- def build_params_header (self , params ):
155
+ def _build_params_header (self , params ):
134
156
if not isinstance (params , dict ):
135
157
raise TypeError ("'params' must be a dict" )
136
158
# Header starts with "CYPHER"
@@ -148,14 +170,20 @@ def build_params_header(self, params):
148
170
def query (self , q , params = None , timeout = None , read_only = False ):
149
171
"""
150
172
Executes a query against the graph.
173
+
174
+ Args:
175
+ q: the query
176
+ params: query parameters
177
+ timeout: maximum runtime for read queries in milliseconds
178
+ read_only: executes a readonly query if set to True
151
179
"""
152
180
153
181
# maintain original 'q'
154
182
query = q
155
183
156
184
# handle query parameters
157
185
if params is not None :
158
- query = self .build_params_header (params ) + query
186
+ query = self ._build_params_header (params ) + query
159
187
160
188
# construct query command
161
189
# ask for compact result-set format
@@ -196,9 +224,13 @@ def execution_plan(self, query, params=None):
196
224
"""
197
225
Get the execution plan for given query,
198
226
GRAPH.EXPLAIN returns an array of operations.
227
+
228
+ Args:
229
+ query: the query that will be executed
230
+ params: query parameters
199
231
"""
200
232
if params is not None :
201
- query = self .build_params_header (params ) + query
233
+ query = self ._build_params_header (params ) + query
202
234
203
235
plan = self .redis_con .execute_command ("GRAPH.EXPLAIN" , self .name , query , query )
204
236
return self ._execution_plan_to_string (plan )
0 commit comments