@@ -45,16 +45,16 @@ class ResultSummary:
4545 #: Dictionary of parameters passed with the statement.
4646 parameters = None
4747
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).
4949 query_type = None
5050
51- #: A :class:`.Counters ` instance. Counters for operations the query triggered.
51+ #: A :class:`neo4j.SummaryCounters ` instance. Counters for operations the query triggered.
5252 counters = None
5353
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.
5555 plan = None
5656
57- #: A :class:`.ProfiledPlan` instance
57+ #: Dictionary that describes how the database executed the query.
5858 profile = None
5959
6060 #: The time it took for the server to have the result available. (milliseconds)
@@ -63,7 +63,7 @@ class ResultSummary:
6363 #: The time it took for the server to consume the result. (milliseconds)
6464 result_consumed_after = None
6565
66- #: A list of :class: `.Notification` instances
66+ #: A list of Dictionaries containing notification information.
6767 #: Notifications provide extra information for a user executing a statement.
6868 #: They can be warnings about problematic queries or other valuable information that can be
6969 #: presented in a client.
@@ -77,25 +77,16 @@ def __init__(self, **metadata):
7777 self .query = metadata .get ("query" )
7878 self .parameters = metadata .get ("parameters" )
7979 self .query_type = metadata .get ("type" )
80+ self .plan = metadata .get ("plan" )
81+ self .profile = metadata .get ("profile" )
82+ self .notifications = metadata .get ("notifications" )
8083 self .counters = SummaryCounters (metadata .get ("stats" , {}))
8184 if self .server .protocol_version [0 ] < BOLT_VERSION_3 :
8285 self .result_available_after = metadata .get ("result_available_after" )
8386 self .result_consumed_after = metadata .get ("result_consumed_after" )
8487 else :
8588 self .result_available_after = metadata .get ("t_first" )
8689 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 ))
9990
10091
10192class SummaryCounters :
@@ -159,68 +150,3 @@ def contains_updates(self):
159150 def contains_system_updates (self ):
160151 """True if the system database was updated, otherwise False."""
161152 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