Skip to content

Commit 95fa46f

Browse files
committed
#11 added support for Graph.DELETE
1 parent b55c384 commit 95fa46f

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
*
99
*/
1010
public enum Command implements ProtocolCommand {
11-
QUERY("graph.QUERY");
11+
QUERY("graph.QUERY"),
12+
DELETE("graph.DELETE");
1213

1314
private final byte[] raw;
1415

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ public ResultSet query(String query) {
4747
return new ResultSetImpl(sendCommand(conn, Command.QUERY, graphId, query).getObjectMultiBulkReply());
4848
}
4949
}
50+
51+
/**
52+
* Delete the all graph
53+
*
54+
* @return
55+
*/
56+
public String deleteGraph() {
57+
try (Jedis conn = _conn()) {
58+
return sendCommand(conn, Command.DELETE, graphId).getBulkReply();
59+
}
60+
}
61+
5062

5163
private BinaryClient sendCommand(Jedis conn, ProtocolCommand provider, String ...args) {
5264
BinaryClient client = conn.getClient();

src/main/java/com/redislabs/redisgraph/impl/StatisticsImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.redislabs.redisgraph.impl;
22

3-
import java.util.ArrayList;
43
import java.util.HashMap;
54
import java.util.List;
65
import java.util.Map;
@@ -26,8 +25,7 @@ public String getStringValue(Statistics.Label label) {
2625
private Map<Statistics.Label, String> getStatistics(){
2726
if(statistics.size() == 0) {
2827
for(byte[] touple : this.raw) {
29-
String row = SafeEncoder.encode(touple);
30-
String[] rowTouple = row.split(":");
28+
String[] rowTouple = SafeEncoder.encode(touple).split(":");
3129
this.statistics.put( Statistics.Label.getEnum(rowTouple[0]), rowTouple[1].trim());
3230
}
3331
}

src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ public RedisGraphAPITest() {
1919

2020
@Before
2121
public void flushDB() throws Exception{
22-
// api.deleteGraph(); - TODO add this back once we implement this API
23-
24-
Method method = RedisGraphAPI.class.getDeclaredMethod("_conn");
25-
method.setAccessible(true);
26-
((Jedis)method.invoke(api)).flushDB();
22+
api.deleteGraph();
2723
}
2824

2925
@Test

0 commit comments

Comments
 (0)