-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathstatistics.js.html
180 lines (145 loc) · 4.64 KB
/
statistics.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: statistics.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: statistics.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>"use strict";
const Label = require("./label");
class Statistics {
/**
* Builds a query statistics object out of raw data.
* @constructor
* @param {object[]} raw - raw data.
*/
constructor(raw) {
this._raw = raw;
}
/**
* Returns a statistics value according to the statistics label.
* @param {import('./label')} label - Statistics label.
*/
getStringValue(label) {
return this.getStatistics()[label];
}
/**
* Return the query statistics
* @return {Object<string, string>} statistics object
*/
getStatistics() {
if (!this._statistics) {
this._statistics = {};
for (let row of this._raw) {
let touple = row.split(":");
this._statistics[touple[0]] = touple[1].trim();
}
}
return this._statistics;
}
/**
* Returns the integer value of a requested label.
* @param {import('./label')} label
* @returns {number} The actual value if exists, 0 otherwise. (integer)
*/
getIntValue(label) {
let value = this.getStringValue(label);
return value ? parseInt(value) : 0;
}
/**
* Returns the float value of a requested label.
* @param {import('./label')} label
* @returns {number} The actual value if exists, 0 otherwise.
*/
getFloatValue(label) {
let value = this.getStringValue(label);
return value ? parseFloat(value) : 0;
}
/**
* @returns {number} The amount of nodes created by th query. (integer)
*/
nodesCreated() {
return this.getIntValue(Label.NODES_CREATED);
}
/**
* @returns {number} The amount of nodes deleted by the query. (integer)
*/
nodesDeleted() {
return this.getIntValue(Label.NODES_DELETED);
}
/**
* @returns {number} The amount of labels created by the query. (integer)
*/
labelsAdded() {
return this.getIntValue(Label.LABELS_ADDED);
}
/**
* @returns {number} The amount of relationships deleted by the query. (integer)
*/
relationshipsDeleted() {
return this.getIntValue(Label.RELATIONSHIPS_DELETED);
}
/**
* @returns {number} The amount of relationships created by the query. (integer)
*/
relationshipsCreated() {
return this.getIntValue(Label.RELATIONSHIPS_CREATED);
}
/**
* @returns {number} The amount of properties set by the query. (integer)
*/
propertiesSet() {
return this.getIntValue(Label.PROPERTIES_SET);
}
/**
* @returns {number} The amount of indices created by the query. (integer)
*/
indicesCreated() {
return this.getIntValue(Label.INDICES_CREATED);
}
/**
* @returns {number} The amount of indices deleted by the query. (integer)
*/
indicesDeleted() {
return this.getIntValue(Label.INDICES_DELETED);
}
/**
* @returns {boolean} The execution plan was cached on RedisGraph.
*/
cachedExecution() {
return this.getIntValue(Label.CACHED_EXECUTION) == 1;
}
/**
* @returns {number} The query execution time in ms.
*/
queryExecutionTime() {
return this.getFloatValue(Label.QUERY_INTERNAL_EXECUTION_TIME);
}
}
module.exports = Statistics;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Node.html">Node</a></li><li><a href="Path.html">Path</a></li><li><a href="Record.html">Record</a></li><li><a href="ResultSet.html">ResultSet</a></li><li><a href="Statistics.html">Statistics</a></li></ul><h3>Global</h3><ul><li><a href="global.html#Label">Label</a></li><li><a href="global.html#ResultSetColumnTypes">ResultSetColumnTypes</a></li><li><a href="global.html#ResultSetValueTypes">ResultSetValueTypes</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Dec 08 2022 09:52:52 GMT+0000 (Coordinated Universal Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>