@@ -45,16 +45,16 @@ class ResultSummary:
45
45
#: Dictionary of parameters passed with the statement.
46
46
parameters = None
47
47
48
- #: The type of query (``'r'`` = read-only, ``'rw'`` = read/write).
48
+ #: A string that describes the type of query (``'r'`` = read-only, ``'rw'`` = read/write).
49
49
query_type = None
50
50
51
- #: A :class:`.Counters ` instance. Counters for operations the query triggered.
51
+ #: A :class:`neo4j.SummaryCounters ` instance. Counters for operations the query triggered.
52
52
counters = None
53
53
54
- #: A :class:`.Plan` instance. This describes how the database will execute the query.
54
+ #: Dictionary that describes how the database will execute the query.
55
55
plan = None
56
56
57
- #: A :class:`.ProfiledPlan` instance
57
+ #: Dictionary that describes how the database executed the query.
58
58
profile = None
59
59
60
60
#: The time it took for the server to have the result available. (milliseconds)
@@ -63,7 +63,7 @@ class ResultSummary:
63
63
#: The time it took for the server to consume the result. (milliseconds)
64
64
result_consumed_after = None
65
65
66
- #: A list of :class: `.Notification` instances
66
+ #: A list of Dictionaries containing notification information.
67
67
#: Notifications provide extra information for a user executing a statement.
68
68
#: They can be warnings about problematic queries or other valuable information that can be
69
69
#: presented in a client.
@@ -77,25 +77,16 @@ def __init__(self, **metadata):
77
77
self .query = metadata .get ("query" )
78
78
self .parameters = metadata .get ("parameters" )
79
79
self .query_type = metadata .get ("type" )
80
+ self .plan = metadata .get ("plan" )
81
+ self .profile = metadata .get ("profile" )
82
+ self .notifications = metadata .get ("notifications" )
80
83
self .counters = SummaryCounters (metadata .get ("stats" , {}))
81
84
if self .server .protocol_version [0 ] < BOLT_VERSION_3 :
82
85
self .result_available_after = metadata .get ("result_available_after" )
83
86
self .result_consumed_after = metadata .get ("result_consumed_after" )
84
87
else :
85
88
self .result_available_after = metadata .get ("t_first" )
86
89
self .result_consumed_after = metadata .get ("t_last" )
87
- if "plan" in metadata :
88
- self .plan = _make_plan (metadata ["plan" ])
89
- if "profile" in metadata :
90
- self .profile = _make_plan (metadata ["profile" ])
91
- self .plan = self .profile
92
- self .notifications = []
93
- for notification in metadata .get ("notifications" , []):
94
- position = notification .get ("position" )
95
- if position is not None :
96
- position = Position (position ["offset" ], position ["line" ], position ["column" ])
97
- self .notifications .append (Notification (notification ["code" ], notification ["title" ],
98
- notification ["description" ], notification ["severity" ], position ))
99
90
100
91
101
92
class SummaryCounters :
@@ -159,68 +150,3 @@ def contains_updates(self):
159
150
def contains_system_updates (self ):
160
151
"""True if the system database was updated, otherwise False."""
161
152
return self .system_updates > 0
162
-
163
-
164
- #: A plan describes how the database will execute your statement.
165
- #:
166
- #: operator_type:
167
- #: the name of the operation performed by the plan
168
- #: identifiers:
169
- #: the list of identifiers used by this plan
170
- #: arguments:
171
- #: a dictionary of arguments used in the specific operation performed by the plan
172
- #: children:
173
- #: a list of sub-plans
174
- Plan = namedtuple ("Plan" , ("operator_type" , "identifiers" , "arguments" , "children" ))
175
-
176
- #: A profiled plan describes how the database executed your statement.
177
- #:
178
- #: db_hits:
179
- #: the number of times this part of the plan touched the underlying data stores
180
- #: rows:
181
- #: the number of records this part of the plan produced
182
- ProfiledPlan = namedtuple ("ProfiledPlan" , Plan ._fields + ("db_hits" , "rows" ))
183
-
184
- #: Representation for notifications found when executing a statement. A
185
- #: notification can be visualized in a client pinpointing problems or
186
- #: other information about the statement.
187
- #:
188
- #: code:
189
- #: a notification code for the discovered issue.
190
- #: title:
191
- #: a short summary of the notification
192
- #: description:
193
- #: a long description of the notification
194
- #: severity:
195
- #: the severity level of the notification
196
- #: position:
197
- #: the position in the statement where this notification points to, if relevant.
198
- Notification = namedtuple ("Notification" , ("code" , "title" , "description" , "severity" , "position" ))
199
-
200
- #: A position within a statement, consisting of offset, line and column.
201
- #:
202
- #: offset:
203
- #: the character offset referred to by this position; offset numbers start at 0
204
- #: line:
205
- #: the line number referred to by the position; line numbers start at 1
206
- #: column:
207
- #: the column number referred to by the position; column numbers start at 1
208
- Position = namedtuple ("Position" , ("offset" , "line" , "column" ))
209
-
210
-
211
- def _make_plan (plan_dict ):
212
- """ Construct a Plan or ProfiledPlan from a dictionary of metadata values.
213
-
214
- :param plan_dict:
215
- :return:
216
- """
217
- operator_type = plan_dict ["operatorType" ]
218
- identifiers = plan_dict .get ("identifiers" , [])
219
- arguments = plan_dict .get ("args" , [])
220
- children = [_make_plan (child ) for child in plan_dict .get ("children" , [])]
221
- if "dbHits" in plan_dict or "rows" in plan_dict :
222
- db_hits = plan_dict .get ("dbHits" , 0 )
223
- rows = plan_dict .get ("rows" , 0 )
224
- return ProfiledPlan (operator_type , identifiers , arguments , children , db_hits , rows )
225
- else :
226
- return Plan (operator_type , identifiers , arguments , children )
0 commit comments