diff --git a/src/main/java/com/falkordb/Driver.java b/src/main/java/com/falkordb/Driver.java index 8e618d9..8f94c61 100644 --- a/src/main/java/com/falkordb/Driver.java +++ b/src/main/java/com/falkordb/Driver.java @@ -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(); } diff --git a/src/main/java/com/falkordb/FalkorDB.java b/src/main/java/com/falkordb/FalkorDB.java index 77b3fe3..5cd1dc5 100644 --- a/src/main/java/com/falkordb/FalkorDB.java +++ b/src/main/java/com/falkordb/FalkorDB.java @@ -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); } diff --git a/src/main/java/com/falkordb/Graph.java b/src/main/java/com/falkordb/Graph.java index b40191d..18bd93e 100644 --- a/src/main/java/com/falkordb/Graph.java +++ b/src/main/java/com/falkordb/Graph.java @@ -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 params, long timeout); @@ -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 params, long timeout); diff --git a/src/main/java/com/falkordb/GraphContext.java b/src/main/java/com/falkordb/GraphContext.java index cb77de7..3b37b4e 100644 --- a/src/main/java/com/falkordb/GraphContext.java +++ b/src/main/java/com/falkordb/GraphContext.java @@ -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(); } diff --git a/src/main/java/com/falkordb/GraphPipeline.java b/src/main/java/com/falkordb/GraphPipeline.java index 209554b..67459f8 100644 --- a/src/main/java/com/falkordb/GraphPipeline.java +++ b/src/main/java/com/falkordb/GraphPipeline.java @@ -40,7 +40,7 @@ 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 query(String query, long timeout); @@ -48,7 +48,7 @@ public interface GraphPipeline extends /** * 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 readOnlyQuery(String query, long timeout); @@ -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 query(String query, Map params, long timeout); @@ -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 readOnlyQuery(String query, Map params, long timeout); diff --git a/src/main/java/com/falkordb/GraphTransaction.java b/src/main/java/com/falkordb/GraphTransaction.java index acf6f21..190bde2 100644 --- a/src/main/java/com/falkordb/GraphTransaction.java +++ b/src/main/java/com/falkordb/GraphTransaction.java @@ -40,7 +40,7 @@ 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 query(String query, long timeout); @@ -48,7 +48,7 @@ public interface GraphTransaction extends /** * 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 readOnlyQuery(String query, long timeout); @@ -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 query(String query, Map params, long timeout); @@ -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 readOnlyQuery(String query, Map params, long timeout); @@ -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> execGetResponse(); diff --git a/src/main/java/com/falkordb/Record.java b/src/main/java/com/falkordb/Record.java index 4b05801..e29787f 100644 --- a/src/main/java/com/falkordb/Record.java +++ b/src/main/java/com/falkordb/Record.java @@ -13,6 +13,7 @@ public interface Record { * The value at the given field index * * @param index field index + * @param return value type * * @return the value */ @@ -22,6 +23,7 @@ public interface Record { * The value at the given field * * @param key header key + * @param return value type * * @return the value */ @@ -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); diff --git a/src/main/java/com/falkordb/graph_entities/GraphEntity.java b/src/main/java/com/falkordb/graph_entities/GraphEntity.java index 777bec1..ce7c444 100644 --- a/src/main/java/com/falkordb/graph_entities/GraphEntity.java +++ b/src/main/java/com/falkordb/graph_entities/GraphEntity.java @@ -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)); @@ -62,11 +62,9 @@ public Set getEntityPropertyNames() { /** * Add a property to the entity * - * @param property + * @param property property object */ public void addProperty(Property property) { - - propertyMap.put(property.getName(), property); } diff --git a/src/main/java/com/falkordb/graph_entities/Path.java b/src/main/java/com/falkordb/graph_entities/Path.java index 59a8233..2a050ff 100644 --- a/src/main/java/com/falkordb/graph_entities/Path.java +++ b/src/main/java/com/falkordb/graph_entities/Path.java @@ -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()}) @@ -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()}) diff --git a/src/main/java/com/falkordb/graph_entities/Point.java b/src/main/java/com/falkordb/graph_entities/Point.java index 5129824..c2b4fff 100644 --- a/src/main/java/com/falkordb/graph_entities/Point.java +++ b/src/main/java/com/falkordb/graph_entities/Point.java @@ -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; @@ -33,18 +33,30 @@ public Point(List 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; diff --git a/src/main/java/com/falkordb/graph_entities/Property.java b/src/main/java/com/falkordb/graph_entities/Property.java index 87af1ee..220fcbb 100644 --- a/src/main/java/com/falkordb/graph_entities/Property.java +++ b/src/main/java/com/falkordb/graph_entities/Property.java @@ -11,28 +11,22 @@ public class Property { 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 */ @@ -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; @@ -85,7 +79,7 @@ public int hashCode() { /** * Default toString implementation - * @return + * @return string representation of the property */ @Override public String toString() { diff --git a/src/main/java/com/falkordb/impl/api/AbstractGraph.java b/src/main/java/com/falkordb/impl/api/AbstractGraph.java index 6372b05..6df718d 100644 --- a/src/main/java/com/falkordb/impl/api/AbstractGraph.java +++ b/src/main/java/com/falkordb/impl/api/AbstractGraph.java @@ -28,7 +28,7 @@ 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); @@ -36,7 +36,7 @@ public abstract class AbstractGraph implements Graph { /** * 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); @@ -109,9 +109,9 @@ public ResultSet readOnlyQuery(String query, Map 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 @@ -122,9 +122,9 @@ public ResultSet query(String query, Map 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 diff --git a/src/main/java/com/falkordb/impl/api/GraphCommand.java b/src/main/java/com/falkordb/impl/api/GraphCommand.java index 906609e..f351eee 100644 --- a/src/main/java/com/falkordb/impl/api/GraphCommand.java +++ b/src/main/java/com/falkordb/impl/api/GraphCommand.java @@ -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"), @@ -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; } diff --git a/src/main/java/com/falkordb/impl/api/GraphContextImpl.java b/src/main/java/com/falkordb/impl/api/GraphContextImpl.java index 534ca30..fe49dce 100644 --- a/src/main/java/com/falkordb/impl/api/GraphContextImpl.java +++ b/src/main/java/com/falkordb/impl/api/GraphContextImpl.java @@ -27,7 +27,9 @@ public class GraphContextImpl extends AbstractGraph implements GraphContext { /** * Generates a new instance with a specific Jedis connection - * @param connectionContext + * @param connection Jedis connection + * @param cache GraphCache + * @param graphId graph id */ public GraphContextImpl(Jedis connection, GraphCache cache, String graphId) { this.connection = connection; diff --git a/src/main/java/com/falkordb/impl/api/GraphImpl.java b/src/main/java/com/falkordb/impl/api/GraphImpl.java index 7e9c6fb..161580b 100644 --- a/src/main/java/com/falkordb/impl/api/GraphImpl.java +++ b/src/main/java/com/falkordb/impl/api/GraphImpl.java @@ -8,7 +8,7 @@ import redis.clients.jedis.util.SafeEncoder; /** - * + * An implementation of GraphContextGenerator. */ public class GraphImpl extends AbstractGraph implements GraphContextGenerator { diff --git a/src/main/java/com/falkordb/impl/api/GraphPipelineImpl.java b/src/main/java/com/falkordb/impl/api/GraphPipelineImpl.java index 85384b3..b89f27a 100644 --- a/src/main/java/com/falkordb/impl/api/GraphPipelineImpl.java +++ b/src/main/java/com/falkordb/impl/api/GraphPipelineImpl.java @@ -69,7 +69,7 @@ public ResultSet build(Object o) { * * NOTE: timeout is simply sent to DB. Socket timeout will not be changed. * @param query Cypher query - * @param timeout + * @param timeout timeout in milliseconds * @return a response which builds the result set with the query answer. */ @Override @@ -90,7 +90,7 @@ public ResultSet build(Object o) { * * NOTE: timeout is simply sent to DB. Socket timeout will not be changed. * @param query Cypher query - * @param timeout + * @param timeout timeout in milliseconds * @return a response which builds the result set with the query answer. */ @Override @@ -151,7 +151,7 @@ public ResultSet build(Object o) { * 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. */ @Override @@ -175,7 +175,7 @@ public ResultSet build(Object o) { * 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. */ @Override diff --git a/src/main/java/com/falkordb/impl/api/GraphTransaction.java b/src/main/java/com/falkordb/impl/api/GraphTransaction.java index feee590..7899537 100644 --- a/src/main/java/com/falkordb/impl/api/GraphTransaction.java +++ b/src/main/java/com/falkordb/impl/api/GraphTransaction.java @@ -92,7 +92,7 @@ public ResultSet build(Object o) { * * NOTE: timeout is simply sent to DB. Socket timeout will not be changed. * @param query Cypher query - * @param timeout + * @param timeout timeout in milliseconds * @return a response which builds the result set with the query answer. */ @Override @@ -152,7 +152,7 @@ public ResultSet build(Object o) { * NOTE: timeout is simply sent to DB. Socket timeout will not be changed. * @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. */ @Override @@ -175,7 +175,7 @@ public ResultSet build(Object o) { * NOTE: timeout is simply sent to DB. Socket timeout will not be changed. * @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. */ @Override diff --git a/src/main/java/com/falkordb/impl/graph_cache/GraphCache.java b/src/main/java/com/falkordb/impl/graph_cache/GraphCache.java index 9d05b1f..6f95db5 100644 --- a/src/main/java/com/falkordb/impl/graph_cache/GraphCache.java +++ b/src/main/java/com/falkordb/impl/graph_cache/GraphCache.java @@ -13,7 +13,7 @@ public class GraphCache { private final GraphCacheList relationshipTypes; /** - * + * Default constructor */ public GraphCache() { this.labels = new GraphCacheList("db.labels"); @@ -22,7 +22,8 @@ public GraphCache() { } /** - * @param index - index of label + * @param index index of label + * @param graph source graph * @return requested label */ public String getLabel(int index, Graph graph) { @@ -31,6 +32,7 @@ public String getLabel(int index, Graph graph) { /** * @param index index of the relationship type + * @param graph source graph * @return requested relationship type */ public String getRelationshipType(int index, Graph graph) { @@ -39,12 +41,16 @@ public String getRelationshipType(int index, Graph graph) { /** * @param index index of property name + * @param graph source graph * @return requested property */ public String getPropertyName(int index, Graph graph) { return propertyNames.getCachedData(index, graph); } + /** + * Clears the cache + */ public void clear() { labels.clear(); propertyNames.clear();