Skip to content

Commit 8aa70bb

Browse files
author
DvirDukhan
committed
changed Jedis client to new 3.1.0 version. Modified send command flow
1 parent b7ea858 commit 8aa70bb

File tree

3 files changed

+17
-34
lines changed

3 files changed

+17
-34
lines changed

pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@
4646
<distribution>repo</distribution>
4747
</license>
4848
</licenses>
49-
49+
50+
<repositories>
51+
<repository>
52+
<id>snapshots-repo</id>
53+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
54+
</repository>
55+
</repositories>
56+
5057
<dependencies>
5158
<dependency>
5259
<groupId>org.apache.commons</groupId>
@@ -62,7 +69,7 @@
6269
<dependency>
6370
<groupId>redis.clients</groupId>
6471
<artifactId>jedis</artifactId>
65-
<version>3.0.1</version>
72+
<version>3.1.0-SNAPSHOT</version>
6673
</dependency>
6774
<dependency>
6875
<groupId>org.apache.commons</groupId>

src/main/java/com/redislabs/redisgraph/RedisGraph.java

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import redis.clients.jedis.JedisPool;
1111
import redis.clients.jedis.commands.ProtocolCommand;
1212
import redis.clients.jedis.util.Pool;
13+
import redis.clients.jedis.util.SafeEncoder;
1314

1415
import java.io.Closeable;
1516
import 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
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.redislabs.redisgraph.impl;
2+
3+
public class JRedisGraphTransaction {
4+
}

0 commit comments

Comments
 (0)