6
6
7
7
use GraphAware \Common \Cypher \StatementInterface ;
8
8
use GraphAware \Common \Result \StatementResult as StatementResultInterface ;
9
+ use GraphAware \Common \Result \StatementStatistics ;
10
+ use GraphAware \Common \Result \StatementStatisticsInterface ;
9
11
10
12
/**
11
13
* @author Xavier Coureau <[email protected] >
@@ -48,6 +50,7 @@ public function record(StatementInterface $statement)
48
50
'query ' => $ statementText ,
49
51
'parameters ' => $ statementParams ,
50
52
'tag ' => $ statement ->getTag (),
53
+ 'statistics ' => []
51
54
];
52
55
$ this ->statementsHash [$ statementText ][$ statementParams ][$ tag ] = $ idx ;
53
56
}
@@ -74,6 +77,7 @@ public function finish(StatementResultInterface $statementResult)
74
77
$ this ->statements [$ idx ] = array_merge ($ this ->statements [$ idx ], [
75
78
'end_time ' => microtime (true ) * 1000 ,
76
79
'nb_results ' => $ statementResult ->size (),
80
+ 'statistics ' => $ this ->statisticsToArray ($ statementResult ->summarize ()->updateStatistics ())
77
81
]);
78
82
}
79
83
@@ -118,4 +122,24 @@ public function getElapsedTime()
118
122
119
123
return $ time ;
120
124
}
125
+
126
+ private function statisticsToArray (StatementStatisticsInterface $ statementStatistics )
127
+ {
128
+ $ data = [
129
+ 'contains_updates ' => $ statementStatistics ->containsUpdates (),
130
+ 'nodes_created ' => $ statementStatistics ->nodesCreated (),
131
+ 'nodes_deleted ' => $ statementStatistics ->nodesDeleted (),
132
+ 'relationships_created ' => $ statementStatistics ->relationshipsCreated (),
133
+ 'relationships_deleted ' => $ statementStatistics ->relationshipsDeleted (),
134
+ 'properties_set ' => $ statementStatistics ->propertiesSet (),
135
+ 'labels_added ' => $ statementStatistics ->labelsAdded (),
136
+ 'labels_removed ' => $ statementStatistics ->labelsRemoved (),
137
+ 'indexes_added ' => $ statementStatistics ->indexesAdded (),
138
+ 'indexes_removed ' => $ statementStatistics ->indexesRemoved (),
139
+ 'constraints_added ' => $ statementStatistics ->constraintsAdded (),
140
+ 'constraints_removed ' => $ statementStatistics ->constraintsRemoved ()
141
+ ];
142
+
143
+ return $ data ;
144
+ }
121
145
}
0 commit comments