14
14
import java .util .*;
15
15
16
16
public class ResultSetImpl implements ResultSet {
17
-
17
+
18
18
19
19
private final Header header ;
20
20
private final Statistics statistics ;
21
- private final List <Record > results ;
21
+ private final List <Record > results ;
22
22
23
23
private int position = 0 ;
24
24
private final RedisGraph redisGraph ;
@@ -27,15 +27,15 @@ public class ResultSetImpl implements ResultSet {
27
27
/**
28
28
* @param rawResponse the raw representation of response is at most 3 lists of objects.
29
29
* The last list is the statistics list.
30
- * @param redisGraph the graph connection
31
- * @param cache the graph local cache
30
+ * @param redisGraph the graph connection
31
+ * @param cache the graph local cache
32
32
*/
33
33
public ResultSetImpl (List <Object > rawResponse , RedisGraph redisGraph , GraphCache cache ) {
34
34
this .redisGraph = redisGraph ;
35
35
this .cache = cache ;
36
36
37
37
// If a run-time error occurred, the last member of the rawResponse will be a JedisDataException.
38
- if (rawResponse .get (rawResponse .size ()- 1 ) instanceof JedisDataException ) {
38
+ if (rawResponse .get (rawResponse .size () - 1 ) instanceof JedisDataException ) {
39
39
40
40
throw new JRedisGraphRunTimeException ((Throwable ) rawResponse .get (rawResponse .size () - 1 ));
41
41
}
@@ -44,8 +44,8 @@ public ResultSetImpl(List<Object> rawResponse, RedisGraph redisGraph, GraphCache
44
44
45
45
header = parseHeader (new ArrayList <>());
46
46
results = new ArrayList <>();
47
- statistics = rawResponse .isEmpty () ? parseStatistics (new ArrayList <Objects >()) :
48
- parseStatistics (rawResponse .get (rawResponse .size () - 1 )) ;
47
+ statistics = rawResponse .isEmpty () ? parseStatistics (new ArrayList <Objects >()) :
48
+ parseStatistics (rawResponse .get (rawResponse .size () - 1 ));
49
49
50
50
} else {
51
51
@@ -57,7 +57,6 @@ public ResultSetImpl(List<Object> rawResponse, RedisGraph redisGraph, GraphCache
57
57
58
58
59
59
/**
60
- *
61
60
* @param rawResultSet - raw result set representation
62
61
* @return parsed result set
63
62
*/
@@ -84,10 +83,10 @@ private List<Record> parseResult(List<List<Object>> rawResultSet) {
84
83
case COLUMN_RELATION :
85
84
parsedRow .add (deserializeEdge (obj ));
86
85
break ;
87
- case COLUMN_SCALAR :
86
+ case COLUMN_SCALAR :
88
87
parsedRow .add (deserializeScalar (obj ));
89
88
break ;
90
- default :
89
+ default :
91
90
parsedRow .add (null );
92
91
break ;
93
92
}
@@ -102,7 +101,6 @@ private List<Record> parseResult(List<List<Object>> rawResultSet) {
102
101
}
103
102
104
103
/**
105
- *
106
104
* @param rawStatistics raw statistics representation
107
105
* @return parsed statistics
108
106
*/
@@ -112,7 +110,6 @@ private StatisticsImpl parseStatistics(Object rawStatistics) {
112
110
113
111
114
112
/**
115
- *
116
113
* @param rawHeader - raw header representation
117
114
* @return parsed header
118
115
*/
@@ -176,11 +173,11 @@ private Edge deserializeEdge(List<Object> rawEdgeData) {
176
173
deserializeGraphEntityId (edge , rawEdgeData .get (0 ));
177
174
178
175
String relationshipType = cache .getRelationshipType (((Long ) rawEdgeData .get (1 )).intValue (),
179
- redisGraph );
176
+ redisGraph );
180
177
edge .setRelationshipType (relationshipType );
181
178
182
- edge .setSource ( (long ) rawEdgeData .get (2 ));
183
- edge .setDestination ( (long ) rawEdgeData .get (3 ));
179
+ edge .setSource ((long ) rawEdgeData .get (2 ));
180
+ edge .setDestination ((long ) rawEdgeData .get (3 ));
184
181
185
182
deserializeGraphEntityProperties (edge , (List <List <Object >>) rawEdgeData .get (4 ));
186
183
@@ -201,7 +198,7 @@ private void deserializeGraphEntityProperties(GraphEntity entity, List<List<Obje
201
198
for (List <Object > rawProperty : rawProperties ) {
202
199
Property <Object > property = new Property <>();
203
200
property .setName (cache .getPropertyName (((Long ) rawProperty .get (0 )).intValue (),
204
- redisGraph ));
201
+ redisGraph ));
205
202
206
203
//trimmed for getting to value using deserializeScalar
207
204
List <Object > propertyScalar = rawProperty .subList (1 , rawProperty .size ());
@@ -249,11 +246,11 @@ private Object deserializeScalar(List<Object> rawScalarData) {
249
246
}
250
247
251
248
private Map <String , Object > deserializeMap (Object rawScalarData ) {
252
- List <List < Object >> keyTypeValueEntries = (List <List < Object > >) rawScalarData ;
249
+ List <Object > keyTypeValueEntries = (List <Object >) rawScalarData ;
253
250
Map <String , Object > map = new HashMap <>();
254
- for ( List < Object > keyTypeValueEntry : keyTypeValueEntries ) {
255
- String key = SafeEncoder .encode ((byte [])keyTypeValueEntry .get (0 ));
256
- Object value = deserializeScalar ((List <Object >)keyTypeValueEntry .get (1 ));
251
+ for ( int i = 0 ; i < keyTypeValueEntries . size (); i += 2 ) {
252
+ String key = SafeEncoder .encode ((byte []) keyTypeValueEntries .get (i ));
253
+ Object value = deserializeScalar ((List <Object >) keyTypeValueEntries .get (i + 1 ));
257
254
map .put (key , value );
258
255
}
259
256
return map ;
@@ -331,9 +328,9 @@ public String toString() {
331
328
}
332
329
333
330
334
- @ Override
335
- public Iterator <Record > iterator () {
336
- // TODO Auto-generated method stub
337
- return results .iterator ();
338
- }
331
+ @ Override
332
+ public Iterator <Record > iterator () {
333
+ // TODO Auto-generated method stub
334
+ return results .iterator ();
335
+ }
339
336
}
0 commit comments