1414import java .util .*;
1515
1616public class ResultSetImpl implements ResultSet {
17-
17+
1818
1919 private final Header header ;
2020 private final Statistics statistics ;
21- private final List <Record > results ;
21+ private final List <Record > results ;
2222
2323 private int position = 0 ;
2424 private final RedisGraph redisGraph ;
@@ -27,15 +27,15 @@ public class ResultSetImpl implements ResultSet {
2727 /**
2828 * @param rawResponse the raw representation of response is at most 3 lists of objects.
2929 * 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
3232 */
3333 public ResultSetImpl (List <Object > rawResponse , RedisGraph redisGraph , GraphCache cache ) {
3434 this .redisGraph = redisGraph ;
3535 this .cache = cache ;
3636
3737 // 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 ) {
3939
4040 throw new JRedisGraphRunTimeException ((Throwable ) rawResponse .get (rawResponse .size () - 1 ));
4141 }
@@ -44,8 +44,8 @@ public ResultSetImpl(List<Object> rawResponse, RedisGraph redisGraph, GraphCache
4444
4545 header = parseHeader (new ArrayList <>());
4646 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 ));
4949
5050 } else {
5151
@@ -57,7 +57,6 @@ public ResultSetImpl(List<Object> rawResponse, RedisGraph redisGraph, GraphCache
5757
5858
5959 /**
60- *
6160 * @param rawResultSet - raw result set representation
6261 * @return parsed result set
6362 */
@@ -84,10 +83,10 @@ private List<Record> parseResult(List<List<Object>> rawResultSet) {
8483 case COLUMN_RELATION :
8584 parsedRow .add (deserializeEdge (obj ));
8685 break ;
87- case COLUMN_SCALAR :
86+ case COLUMN_SCALAR :
8887 parsedRow .add (deserializeScalar (obj ));
8988 break ;
90- default :
89+ default :
9190 parsedRow .add (null );
9291 break ;
9392 }
@@ -102,7 +101,6 @@ private List<Record> parseResult(List<List<Object>> rawResultSet) {
102101 }
103102
104103 /**
105- *
106104 * @param rawStatistics raw statistics representation
107105 * @return parsed statistics
108106 */
@@ -112,7 +110,6 @@ private StatisticsImpl parseStatistics(Object rawStatistics) {
112110
113111
114112 /**
115- *
116113 * @param rawHeader - raw header representation
117114 * @return parsed header
118115 */
@@ -176,11 +173,11 @@ private Edge deserializeEdge(List<Object> rawEdgeData) {
176173 deserializeGraphEntityId (edge , rawEdgeData .get (0 ));
177174
178175 String relationshipType = cache .getRelationshipType (((Long ) rawEdgeData .get (1 )).intValue (),
179- redisGraph );
176+ redisGraph );
180177 edge .setRelationshipType (relationshipType );
181178
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 ));
184181
185182 deserializeGraphEntityProperties (edge , (List <List <Object >>) rawEdgeData .get (4 ));
186183
@@ -201,7 +198,7 @@ private void deserializeGraphEntityProperties(GraphEntity entity, List<List<Obje
201198 for (List <Object > rawProperty : rawProperties ) {
202199 Property <Object > property = new Property <>();
203200 property .setName (cache .getPropertyName (((Long ) rawProperty .get (0 )).intValue (),
204- redisGraph ));
201+ redisGraph ));
205202
206203 //trimmed for getting to value using deserializeScalar
207204 List <Object > propertyScalar = rawProperty .subList (1 , rawProperty .size ());
@@ -249,11 +246,11 @@ private Object deserializeScalar(List<Object> rawScalarData) {
249246 }
250247
251248 private Map <String , Object > deserializeMap (Object rawScalarData ) {
252- List <List < Object >> keyTypeValueEntries = (List <List < Object > >) rawScalarData ;
249+ List <Object > keyTypeValueEntries = (List <Object >) rawScalarData ;
253250 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 ));
257254 map .put (key , value );
258255 }
259256 return map ;
@@ -331,9 +328,9 @@ public String toString() {
331328 }
332329
333330
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+ }
339336}
0 commit comments