@@ -10,7 +10,7 @@ const ResultSetColumnTypes = {
10
10
COLUMN_UNKNOWN : 0 ,
11
11
COLUMN_SCALAR : 1 ,
12
12
COLUMN_NODE : 2 ,
13
- COLUMN_RELATION : 3
13
+ COLUMN_RELATION : 3 ,
14
14
} ;
15
15
16
16
const ResultSetValueTypes = {
@@ -23,29 +23,29 @@ const ResultSetValueTypes = {
23
23
VALUE_ARRAY : 6 ,
24
24
VALUE_EDGE : 7 ,
25
25
VALUE_NODE : 8 ,
26
- VALUE_PATH : 9
26
+ VALUE_PATH : 9 ,
27
27
} ;
28
28
29
29
/**
30
30
* Hold a query result
31
31
*/
32
32
class ResultSet {
33
- /**
34
- * Builds an empty ResultSet object.
35
- * @constructor
36
- * @param {Graph } graph
37
- */
33
+ /**
34
+ * Builds an empty ResultSet object.
35
+ * @constructor
36
+ * @param {Graph } graph
37
+ */
38
38
constructor ( graph ) {
39
- this . _graph = graph ; //_graph is graph api
40
- this . _position = 0 ; //allowing iterator like behevior
39
+ this . _graph = graph ; //_graph is graph api
40
+ this . _position = 0 ; //allowing iterator like behevior
41
41
this . _resultsCount = 0 ; //total number of records in this result set
42
- this . _header = [ ] ; //reponse schema columns labels
43
- this . _results = [ ] ; //result records
42
+ this . _header = [ ] ; //reponse schema columns labels
43
+ this . _results = [ ] ; //result records
44
44
}
45
45
46
46
/**
47
47
* Parse raw response data to ResultSet object.
48
- * @async
48
+ * @async
49
49
* @param {object[] } resp - raw response representation - the raw representation of response is at most 3 lists of objects.
50
50
* The last list is the statistics list.
51
51
*/
@@ -66,11 +66,11 @@ class ResultSet {
66
66
return this ;
67
67
}
68
68
69
- /**
70
- * Parse a raw response body into header an records.
71
- * @async
72
- * @param {object[] } resp raw response
73
- */
69
+ /**
70
+ * Parse a raw response body into header an records.
71
+ * @async
72
+ * @param {object[] } resp raw response
73
+ */
74
74
async parseResults ( resp ) {
75
75
this . parseHeader ( resp [ 0 ] ) ;
76
76
await this . parseRecords ( resp ) ;
@@ -95,7 +95,7 @@ class ResultSet {
95
95
/**
96
96
* The raw representation of response is at most 3 lists of objects. rawResultSet[1] contains the data records.
97
97
* Each entry in the record can be either a node, an edge or a scalar
98
- * @async
98
+ * @async
99
99
* @param {object[] } rawResultSet raw result set representation
100
100
*/
101
101
async parseRecords ( rawResultSet ) {
@@ -127,12 +127,12 @@ class ResultSet {
127
127
}
128
128
}
129
129
130
- /**
131
- * Parse raw entity properties representation into a Map
132
- * @async
133
- * @param {object[] } props raw properties representation
134
- * @returns {Map } Map with the parsed properties.
135
- */
130
+ /**
131
+ * Parse raw entity properties representation into a Map
132
+ * @async
133
+ * @param {object[] } props raw properties representation
134
+ * @returns {Map } Map with the parsed properties.
135
+ */
136
136
async parseEntityProperties ( props ) {
137
137
// [[name, value, value type] X N]
138
138
let properties = { } ;
@@ -158,12 +158,12 @@ class ResultSet {
158
158
return properties ;
159
159
}
160
160
161
- /**
162
- * Parse raw node representation into a Node object.
163
- * @async
164
- * @param {object[] } cell raw node representation.
165
- * @returns {Node } Node object.
166
- */
161
+ /**
162
+ * Parse raw node representation into a Node object.
163
+ * @async
164
+ * @param {object[] } cell raw node representation.
165
+ * @returns {Node } Node object.
166
+ */
167
167
async parseNode ( cell ) {
168
168
// Node ID (integer),
169
169
// [label string offset (integer)],
@@ -188,12 +188,12 @@ class ResultSet {
188
188
return node ;
189
189
}
190
190
191
- /**
192
- * Parse a raw edge representation into an Edge object.
193
- * @async
194
- * @param {object[] } cell raw edge representation
195
- * @returns {Edge } Edge object.
196
- */
191
+ /**
192
+ * Parse a raw edge representation into an Edge object.
193
+ * @async
194
+ * @param {object[] } cell raw edge representation
195
+ * @returns {Edge } Edge object.
196
+ */
197
197
async parseEdge ( cell ) {
198
198
// Edge ID (integer),
199
199
// reltype string offset (integer),
@@ -223,37 +223,37 @@ class ResultSet {
223
223
return edge ;
224
224
}
225
225
226
- /**
227
- * Parse and in-place replace raw array into an array of values or objects.
228
- * @async
229
- * @param {object[] } rawArray raw array representation
230
- * @returns {object[] } Parsed array.
231
- */
226
+ /**
227
+ * Parse and in-place replace raw array into an array of values or objects.
228
+ * @async
229
+ * @param {object[] } rawArray raw array representation
230
+ * @returns {object[] } Parsed array.
231
+ */
232
232
async parseArray ( rawArray ) {
233
233
for ( var i = 0 ; i < rawArray . length ; i ++ ) {
234
234
rawArray [ i ] = await this . parseScalar ( rawArray [ i ] ) ;
235
235
}
236
236
return rawArray ;
237
237
}
238
238
239
- /**
240
- * Parse a raw path representation into Path object.
241
- * @async
242
- * @param {object[] } rawPath raw path representation
243
- * @returns {Path } Path object.
244
- */
239
+ /**
240
+ * Parse a raw path representation into Path object.
241
+ * @async
242
+ * @param {object[] } rawPath raw path representation
243
+ * @returns {Path } Path object.
244
+ */
245
245
async parsePath ( rawPath ) {
246
246
let nodes = await this . parseScalar ( rawPath [ 0 ] ) ;
247
247
let edges = await this . parseScalar ( rawPath [ 1 ] ) ;
248
248
return new Path ( nodes , edges ) ;
249
249
}
250
250
251
- /**
252
- * Parse a raw value into its actual value.
253
- * @async
254
- * @param {object[] } cell raw value representation
255
- * @returns {object } Actual value - scalar, array, Node, Edge, Path
256
- */
251
+ /**
252
+ * Parse a raw value into its actual value.
253
+ * @async
254
+ * @param {object[] } cell raw value representation
255
+ * @returns {object } Actual value - scalar, array, Node, Edge, Path
256
+ */
257
257
async parseScalar ( cell ) {
258
258
let scalar_type = cell [ 0 ] ;
259
259
let value = cell [ 1 ] ;
@@ -298,40 +298,40 @@ class ResultSet {
298
298
return scalar ;
299
299
}
300
300
301
- /**
302
- * @returns {string[] }ResultSet's header.
303
- */
301
+ /**
302
+ * @returns {string[] }ResultSet's header.
303
+ */
304
304
getHeader ( ) {
305
305
return this . _typelessHeader ;
306
306
}
307
307
308
- /**
309
- * @returns {boolean } If the ResultSet object can return additional records.
310
- */
308
+ /**
309
+ * @returns {boolean } If the ResultSet object can return additional records.
310
+ */
311
311
hasNext ( ) {
312
312
return this . _position < this . _resultsCount ;
313
313
}
314
314
315
- /**
316
- * @returns {Record } The current record.
317
- */
315
+ /**
316
+ * @returns {Record } The current record.
317
+ */
318
318
next ( ) {
319
319
return this . _results [ this . _position ++ ] ;
320
320
}
321
321
322
- /**
323
- * @returns {Statistics } ResultsSet's statistics.
324
- */
322
+ /**
323
+ * @returns {Statistics } ResultsSet's statistics.
324
+ */
325
325
getStatistics ( ) {
326
326
return this . _statistics ;
327
- }
328
-
329
- /**
330
- * @returns {int } Result set size.
331
- */
332
- size ( ) {
333
- return this . _resultsCount ;
334
- }
327
+ }
328
+
329
+ /**
330
+ * @returns {int } Result set size.
331
+ */
332
+ size ( ) {
333
+ return this . _resultsCount ;
334
+ }
335
335
}
336
336
337
337
module . exports = ResultSet ;
0 commit comments