1010import redis .clients .jedis .JedisPool ;
1111import redis .clients .jedis .commands .ProtocolCommand ;
1212import redis .clients .jedis .util .Pool ;
13+ import redis .clients .jedis .util .SafeEncoder ;
1314
1415import java .io .Closeable ;
1516import java .util .*;
@@ -29,7 +30,7 @@ public class RedisGraph implements Closeable {
2930
3031
3132
32- private static final CharSequenceTranslator ESCAPE_CHYPER ;
33+ public static final CharSequenceTranslator ESCAPE_CHYPER ;
3334 static {
3435 final Map <CharSequence , CharSequence > escapeJavaMap = new HashMap <>();
3536 escapeJavaMap .put ("\' " , "\\ '" );
@@ -91,7 +92,7 @@ public ResultSet query(String graphId, String query, Object ...args) {
9192 graphCaches .putIfAbsent (graphId , new GraphCache (graphId , this ));
9293 List <Object > rawResponse = null ;
9394 try (Jedis conn = getConnection ()){
94- rawResponse = sendCompactCommand ( conn , Command .QUERY , graphId , query ). getObjectMultiBulkReply ( );
95+ rawResponse = ( List < Object >) conn . sendCommand ( Command .QUERY , graphId , query , "--COMPACT" );
9596 }
9697 return new ResultSetImpl (rawResponse , graphCaches .get (graphId ));
9798
@@ -129,40 +130,11 @@ public String deleteGraph(String graphId) {
129130 //clear local state
130131 graphCaches .remove (graphId );
131132 try (Jedis conn = getConnection ()) {
132- return sendCommand ( conn , Command .DELETE , graphId ). getBulkReply ( );
133+ return SafeEncoder . encode (( byte []) conn . sendCommand ( Command .DELETE , graphId ));
133134 }
134135
135136 }
136137
137-
138- /**
139- * Sends command - will be replaced with sendCompactCommand once graph.delete support --compact flag
140- * @param conn - connection
141- * @param provider - command type
142- * @param args - command arguments
143- * @return
144- */
145- private BinaryClient sendCommand (Jedis conn , ProtocolCommand provider , String ...args ) {
146- BinaryClient binaryClient = conn .getClient ();
147- binaryClient .sendCommand (provider , args );
148- return binaryClient ;
149- }
150-
151-
152- /**
153- * Sends the command with --COMPACT flag
154- * @param conn - connection
155- * @param provider - command type
156- * @param args - command arguments
157- * @return
158- */
159- private BinaryClient sendCompactCommand (Jedis conn , ProtocolCommand provider , String ...args ) {
160- String [] t = new String [args .length +1 ];
161- System .arraycopy (args , 0 , t , 0 , args .length );
162- t [args .length ]="--COMPACT" ;
163- return sendCommand (conn , provider , t );
164- }
165-
166138 private Jedis getConnection () {
167139 return this .client .getResource ();
168140 }
0 commit comments