Skip to content

Commit

Permalink
refactor to driver
Browse files Browse the repository at this point in the history
  • Loading branch information
gkorland committed Dec 11, 2023
1 parent eb39909 commit 0bb76db
Show file tree
Hide file tree
Showing 23 changed files with 448 additions and 644 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/falkordb/Driver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.falkordb;

import java.io.Closeable;

import redis.clients.jedis.Jedis;

public interface Driver extends Closeable{
GraphContextGenerator graph(String graphId);

Jedis getConnection();
}
14 changes: 14 additions & 0 deletions src/main/java/com/falkordb/FalkorDB.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.falkordb;

final public class FalkorDB {

private FalkorDB() {}

public static Driver driver (){
return new com.falkordb.impl.api.Driver();
}

public static Driver driver (String host, int port){
return new com.falkordb.impl.api.Driver(host, port);

Check warning on line 12 in src/main/java/com/falkordb/FalkorDB.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/falkordb/FalkorDB.java#L12

Added line #L12 was not covered by tests
}
}
42 changes: 12 additions & 30 deletions src/main/java/com/falkordb/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,119 +4,101 @@
import java.util.List;
import java.util.Map;

import redis.clients.jedis.Jedis;

public interface Graph extends Closeable {

static Graph with(Jedis jedis) {
return new com.falkordb.impl.api.Graph(jedis);
}

/**
* Execute a Cypher query.
* @param graphId a graph to perform the query on
* @param query Cypher query
* @return a result set
*/
ResultSet query(String graphId, String query);
ResultSet query(String query);

/**
* Execute a Cypher read-only query.
* @param graphId a graph to perform the query on
* @param query Cypher query
* @return a result set
*/
ResultSet readOnlyQuery(String graphId, String query);
ResultSet readOnlyQuery(String query);

/**
* Execute a Cypher query with timeout.
* @param graphId a graph to perform the query on
* @param query Cypher query
* @param timeout timeout in milliseconds
* @return a result set
*/
ResultSet query(String graphId, String query, long timeout);
ResultSet query(String query, long timeout);

/**
* Execute a Cypher read-only query with timeout.
* @param graphId a graph to perform the query on
* @param query Cypher query
* @param timeout timeout in milliseconds
* @return a result set
*/
ResultSet readOnlyQuery(String graphId, String query, long timeout);
ResultSet readOnlyQuery(String query, long timeout);

/**
* Executes a cypher query with parameters.
* @param graphId a graph to perform the query on.
* @param query Cypher query.
* @param params parameters map.
* @return a result set.
*/
ResultSet query(String graphId, String query, Map<String, Object> params);
ResultSet query(String query, Map<String, Object> params);

/**
* Executes a cypher read-only query with parameters.
* @param graphId a graph to perform the query on.
* @param query Cypher query.
* @param params parameters map.
* @return a result set.
*/
ResultSet readOnlyQuery(String graphId, String query, Map<String, Object> params);
ResultSet readOnlyQuery(String query, Map<String, Object> params);

/**
* Executes a cypher query with parameters and timeout.
* @param graphId a graph to perform the query on.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @return a result set.
*/
ResultSet query(String graphId, String query, Map<String, Object> params, long timeout);
ResultSet query(String query, Map<String, Object> params, long timeout);

/**
* Executes a cypher read-only query with parameters and timeout.
* @param graphId a graph to perform the query on.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @return a result set.
*/
ResultSet readOnlyQuery(String graphId, String query, Map<String, Object> params, long timeout);
ResultSet readOnlyQuery(String query, Map<String, Object> params, long timeout);

/**
* Invokes stored procedures without arguments
* @param graphId a graph to perform the query on
* @param procedure procedure name to invoke
* @return result set with the procedure data
*/
ResultSet callProcedure(String graphId, String procedure);
ResultSet callProcedure(String procedure);

/**
* Invokes stored procedure with arguments
* @param graphId a graph to perform the query on
* @param procedure procedure name to invoke
* @param args procedure arguments
* @return result set with the procedure data
*/
ResultSet callProcedure(String graphId, String procedure, List<String> args);
ResultSet callProcedure(String procedure, List<String> args);

/**
* Invoke a stored procedure
* @param graphId a graph to perform the query on
* @param procedure - procedure to execute
* @param args - procedure arguments
* @param kwargs - procedure output arguments
* @return result set with the procedure data
*/
ResultSet callProcedure(String graphId, String procedure, List<String> args , Map<String, List<String>> kwargs);
ResultSet callProcedure(String procedure, List<String> args , Map<String, List<String>> kwargs);

/**
* Deletes the entire graph
* @param graphId graph to delete
* @return delete running time statistics
*/
String deleteGraph(String graphId);
String deleteGraph();

@Override
void close();
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/com/falkordb/GraphContext.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
package com.falkordb;

import redis.clients.jedis.Jedis;

public interface GraphContext extends Graph {


/**
* Returns implementing class connection context
* @return Jedis connection
*/
Jedis getConnectionContext();

/**
* Returns a Redis transactional object, over the connection context, with graph API capabilities
* @return Redis transactional object, over the connection context, with graph API capabilities
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/falkordb/GraphContextGenerator.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.falkordb;

public interface GraphContextGenerator extends Graph {

/**
* Generate a connection bounded api
* @return a connection bounded api
*/
GraphContext getContext();

}
41 changes: 14 additions & 27 deletions src/main/java/com/falkordb/GraphPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,109 +25,97 @@ public interface GraphPipeline extends

/**
* Execute a Cypher query.
* @param graphId a graph to perform the query on
* @param query Cypher query
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> query(String graphId, String query);
Response<ResultSet> query(String query);

/**
* Execute a Cypher read-only query.
* @param graphId a graph to perform the query on
* @param query Cypher query
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> readOnlyQuery(String graphId, String query);
Response<ResultSet> readOnlyQuery(String query);

/**
* Execute a Cypher query with timeout.
* @param graphId a graph to perform the query on
* @param query Cypher query
* @param timeout
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> query(String graphId, String query, long timeout);
Response<ResultSet> query(String query, long timeout);

/**
* Execute a Cypher read-only query with timeout.
* @param graphId a graph to perform the query on
* @param query Cypher query
* @param timeout
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> readOnlyQuery(String graphId, String query, long timeout);
Response<ResultSet> readOnlyQuery(String query, long timeout);

/**
* Executes a cypher query with parameters.
* @param graphId a graph to perform the query on.
* @param query Cypher query.
* @param params parameters map.
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> query(String graphId, String query, Map<String, Object> params);
Response<ResultSet> query(String query, Map<String, Object> params);

/**
* Executes a cypher read-only query with parameters.
* @param graphId a graph to perform the query on.
* @param query Cypher query.
* @param params parameters map.
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> readOnlyQuery(String graphId, String query, Map<String, Object> params);
Response<ResultSet> readOnlyQuery(String query, Map<String, Object> params);

/**
* Executes a cypher query with parameters and timeout.
* @param graphId a graph to perform the query on.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> query(String graphId, String query, Map<String, Object> params, long timeout);
Response<ResultSet> query(String query, Map<String, Object> params, long timeout);

/**
* Executes a cypher read-only query with parameters and timeout.
* @param graphId a graph to perform the query on.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> readOnlyQuery(String graphId, String query, Map<String, Object> params, long timeout);
Response<ResultSet> readOnlyQuery(String query, Map<String, Object> params, long timeout);

/**
* Invokes stored procedures without arguments
* @param graphId a graph to perform the query on
* @param procedure procedure name to invoke
* @return a response which builds result set with the procedure data
*/
Response<ResultSet> callProcedure(String graphId, String procedure);
Response<ResultSet> callProcedure(String procedure);

/**
* Invokes stored procedure with arguments
* @param graphId a graph to perform the query on
* @param procedure procedure name to invoke
* @param args procedure arguments
* @return a response which builds result set with the procedure data
*/
Response<ResultSet> callProcedure(String graphId, String procedure, List<String> args);
Response<ResultSet> callProcedure(String procedure, List<String> args);

/**
* Invoke a stored procedure
* @param graphId a graph to perform the query on
* @param procedure - procedure to execute
* @param args - procedure arguments
* @param kwargs - procedure output arguments
* @return a response which builds result set with the procedure data
*/
Response<ResultSet> callProcedure(String graphId, String procedure, List<String> args , Map<String, List<String>> kwargs);
Response<ResultSet> callProcedure(String procedure, List<String> args , Map<String, List<String>> kwargs);

/**
* Deletes the entire graph
* @param graphId graph to delete
* @return a response which builds the delete running time statistics
*/
Response<String> deleteGraph(String graphId);
Response<String> deleteGraph();


/**
Expand All @@ -143,8 +131,7 @@ public interface GraphPipeline extends
* get return values from pipelined commands, capture the different Response&lt;?&gt; of the
* commands you execute.
*/
public void sync();

void sync();

/**
* Blocks until all the previous write commands are successfully transferred and acknowledged by
Expand All @@ -156,5 +143,5 @@ public interface GraphPipeline extends
* @return the number of replicas reached by all the writes performed in the context of the
* current connection
*/
public Response<Long> waitReplicas(int replicas, long timeout);
Response<Long> waitReplicas(int replicas, long timeout);
}
Loading

0 comments on commit 0bb76db

Please sign in to comment.