Skip to content

Commit

Permalink
Merge pull request #14 from FalkorDB/jdoc
Browse files Browse the repository at this point in the history
fix jdoc
  • Loading branch information
gkorland authored Dec 12, 2023
2 parents 572c0eb + 6716b6e commit 71cbb6a
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 54 deletions.
14 changes: 13 additions & 1 deletion src/main/java/com/falkordb/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
import java.io.Closeable;

import redis.clients.jedis.Jedis;

/**
* An interface which aligned to FalkorDB Driver interface
*/
public interface Driver extends Closeable{

/**
* Returns a selected Graph
* @param graphId Graph name
* @return a selected Graph
*/
GraphContextGenerator graph(String graphId);

/**
* Returns a underline connection to the database
* @return a underline connection to the database
*/
Jedis getConnection();
}
13 changes: 13 additions & 0 deletions src/main/java/com/falkordb/FalkorDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@

import com.falkordb.impl.api.DriverImpl;

/**
* FalkorDB driver factory
*/
final public class FalkorDB {

private FalkorDB() {}

/**
* Creates a new driver instance
* @return a new driver instance
*/
public static Driver driver (){
return new DriverImpl();
}

/**
* Creates a new driver instance
* @param host host name
* @param port port number
* @return a new driver instance
*/
public static Driver driver (String host, int port){
return new DriverImpl(host, port);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/falkordb/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public interface Graph extends Closeable {
* Executes a cypher query with parameters and timeout.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @param timeout timeout in milliseconds
* @return a result set.
*/
ResultSet query(String query, Map<String, Object> params, long timeout);
Expand All @@ -65,7 +65,7 @@ public interface Graph extends Closeable {
* Executes a cypher read-only query with parameters and timeout.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @param timeout timeout in milliseconds
* @return a result set.
*/
ResultSet readOnlyQuery(String query, Map<String, Object> params, long timeout);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/falkordb/GraphContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public interface GraphContext extends Graph {
GraphPipeline pipelined();

/**
* Perform watch over given Redis keys
* @param keys
* Perform watch over given Redis keys (Graphs names)
* @param keys Redis keys (Graphs names)
* @return "OK"
*/
String watch(String... keys);

/**
* Removes watch from all keys
* @return
* @return "OK"
*/
String unwatch();
}
8 changes: 4 additions & 4 deletions src/main/java/com/falkordb/GraphPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public interface GraphPipeline extends
/**
* Execute a Cypher query with timeout.
* @param query Cypher query
* @param timeout
* @param timeout timeout in milliseconds
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> query(String query, long timeout);

/**
* Execute a Cypher read-only query with timeout.
* @param query Cypher query
* @param timeout
* @param timeout timeout in milliseconds
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> readOnlyQuery(String query, long timeout);
Expand All @@ -73,7 +73,7 @@ public interface GraphPipeline extends
* Executes a cypher query with parameters and timeout.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @param timeout timeout in milliseconds
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> query(String query, Map<String, Object> params, long timeout);
Expand All @@ -82,7 +82,7 @@ public interface GraphPipeline extends
* Executes a cypher read-only query with parameters and timeout.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @param timeout timeout in milliseconds
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> readOnlyQuery(String query, Map<String, Object> params, long timeout);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/falkordb/GraphTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public interface GraphTransaction extends
/**
* Execute a Cypher query with timeout.
* @param query Cypher query
* @param timeout
* @param timeout timeout in milliseconds
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> query(String query, long timeout);

/**
* Execute a Cypher read-only query with timeout.
* @param query Cypher query
* @param timeout
* @param timeout timeout in milliseconds
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> readOnlyQuery(String query, long timeout);
Expand All @@ -73,7 +73,7 @@ public interface GraphTransaction extends
* Executes a cypher query with parameters and timeout.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @param timeout timeout in milliseconds
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> query(String query, Map<String, Object> params, long timeout);
Expand All @@ -82,7 +82,7 @@ public interface GraphTransaction extends
* Executes a cypher read-only query with parameters and timeout.
* @param query Cypher query.
* @param params parameters map.
* @param timeout
* @param timeout timeout in milliseconds
* @return a response which builds the result set with the query answer.
*/
Response<ResultSet> readOnlyQuery(String query, Map<String, Object> params, long timeout);
Expand Down Expand Up @@ -131,8 +131,8 @@ public interface GraphTransaction extends
void clear();

/**
*
* @return
* Executes the transaction and returns a list of the executed transaction commands answers
* @return a list of the executed transaction commands answers
*/
List<Response<?>> execGetResponse();

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/falkordb/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface Record {
* The value at the given field index
*
* @param index field index
* @param <T> return value type
*
* @return the value
*/
Expand All @@ -22,6 +23,7 @@ public interface Record {
* The value at the given field
*
* @param key header key
* @param <T> return value type
*
* @return the value
*/
Expand All @@ -30,7 +32,7 @@ public interface Record {
/**
* The value at the given field index (represented as String)
*
* @param index
* @param index field index
* @return string representation of the value
*/
String getString(int index);
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/falkordb/graph_entities/GraphEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void setId(long id) {
/**
* Adds a property to the entity, by composing name, type and value to a property object
*
* @param name
* @param value
* @param name property name
* @param value property value
*/
public void addProperty(String name, Object value) {
addProperty(new Property(name, value));
Expand All @@ -62,11 +62,9 @@ public Set<String> getEntityPropertyNames() {
/**
* Add a property to the entity
*
* @param property
* @param property property object
*/
public void addProperty(Property property) {


propertyMap.put(property.getName(), property);
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/falkordb/graph_entities/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public Node lastNode(){

/**
* Returns a node with specified index in the path.
* @param index index of the node.
* @return Node.
* @throws IndexOutOfBoundsException if the index is out of range
* ({@code index < 0 || index >= nodesCount()})
Expand All @@ -84,6 +85,7 @@ public Node getNode(int index){

/**
* Returns an edge with specified index in the path.
* @param index index of the edge.
* @return Edge.
* @throws IndexOutOfBoundsException if the index is out of range
* ({@code index < 0 || index >= length()})
Expand Down
20 changes: 16 additions & 4 deletions src/main/java/com/falkordb/graph_entities/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public final class Point {
private final double longitude;

/**
* @param latitude
* @param longitude
* @param latitude The latitude in degrees. It must be in the range [-90.0, +90.0]
* @param longitude The longitude in degrees. It must be in the range [-180.0, +180.0]
*/
public Point(double latitude, double longitude) {
this.latitude = latitude;
Expand All @@ -33,18 +33,30 @@ public Point(List<Double> values) {
this.longitude = values.get(1);
}

/**
* Get the latitude in degrees
* @return latitude
*/
public double getLatitude() {
return latitude;
}

/**
* Get the longitude in degrees
* @return longitude
*/
public double getLongitude() {
return longitude;
}

@Override
public boolean equals(Object other) {
if (this == other) return true;
if (!(other instanceof Point)) return false;
if (this == other){
return true;
}
if (!(other instanceof Point)){
return false;
}
Point o = (Point) other;
return Math.abs(latitude - o.latitude) < EPSILON &&
Math.abs(longitude - o.longitude) < EPSILON;
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/com/falkordb/graph_entities/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,22 @@ public class Property <T> {
private String name;
private T value;


/**
* Default constructor
*/
public Property() {

}

public Property() {}

/**
* Parameterized constructor
*
* @param name
* @param value
* @param name property name
* @param value property value
*/
public Property(String name, T value) {
this.name = name;
this.value = value;
}


//getters & setters

/**
* @return property name
*/
Expand All @@ -41,7 +35,7 @@ public String getName() {
}

/**
* @param name - property name to be set
* @param name property name to be set
*/
public void setName(String name) {
this.name = name;
Expand Down Expand Up @@ -85,7 +79,7 @@ public int hashCode() {

/**
* Default toString implementation
* @return
* @return string representation of the property
*/
@Override
public String toString() {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/falkordb/impl/api/AbstractGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public abstract class AbstractGraph implements Graph {
/**
* Sends a query to the redis graph.Implementation and context dependent
* @param preparedQuery prepared query
* @param timeout
* @param timeout timeout in milliseconds
* @return Result set
*/
protected abstract ResultSet sendQuery(String preparedQuery, long timeout);

/**
* Sends a read-query to the redis graph.Implementation and context dependent
* @param preparedQuery prepared query
* @param timeout
* @param timeout timeout in milliseconds
* @return Result set
*/
protected abstract ResultSet sendReadOnlyQuery(String preparedQuery, long timeout);
Expand Down Expand Up @@ -109,9 +109,9 @@ public ResultSet readOnlyQuery(String query, Map<String, Object> params) {

/**
* Executes a cypher query with parameters and timeout.
* @param timeout
* @param query Cypher query.
* @param params parameters map.
* @param timeout timeout in milliseconds
* @return a result set.
*/
@Override
Expand All @@ -122,9 +122,9 @@ public ResultSet query(String query, Map<String, Object> params, long timeout) {

/**
* Executes a cypher read-only query with parameters and timeout.
* @param timeout
* @param query Cypher query.
* @param params parameters map.
* @param timeout timeout in milliseconds
* @return a result set.
*/
@Override
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/falkordb/impl/api/GraphCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import redis.clients.jedis.commands.ProtocolCommand;

/**
*
* An enum which aligned to FalkorDB Graph commands
*/
public enum GraphCommand implements ProtocolCommand {
QUERY("graph.QUERY"),
Expand All @@ -12,10 +12,17 @@ public enum GraphCommand implements ProtocolCommand {

private final byte[] raw;

/**
* Generates a new instance with a specific command
* @param alt command
*/
GraphCommand(String alt) {
raw = SafeEncoder.encode(alt);
}

/**
* Returns the raw command
*/
public byte[] getRaw() {
return raw;
}
Expand Down
Loading

0 comments on commit 71cbb6a

Please sign in to comment.