@@ -63,33 +63,24 @@ public RedisGraphAPI(String graphId, Pool<Jedis> jedis) {
6363 }
6464
6565 /**
66- * Execute a Cypher query
67- *
68- * @param query Cypher query
69- * @return a result set
70- */
71- public ResultSet query (String query ) {
72- try (Jedis conn = getConnection ()) {
73- return new ResultSetImpl (sendCommand (conn , Command .QUERY , graphId , query ).getObjectMultiBulkReply ());
74- }
75- }
76-
77- /**
78- * Execute a Cypher query
66+ * Execute a Cypher query with arguments
7967 *
8068 * @param query Cypher query
69+ * @param args
8170 * @return a result set
8271 */
8372 public ResultSet query (String query , Object ...args ) {
84- for (int i =0 ; i <args .length ; ++i ) {
85- if (args [i ] instanceof String ) {
86- args [i ] = "\' " + ESCAPE_CHYPER .translate ((String )args [i ]) + "\' " ;
73+ if (args .length > 0 ) {
74+ for (int i =0 ; i <args .length ; ++i ) {
75+ if (args [i ] instanceof String ) {
76+ args [i ] = "\' " + ESCAPE_CHYPER .translate ((String )args [i ]) + "\' " ;
77+ }
8778 }
79+ query = String .format (query , args );
8880 }
89-
90- query = String .format (query , args );
81+
9182 try (Jedis conn = getConnection ()) {
92- return new ResultSetImpl (sendCommand (conn , Command .QUERY , graphId , query ).getObjectMultiBulkReply ());
83+ return new ResultSetImpl (sendCommand (conn , Command .QUERY , graphId , query ).getObjectMultiBulkReply ());
9384 }
9485 }
9586
@@ -100,11 +91,10 @@ public ResultSet query(String query, Object ...args) {
10091 * @return delete running time statistics
10192 */
10293 public String deleteGraph () {
103- try (Jedis conn = getConnection ()) {
104- return sendCommand (conn , Command .DELETE , graphId ).getBulkReply ();
105- }
106- }
107-
94+ try (Jedis conn = getConnection ()) {
95+ return sendCommand (conn , Command .DELETE , graphId ).getBulkReply ();
96+ }
97+ }
10898
10999 private BinaryClient sendCommand (Jedis conn , ProtocolCommand provider , String ...args ) {
110100 BinaryClient binaryClient = conn .getClient ();
0 commit comments