Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/com/redislabs/redisgraph/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*
*/
public enum Command implements ProtocolCommand {
QUERY("graph.QUERY");
QUERY("graph.QUERY"),
DELETE("graph.DELETE");

private final byte[] raw;

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/redislabs/redisgraph/RedisGraphAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ public ResultSet query(String query) {
return new ResultSetImpl(sendCommand(conn, Command.QUERY, graphId, query).getObjectMultiBulkReply());
}
}

/**
* Deletes the entire graph
*
* @return delete running time statistics
*/
public String deleteGraph() {
try (Jedis conn = _conn()) {
return sendCommand(conn, Command.DELETE, graphId).getBulkReply();
}
}


private BinaryClient sendCommand(Jedis conn, ProtocolCommand provider, String ...args) {
BinaryClient client = conn.getClient();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.redislabs.redisgraph.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -26,8 +25,7 @@ public String getStringValue(Statistics.Label label) {
private Map<Statistics.Label, String> getStatistics(){
if(statistics.size() == 0) {
for(byte[] touple : this.raw) {
String row = SafeEncoder.encode(touple);
String[] rowTouple = row.split(":");
String[] rowTouple = SafeEncoder.encode(touple).split(":");
this.statistics.put( Statistics.Label.getEnum(rowTouple[0]), rowTouple[1].trim());
}
}
Expand Down
10 changes: 3 additions & 7 deletions src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ public RedisGraphAPITest() {
}

@Before
public void flushDB() throws Exception{
// api.deleteGraph(); - TODO add this back once we implement this API

Method method = RedisGraphAPI.class.getDeclaredMethod("_conn");
method.setAccessible(true);
((Jedis)method.invoke(api)).flushDB();
public void deleteGraph() throws Exception{
api.deleteGraph();
}

@Test
Expand Down Expand Up @@ -93,4 +89,4 @@ public void testQuery() throws Exception {
Assert.assertEquals( "32.000000", record.getString(0));

}
}
}