From bf3ceba24808c84d371836a040aec0252818763e Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Mon, 27 Nov 2023 11:17:39 +0200 Subject: [PATCH 1/2] initial commit --- pom.xml | 36 ++++------ .../RedisGraph.java => falkordb/Graph.java} | 8 +-- .../GraphContext.java} | 8 +-- .../com/falkordb/GraphContextGenerator.java | 11 +++ .../GraphPipeline.java} | 4 +- .../GraphTransaction.java} | 4 +- .../redisgraph => falkordb}/Header.java | 2 +- .../redisgraph => falkordb}/Record.java | 6 +- .../redisgraph => falkordb}/ResultSet.java | 2 +- .../redisgraph => falkordb}/Statistics.java | 2 +- .../falkordb/exceptions/GraphException.java | 23 ++++++ .../graph_entities/Edge.java | 2 +- .../graph_entities/GraphEntity.java | 2 +- .../graph_entities/Node.java | 2 +- .../graph_entities/Path.java | 2 +- .../graph_entities/Point.java | 2 +- .../graph_entities/Property.java | 2 +- .../redisgraph => falkordb}/impl/Utils.java | 2 +- .../impl/api/AbstractGraph.java} | 10 +-- .../impl/api/ContextedGraph.java} | 70 +++++++++---------- .../impl/api/Graph.java} | 60 ++++++++-------- .../falkordb/impl/api/GraphCacheHolder.java | 8 +++ .../impl/api/GraphCommand.java} | 6 +- .../impl/api/GraphPipeline.java} | 40 +++++------ .../impl/api/GraphTransaction.java} | 44 ++++++------ .../impl/graph_cache/GraphCache.java | 10 +-- .../impl/graph_cache/GraphCacheList.java | 12 ++-- .../impl/graph_cache/GraphCaches.java} | 18 ++--- .../impl/resultset/HeaderImpl.java | 4 +- .../impl/resultset/RecordImpl.java | 4 +- .../impl/resultset/ResultSetImpl.java | 26 +++---- .../impl/resultset/ResultSetScalarTypes.java | 2 +- .../impl/resultset/StatisticsImpl.java | 6 +- .../RedisGraphContextGenerator.java | 11 --- .../exceptions/JRedisGraphException.java | 23 ------ .../impl/api/RedisGraphCacheHolder.java | 8 --- .../GraphAPITest.java} | 30 ++++---- .../InstantiationTest.java | 16 +++-- .../redisgraph => falkordb}/IterableTest.java | 10 +-- .../redisgraph => falkordb}/PipelineTest.java | 31 ++++---- .../TransactionTest.java | 39 ++++++----- .../exceptions/GraphErrorTest.java} | 43 ++++++------ .../graph_entities/PathTest.java | 6 +- .../impl/UtilsTest.java | 4 +- .../test/utils/PathBuilder.java | 8 +-- .../test/utils/PathBuilderTest.java | 4 +- 46 files changed, 344 insertions(+), 329 deletions(-) rename src/main/java/com/{redislabs/redisgraph/RedisGraph.java => falkordb/Graph.java} (95%) rename src/main/java/com/{redislabs/redisgraph/RedisGraphContext.java => falkordb/GraphContext.java} (83%) create mode 100644 src/main/java/com/falkordb/GraphContextGenerator.java rename src/main/java/com/{redislabs/redisgraph/RedisGraphPipeline.java => falkordb/GraphPipeline.java} (98%) rename src/main/java/com/{redislabs/redisgraph/RedisGraphTransaction.java => falkordb/GraphTransaction.java} (98%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/Header.java (91%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/Record.java (87%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/ResultSet.java (86%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/Statistics.java (97%) create mode 100644 src/main/java/com/falkordb/exceptions/GraphException.java rename src/main/java/com/{redislabs/redisgraph => falkordb}/graph_entities/Edge.java (98%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/graph_entities/GraphEntity.java (98%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/graph_entities/Node.java (97%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/graph_entities/Path.java (98%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/graph_entities/Point.java (96%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/graph_entities/Property.java (97%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/impl/Utils.java (99%) rename src/main/java/com/{redislabs/redisgraph/impl/api/AbstractRedisGraph.java => falkordb/impl/api/AbstractGraph.java} (96%) rename src/main/java/com/{redislabs/redisgraph/impl/api/ContextedRedisGraph.java => falkordb/impl/api/ContextedGraph.java} (71%) rename src/main/java/com/{redislabs/redisgraph/impl/api/RedisGraph.java => falkordb/impl/api/Graph.java} (62%) create mode 100644 src/main/java/com/falkordb/impl/api/GraphCacheHolder.java rename src/main/java/com/{redislabs/redisgraph/impl/api/RedisGraphCommand.java => falkordb/impl/api/GraphCommand.java} (71%) rename src/main/java/com/{redislabs/redisgraph/impl/api/RedisGraphPipeline.java => falkordb/impl/api/GraphPipeline.java} (84%) rename src/main/java/com/{redislabs/redisgraph/impl/api/RedisGraphTransaction.java => falkordb/impl/api/GraphTransaction.java} (84%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/impl/graph_cache/GraphCache.java (78%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/impl/graph_cache/GraphCacheList.java (84%) rename src/main/java/com/{redislabs/redisgraph/impl/graph_cache/RedisGraphCaches.java => falkordb/impl/graph_cache/GraphCaches.java} (76%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/impl/resultset/HeaderImpl.java (96%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/impl/resultset/RecordImpl.java (94%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/impl/resultset/ResultSetImpl.java (94%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/impl/resultset/ResultSetScalarTypes.java (92%) rename src/main/java/com/{redislabs/redisgraph => falkordb}/impl/resultset/StatisticsImpl.java (96%) delete mode 100644 src/main/java/com/redislabs/redisgraph/RedisGraphContextGenerator.java delete mode 100644 src/main/java/com/redislabs/redisgraph/exceptions/JRedisGraphException.java delete mode 100644 src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphCacheHolder.java rename src/test/java/com/{redislabs/redisgraph/RedisGraphAPITest.java => falkordb/GraphAPITest.java} (98%) rename src/test/java/com/{redislabs/redisgraph => falkordb}/InstantiationTest.java (76%) rename src/test/java/com/{redislabs/redisgraph => falkordb}/IterableTest.java (84%) rename src/test/java/com/{redislabs/redisgraph => falkordb}/PipelineTest.java (91%) rename src/test/java/com/{redislabs/redisgraph => falkordb}/TransactionTest.java (90%) rename src/test/java/com/{redislabs/redisgraph/exceptions/JRedisGraphErrorTest.java => falkordb/exceptions/GraphErrorTest.java} (73%) rename src/test/java/com/{redislabs/redisgraph => falkordb}/graph_entities/PathTest.java (93%) rename src/test/java/com/{redislabs/redisgraph => falkordb}/impl/UtilsTest.java (98%) rename src/test/java/com/{redislabs/redisgraph => falkordb}/test/utils/PathBuilder.java (87%) rename src/test/java/com/{redislabs/redisgraph => falkordb}/test/utils/PathBuilderTest.java (90%) diff --git a/pom.xml b/pom.xml index fd096c0..9c5d73b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,41 +4,31 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.redislabs - jredisgraph - 2.6.0-SNAPSHOT + com.falkordb + jfalkordb + 0.0.1-SNAPSHOT - JRedisGraph - Official client for Redis-Graph - https://redisgraph.io + JFalkorDB + Official client for falkordb + https://www.falkordb.com - RedisLabs - www.redislabs.com + FalkorBD + www.falkordb.com CircleCI - https://circleci.com/gh/RedisGraph/JRedisGraph + https://circleci.com/gh/FalkorDB/JFalkorDB - https://github.com/RedisGraph/JRedisGraph/issues + https://github.com/FalkorDB/JFalkorDB/issues Github - https://github.com/RedisGraph/JRedisGraph - scm:git:git://github.com/RedisGraph/JRedisGraph.git - scm:git:git@github.com:RedisGraph/JRedisGraph.git + https://github.com/FalkorDB/JFalkorDB + scm:git:git://github.com/FalkorDB/JFalkorDB.git + scm:git:git@github.com:FalkorDB/JFalkorDB.git - - - Roi Lipman - Redis Labs, Inc. - - - Guy Korland - Redis Labs, Inc. - - BSD 3 Clause diff --git a/src/main/java/com/redislabs/redisgraph/RedisGraph.java b/src/main/java/com/falkordb/Graph.java similarity index 95% rename from src/main/java/com/redislabs/redisgraph/RedisGraph.java rename to src/main/java/com/falkordb/Graph.java index f5c9a62..054eafb 100644 --- a/src/main/java/com/redislabs/redisgraph/RedisGraph.java +++ b/src/main/java/com/falkordb/Graph.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import java.io.Closeable; import java.util.List; @@ -6,10 +6,10 @@ import redis.clients.jedis.Jedis; -public interface RedisGraph extends Closeable { +public interface Graph extends Closeable { - public static RedisGraph with(Jedis jedis) { - return new com.redislabs.redisgraph.impl.api.RedisGraph(jedis); + public static Graph with(Jedis jedis) { + return new com.falkordb.impl.api.Graph(jedis); } /** diff --git a/src/main/java/com/redislabs/redisgraph/RedisGraphContext.java b/src/main/java/com/falkordb/GraphContext.java similarity index 83% rename from src/main/java/com/redislabs/redisgraph/RedisGraphContext.java rename to src/main/java/com/falkordb/GraphContext.java index 44d6319..f44d585 100644 --- a/src/main/java/com/redislabs/redisgraph/RedisGraphContext.java +++ b/src/main/java/com/falkordb/GraphContext.java @@ -1,8 +1,8 @@ -package com.redislabs.redisgraph; +package com.falkordb; import redis.clients.jedis.Jedis; -public interface RedisGraphContext extends RedisGraph { +public interface GraphContext extends Graph { /** @@ -15,13 +15,13 @@ public interface RedisGraphContext extends RedisGraph { * 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 */ - RedisGraphTransaction multi(); + GraphTransaction multi(); /** * Returns a Redis pipeline object, over the connection context, with graph API capabilities * @return Redis pipeline object, over the connection context, with graph API capabilities */ - RedisGraphPipeline pipelined(); + GraphPipeline pipelined(); /** * Perform watch over given Redis keys diff --git a/src/main/java/com/falkordb/GraphContextGenerator.java b/src/main/java/com/falkordb/GraphContextGenerator.java new file mode 100644 index 0000000..9a77af7 --- /dev/null +++ b/src/main/java/com/falkordb/GraphContextGenerator.java @@ -0,0 +1,11 @@ +package com.falkordb; + +public interface GraphContextGenerator extends Graph { + + /** + * Generate a connection bounded api + * @return a connection bounded api + */ + GraphContext getContext(); + +} diff --git a/src/main/java/com/redislabs/redisgraph/RedisGraphPipeline.java b/src/main/java/com/falkordb/GraphPipeline.java similarity index 98% rename from src/main/java/com/redislabs/redisgraph/RedisGraphPipeline.java rename to src/main/java/com/falkordb/GraphPipeline.java index 8416f66..5518409 100644 --- a/src/main/java/com/redislabs/redisgraph/RedisGraphPipeline.java +++ b/src/main/java/com/falkordb/GraphPipeline.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import redis.clients.jedis.Response; import redis.clients.jedis.commands.BasicRedisPipeline; @@ -17,7 +17,7 @@ /** * An interface which aligned to Jedis Pipeline interface */ -public interface RedisGraphPipeline extends +public interface GraphPipeline extends MultiKeyBinaryRedisPipeline, MultiKeyCommandsPipeline, ClusterPipeline, BinaryScriptingCommandsPipeline, ScriptingCommandsPipeline, diff --git a/src/main/java/com/redislabs/redisgraph/RedisGraphTransaction.java b/src/main/java/com/falkordb/GraphTransaction.java similarity index 98% rename from src/main/java/com/redislabs/redisgraph/RedisGraphTransaction.java rename to src/main/java/com/falkordb/GraphTransaction.java index cbcd127..a7811df 100644 --- a/src/main/java/com/redislabs/redisgraph/RedisGraphTransaction.java +++ b/src/main/java/com/falkordb/GraphTransaction.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import redis.clients.jedis.Response; import redis.clients.jedis.commands.BasicRedisPipeline; @@ -17,7 +17,7 @@ /** * An interface which aligned to Jedis transactional interface */ -public interface RedisGraphTransaction extends +public interface GraphTransaction extends MultiKeyBinaryRedisPipeline, MultiKeyCommandsPipeline, ClusterPipeline, BinaryScriptingCommandsPipeline, ScriptingCommandsPipeline, diff --git a/src/main/java/com/redislabs/redisgraph/Header.java b/src/main/java/com/falkordb/Header.java similarity index 91% rename from src/main/java/com/redislabs/redisgraph/Header.java rename to src/main/java/com/falkordb/Header.java index a8156aa..1058f39 100644 --- a/src/main/java/com/redislabs/redisgraph/Header.java +++ b/src/main/java/com/falkordb/Header.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import java.util.List; diff --git a/src/main/java/com/redislabs/redisgraph/Record.java b/src/main/java/com/falkordb/Record.java similarity index 87% rename from src/main/java/com/redislabs/redisgraph/Record.java rename to src/main/java/com/falkordb/Record.java index f6b928f..4b05801 100644 --- a/src/main/java/com/redislabs/redisgraph/Record.java +++ b/src/main/java/com/falkordb/Record.java @@ -1,11 +1,11 @@ -package com.redislabs.redisgraph; +package com.falkordb; import java.util.List; /** - * Container for RedisGraph result values. + * Container for Graph result values. * - * List records are returned from RedisGraph statement execution, contained within a ResultSet. + * List records are returned from Graph statement execution, contained within a ResultSet. */ public interface Record { diff --git a/src/main/java/com/redislabs/redisgraph/ResultSet.java b/src/main/java/com/falkordb/ResultSet.java similarity index 86% rename from src/main/java/com/redislabs/redisgraph/ResultSet.java rename to src/main/java/com/falkordb/ResultSet.java index d86ff19..36fcd88 100644 --- a/src/main/java/com/redislabs/redisgraph/ResultSet.java +++ b/src/main/java/com/falkordb/ResultSet.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import java.util.Iterator; diff --git a/src/main/java/com/redislabs/redisgraph/Statistics.java b/src/main/java/com/falkordb/Statistics.java similarity index 97% rename from src/main/java/com/redislabs/redisgraph/Statistics.java rename to src/main/java/com/falkordb/Statistics.java index 9d7453f..1aac2b7 100644 --- a/src/main/java/com/redislabs/redisgraph/Statistics.java +++ b/src/main/java/com/falkordb/Statistics.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; public interface Statistics { diff --git a/src/main/java/com/falkordb/exceptions/GraphException.java b/src/main/java/com/falkordb/exceptions/GraphException.java new file mode 100644 index 0000000..0126eb7 --- /dev/null +++ b/src/main/java/com/falkordb/exceptions/GraphException.java @@ -0,0 +1,23 @@ +package com.falkordb.exceptions; + +import redis.clients.jedis.exceptions.JedisDataException; + +/** + * Graph query evaluation exception. An instance of GraphException is + * thrown when Graph encounters an error during query evaluation. + */ +public class GraphException extends JedisDataException { + private static final long serialVersionUID = -476099681322055468L; + + public GraphException(String message) { + super(message); + } + + public GraphException(Throwable cause) { + super(cause); + } + + public GraphException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/com/redislabs/redisgraph/graph_entities/Edge.java b/src/main/java/com/falkordb/graph_entities/Edge.java similarity index 98% rename from src/main/java/com/redislabs/redisgraph/graph_entities/Edge.java rename to src/main/java/com/falkordb/graph_entities/Edge.java index b36db16..54454fb 100644 --- a/src/main/java/com/redislabs/redisgraph/graph_entities/Edge.java +++ b/src/main/java/com/falkordb/graph_entities/Edge.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.graph_entities; +package com.falkordb.graph_entities; import java.util.Objects; diff --git a/src/main/java/com/redislabs/redisgraph/graph_entities/GraphEntity.java b/src/main/java/com/falkordb/graph_entities/GraphEntity.java similarity index 98% rename from src/main/java/com/redislabs/redisgraph/graph_entities/GraphEntity.java rename to src/main/java/com/falkordb/graph_entities/GraphEntity.java index 2919747..777bec1 100644 --- a/src/main/java/com/redislabs/redisgraph/graph_entities/GraphEntity.java +++ b/src/main/java/com/falkordb/graph_entities/GraphEntity.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.graph_entities; +package com.falkordb.graph_entities; import java.util.*; diff --git a/src/main/java/com/redislabs/redisgraph/graph_entities/Node.java b/src/main/java/com/falkordb/graph_entities/Node.java similarity index 97% rename from src/main/java/com/redislabs/redisgraph/graph_entities/Node.java rename to src/main/java/com/falkordb/graph_entities/Node.java index 3185b43..5178bca 100644 --- a/src/main/java/com/redislabs/redisgraph/graph_entities/Node.java +++ b/src/main/java/com/falkordb/graph_entities/Node.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.graph_entities; +package com.falkordb.graph_entities; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/redislabs/redisgraph/graph_entities/Path.java b/src/main/java/com/falkordb/graph_entities/Path.java similarity index 98% rename from src/main/java/com/redislabs/redisgraph/graph_entities/Path.java rename to src/main/java/com/falkordb/graph_entities/Path.java index a77eaea..59a8233 100644 --- a/src/main/java/com/redislabs/redisgraph/graph_entities/Path.java +++ b/src/main/java/com/falkordb/graph_entities/Path.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.graph_entities; +package com.falkordb.graph_entities; import java.util.List; import java.util.Objects; diff --git a/src/main/java/com/redislabs/redisgraph/graph_entities/Point.java b/src/main/java/com/falkordb/graph_entities/Point.java similarity index 96% rename from src/main/java/com/redislabs/redisgraph/graph_entities/Point.java rename to src/main/java/com/falkordb/graph_entities/Point.java index 5aeb4d3..5129824 100644 --- a/src/main/java/com/redislabs/redisgraph/graph_entities/Point.java +++ b/src/main/java/com/falkordb/graph_entities/Point.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.graph_entities; +package com.falkordb.graph_entities; import java.util.List; import java.util.Objects; diff --git a/src/main/java/com/redislabs/redisgraph/graph_entities/Property.java b/src/main/java/com/falkordb/graph_entities/Property.java similarity index 97% rename from src/main/java/com/redislabs/redisgraph/graph_entities/Property.java rename to src/main/java/com/falkordb/graph_entities/Property.java index 249bd64..87af1ee 100644 --- a/src/main/java/com/redislabs/redisgraph/graph_entities/Property.java +++ b/src/main/java/com/falkordb/graph_entities/Property.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.graph_entities; +package com.falkordb.graph_entities; import java.util.Objects; diff --git a/src/main/java/com/redislabs/redisgraph/impl/Utils.java b/src/main/java/com/falkordb/impl/Utils.java similarity index 99% rename from src/main/java/com/redislabs/redisgraph/impl/Utils.java rename to src/main/java/com/falkordb/impl/Utils.java index d508f9d..70bb00e 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/Utils.java +++ b/src/main/java/com/falkordb/impl/Utils.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.impl; +package com.falkordb.impl; import org.apache.commons.text.translate.AggregateTranslator; import org.apache.commons.text.translate.CharSequenceTranslator; diff --git a/src/main/java/com/redislabs/redisgraph/impl/api/AbstractRedisGraph.java b/src/main/java/com/falkordb/impl/api/AbstractGraph.java similarity index 96% rename from src/main/java/com/redislabs/redisgraph/impl/api/AbstractRedisGraph.java rename to src/main/java/com/falkordb/impl/api/AbstractGraph.java index 57fce53..d2c2c80 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/api/AbstractRedisGraph.java +++ b/src/main/java/com/falkordb/impl/api/AbstractGraph.java @@ -1,8 +1,8 @@ -package com.redislabs.redisgraph.impl.api; +package com.falkordb.impl.api; -import com.redislabs.redisgraph.RedisGraph; -import com.redislabs.redisgraph.ResultSet; -import com.redislabs.redisgraph.impl.Utils; +import com.falkordb.Graph; +import com.falkordb.ResultSet; +import com.falkordb.impl.Utils; import redis.clients.jedis.Jedis; import java.util.List; @@ -11,7 +11,7 @@ /** * An abstract class to handle non implementation specific user requests */ -public abstract class AbstractRedisGraph implements RedisGraph { +public abstract class AbstractGraph implements Graph { /** * Inherited classes should return a Jedis connection, with respect to their context diff --git a/src/main/java/com/redislabs/redisgraph/impl/api/ContextedRedisGraph.java b/src/main/java/com/falkordb/impl/api/ContextedGraph.java similarity index 71% rename from src/main/java/com/redislabs/redisgraph/impl/api/ContextedRedisGraph.java rename to src/main/java/com/falkordb/impl/api/ContextedGraph.java index 4d6fe34..b86528b 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/api/ContextedRedisGraph.java +++ b/src/main/java/com/falkordb/impl/api/ContextedGraph.java @@ -1,13 +1,13 @@ -package com.redislabs.redisgraph.impl.api; +package com.falkordb.impl.api; import java.util.List; -import com.redislabs.redisgraph.RedisGraphContext; -import com.redislabs.redisgraph.ResultSet; -import com.redislabs.redisgraph.exceptions.JRedisGraphException; -import com.redislabs.redisgraph.impl.Utils; -import com.redislabs.redisgraph.impl.graph_cache.RedisGraphCaches; -import com.redislabs.redisgraph.impl.resultset.ResultSetImpl; +import com.falkordb.GraphContext; +import com.falkordb.ResultSet; +import com.falkordb.exceptions.GraphException; +import com.falkordb.impl.Utils; +import com.falkordb.impl.graph_cache.GraphCaches; +import com.falkordb.impl.resultset.ResultSetImpl; import redis.clients.jedis.Client; import redis.clients.jedis.Jedis; @@ -15,19 +15,19 @@ import redis.clients.jedis.util.SafeEncoder; /** - * An implementation of RedisGraphContext. Allows sending RedisGraph and some Redis commands, + * An implementation of GraphContext. Allows sending Graph and some Redis commands, * within a specific connection context */ -public class ContextedRedisGraph extends AbstractRedisGraph implements RedisGraphContext, RedisGraphCacheHolder { +public class ContextedGraph extends AbstractGraph implements GraphContext, GraphCacheHolder { private final Jedis connectionContext; - private RedisGraphCaches caches; + private GraphCaches caches; /** * Generates a new instance with a specific Jedis connection * @param connectionContext */ - public ContextedRedisGraph(Jedis connectionContext) { + public ContextedGraph(Jedis connectionContext) { this.connectionContext = connectionContext; } @@ -51,12 +51,12 @@ protected ResultSet sendQuery(String graphId, String preparedQuery) { Jedis conn = getConnection(); try { @SuppressWarnings("unchecked") - List rawResponse = (List) conn.sendCommand(RedisGraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); + List rawResponse = (List) conn.sendCommand(GraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); return new ResultSetImpl(rawResponse, this, caches.getGraphCache(graphId)); - } catch (JRedisGraphException rt) { + } catch (GraphException rt) { throw rt; } catch (JedisDataException j) { - throw new JRedisGraphException(j); + throw new GraphException(j); } } @@ -71,12 +71,12 @@ protected ResultSet sendReadOnlyQuery(String graphId, String preparedQuery) { Jedis conn = getConnection(); try { @SuppressWarnings("unchecked") - List rawResponse = (List) conn.sendCommand(RedisGraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); + List rawResponse = (List) conn.sendCommand(GraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); return new ResultSetImpl(rawResponse, this, caches.getGraphCache(graphId)); - } catch (JRedisGraphException ge) { + } catch (GraphException ge) { throw ge; } catch (JedisDataException de) { - throw new JRedisGraphException(de); + throw new GraphException(de); } } @@ -92,13 +92,13 @@ protected ResultSet sendQuery(String graphId, String preparedQuery, long timeout Jedis conn = getConnection(); try { @SuppressWarnings("unchecked") - List rawResponse = (List) conn.sendBlockingCommand(RedisGraphCommand.QUERY, + List rawResponse = (List) conn.sendBlockingCommand(GraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return new ResultSetImpl(rawResponse, this, caches.getGraphCache(graphId)); - } catch (JRedisGraphException rt) { + } catch (GraphException rt) { throw rt; } catch (JedisDataException j) { - throw new JRedisGraphException(j); + throw new GraphException(j); } } @@ -114,13 +114,13 @@ protected ResultSet sendReadOnlyQuery(String graphId, String preparedQuery, long Jedis conn = getConnection(); try { @SuppressWarnings("unchecked") - List rawResponse = (List) conn.sendBlockingCommand(RedisGraphCommand.RO_QUERY, + List rawResponse = (List) conn.sendBlockingCommand(GraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return new ResultSetImpl(rawResponse, this, caches.getGraphCache(graphId)); - } catch (JRedisGraphException ge) { + } catch (GraphException ge) { throw ge; } catch (JedisDataException de) { - throw new JRedisGraphException(de); + throw new GraphException(de); } } @@ -133,30 +133,30 @@ public Jedis getConnectionContext() { } /** - * Creates a new RedisGraphTransaction transactional object - * @return new RedisGraphTransaction + * Creates a new GraphTransaction transactional object + * @return new GraphTransaction */ @Override - public RedisGraphTransaction multi() { + public GraphTransaction multi() { Jedis jedis = getConnection(); Client client = jedis.getClient(); client.multi(); client.getOne(); - RedisGraphTransaction transaction = new RedisGraphTransaction(client, this); - transaction.setRedisGraphCaches(caches); + GraphTransaction transaction = new GraphTransaction(client, this); + transaction.setGraphCaches(caches); return transaction; } /** - * Creates a new RedisGraphPipeline pipeline object - * @return new RedisGraphPipeline + * Creates a new GraphPipeline pipeline object + * @return new GraphPipeline */ @Override - public RedisGraphPipeline pipelined() { + public GraphPipeline pipelined() { Jedis jedis = getConnection(); Client client = jedis.getClient(); - RedisGraphPipeline pipeline = new RedisGraphPipeline(client, this); - pipeline.setRedisGraphCaches(caches); + GraphPipeline pipeline = new GraphPipeline(client, this); + pipeline.setGraphCaches(caches); return pipeline; } @@ -189,7 +189,7 @@ public String deleteGraph(String graphId) { Jedis conn = getConnection(); Object response; try { - response = conn.sendCommand(RedisGraphCommand.DELETE, graphId); + response = conn.sendCommand(GraphCommand.DELETE, graphId); } catch (Exception e) { conn.close(); throw e; @@ -209,7 +209,7 @@ public void close() { } @Override - public void setRedisGraphCaches(RedisGraphCaches caches) { + public void setGraphCaches(GraphCaches caches) { this.caches = caches; } diff --git a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraph.java b/src/main/java/com/falkordb/impl/api/Graph.java similarity index 62% rename from src/main/java/com/redislabs/redisgraph/impl/api/RedisGraph.java rename to src/main/java/com/falkordb/impl/api/Graph.java index d187f70..d744e80 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraph.java +++ b/src/main/java/com/falkordb/impl/api/Graph.java @@ -1,9 +1,9 @@ -package com.redislabs.redisgraph.impl.api; +package com.falkordb.impl.api; -import com.redislabs.redisgraph.RedisGraphContext; -import com.redislabs.redisgraph.RedisGraphContextGenerator; -import com.redislabs.redisgraph.ResultSet; -import com.redislabs.redisgraph.impl.graph_cache.RedisGraphCaches; +import com.falkordb.GraphContext; +import com.falkordb.GraphContextGenerator; +import com.falkordb.ResultSet; +import com.falkordb.impl.graph_cache.GraphCaches; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.util.Pool; @@ -12,17 +12,17 @@ /** * */ -public class RedisGraph extends AbstractRedisGraph implements RedisGraphContextGenerator { +public class Graph extends AbstractGraph implements GraphContextGenerator { private final Pool pool; private final Jedis jedis; - private final RedisGraphCaches caches = new RedisGraphCaches(); + private final GraphCaches caches = new GraphCaches(); /** * Creates a client running on the local machine */ - public RedisGraph() { + public Graph() { this("localhost", 6379); } @@ -32,7 +32,7 @@ public RedisGraph() { * @param host Redis host * @param port Redis port */ - public RedisGraph(String host, int port) { + public Graph(String host, int port) { this(new JedisPool(host, port)); } @@ -41,12 +41,12 @@ public RedisGraph(String host, int port) { * * @param pool bring your own Jedis pool */ - public RedisGraph(Pool pool) { + public Graph(Pool pool) { this.pool = pool; this.jedis = null; } - public RedisGraph(Jedis jedis) { + public Graph(Jedis jedis) { this.jedis = jedis; this.pool = null; } @@ -69,9 +69,9 @@ protected Jedis getConnection() { */ @Override protected ResultSet sendQuery(String graphId, String preparedQuery){ - try (ContextedRedisGraph contextedRedisGraph = new ContextedRedisGraph(getConnection())) { - contextedRedisGraph.setRedisGraphCaches(caches); - return contextedRedisGraph.sendQuery(graphId, preparedQuery); + try (ContextedGraph contextedGraph = new ContextedGraph(getConnection())) { + contextedGraph.setGraphCaches(caches); + return contextedGraph.sendQuery(graphId, preparedQuery); } } @@ -84,9 +84,9 @@ protected ResultSet sendQuery(String graphId, String preparedQuery){ */ @Override protected ResultSet sendReadOnlyQuery(String graphId, String preparedQuery){ - try (ContextedRedisGraph contextedRedisGraph = new ContextedRedisGraph(getConnection())) { - contextedRedisGraph.setRedisGraphCaches(caches); - return contextedRedisGraph.sendReadOnlyQuery(graphId, preparedQuery); + try (ContextedGraph contextedGraph = new ContextedGraph(getConnection())) { + contextedGraph.setGraphCaches(caches); + return contextedGraph.sendReadOnlyQuery(graphId, preparedQuery); } } @@ -100,9 +100,9 @@ protected ResultSet sendReadOnlyQuery(String graphId, String preparedQuery){ */ @Override protected ResultSet sendQuery(String graphId, String preparedQuery, long timeout){ - try (ContextedRedisGraph contextedRedisGraph = new ContextedRedisGraph(getConnection())) { - contextedRedisGraph.setRedisGraphCaches(caches); - return contextedRedisGraph.sendQuery(graphId, preparedQuery, timeout); + try (ContextedGraph contextedGraph = new ContextedGraph(getConnection())) { + contextedGraph.setGraphCaches(caches); + return contextedGraph.sendQuery(graphId, preparedQuery, timeout); } } @@ -116,9 +116,9 @@ protected ResultSet sendQuery(String graphId, String preparedQuery, long timeout */ @Override protected ResultSet sendReadOnlyQuery(String graphId, String preparedQuery, long timeout){ - try (ContextedRedisGraph contextedRedisGraph = new ContextedRedisGraph(getConnection())) { - contextedRedisGraph.setRedisGraphCaches(caches); - return contextedRedisGraph.sendReadOnlyQuery(graphId, preparedQuery, timeout); + try (ContextedGraph contextedGraph = new ContextedGraph(getConnection())) { + contextedGraph.setGraphCaches(caches); + return contextedGraph.sendReadOnlyQuery(graphId, preparedQuery, timeout); } } @@ -143,7 +143,7 @@ public void close() { @Override public String deleteGraph(String graphId) { try (Jedis conn = getConnection()) { - Object response = conn.sendCommand(RedisGraphCommand.DELETE, graphId); + Object response = conn.sendCommand(GraphCommand.DELETE, graphId); //clear local state caches.removeGraphCache(graphId); return SafeEncoder.encode((byte[]) response); @@ -151,13 +151,13 @@ public String deleteGraph(String graphId) { } /** - * Returns a new ContextedRedisGraph bounded to a Jedis connection from the Jedis pool - * @return ContextedRedisGraph + * Returns a new ContextedGraph bounded to a Jedis connection from the Jedis pool + * @return ContextedGraph */ @Override - public RedisGraphContext getContext() { - ContextedRedisGraph contextedRedisGraph = new ContextedRedisGraph(getConnection()); - contextedRedisGraph.setRedisGraphCaches(this.caches); - return contextedRedisGraph; + public GraphContext getContext() { + ContextedGraph contextedGraph = new ContextedGraph(getConnection()); + contextedGraph.setGraphCaches(this.caches); + return contextedGraph; } } diff --git a/src/main/java/com/falkordb/impl/api/GraphCacheHolder.java b/src/main/java/com/falkordb/impl/api/GraphCacheHolder.java new file mode 100644 index 0000000..8cdfaaa --- /dev/null +++ b/src/main/java/com/falkordb/impl/api/GraphCacheHolder.java @@ -0,0 +1,8 @@ +package com.falkordb.impl.api; + +import com.falkordb.impl.graph_cache.GraphCaches; + +public interface GraphCacheHolder { + + void setGraphCaches(GraphCaches caches); +} diff --git a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphCommand.java b/src/main/java/com/falkordb/impl/api/GraphCommand.java similarity index 71% rename from src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphCommand.java rename to src/main/java/com/falkordb/impl/api/GraphCommand.java index 0af0f61..476ab63 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphCommand.java +++ b/src/main/java/com/falkordb/impl/api/GraphCommand.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.impl.api; +package com.falkordb.impl.api; import redis.clients.jedis.util.SafeEncoder; import redis.clients.jedis.commands.ProtocolCommand; @@ -7,14 +7,14 @@ * * */ -public enum RedisGraphCommand implements ProtocolCommand { +public enum GraphCommand implements ProtocolCommand { QUERY("graph.QUERY"), RO_QUERY("graph.RO_QUERY"), DELETE("graph.DELETE"); private final byte[] raw; - RedisGraphCommand(String alt) { + GraphCommand(String alt) { raw = SafeEncoder.encode(alt); } diff --git a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphPipeline.java b/src/main/java/com/falkordb/impl/api/GraphPipeline.java similarity index 84% rename from src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphPipeline.java rename to src/main/java/com/falkordb/impl/api/GraphPipeline.java index 8078afd..f723c77 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphPipeline.java +++ b/src/main/java/com/falkordb/impl/api/GraphPipeline.java @@ -1,10 +1,10 @@ -package com.redislabs.redisgraph.impl.api; +package com.falkordb.impl.api; -import com.redislabs.redisgraph.RedisGraph; -import com.redislabs.redisgraph.ResultSet; -import com.redislabs.redisgraph.impl.Utils; -import com.redislabs.redisgraph.impl.graph_cache.RedisGraphCaches; -import com.redislabs.redisgraph.impl.resultset.ResultSetImpl; +import com.falkordb.Graph; +import com.falkordb.ResultSet; +import com.falkordb.impl.Utils; +import com.falkordb.impl.graph_cache.GraphCaches; +import com.falkordb.impl.resultset.ResultSetImpl; import redis.clients.jedis.Builder; import redis.clients.jedis.BuilderFactory; import redis.clients.jedis.Client; @@ -17,13 +17,13 @@ /** * This class is extending Jedis Pipeline */ -public class RedisGraphPipeline extends Pipeline implements com.redislabs.redisgraph.RedisGraphPipeline, RedisGraphCacheHolder { +public class GraphPipeline extends Pipeline implements com.falkordb.GraphPipeline, GraphCacheHolder { - private final RedisGraph redisGraph; - private RedisGraphCaches caches; + private final Graph redisGraph; + private GraphCaches caches; - public RedisGraphPipeline(Client client, RedisGraph redisGraph){ + public GraphPipeline(Client client, Graph redisGraph){ super.setClient(client); this.redisGraph = redisGraph; } @@ -36,7 +36,7 @@ public RedisGraphPipeline(Client client, RedisGraph redisGraph){ */ @Override public Response query(String graphId, String query) { - client.sendCommand(RedisGraphCommand.QUERY, graphId, query, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.QUERY, graphId, query, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -54,7 +54,7 @@ public ResultSet build(Object o) { */ @Override public Response readOnlyQuery(String graphId, String query) { - client.sendCommand(RedisGraphCommand.RO_QUERY, graphId, query, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.RO_QUERY, graphId, query, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -75,7 +75,7 @@ public ResultSet build(Object o) { */ @Override public Response query(String graphId, String query, long timeout) { - client.sendCommand(RedisGraphCommand.QUERY, graphId, query, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, + client.sendCommand(GraphCommand.QUERY, graphId, query, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return getResponse(new Builder() { @SuppressWarnings("unchecked") @@ -97,7 +97,7 @@ public ResultSet build(Object o) { */ @Override public Response readOnlyQuery(String graphId, String query, long timeout) { - client.sendCommand(RedisGraphCommand.RO_QUERY, graphId, query, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, + client.sendCommand(GraphCommand.RO_QUERY, graphId, query, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return getResponse(new Builder() { @SuppressWarnings("unchecked") @@ -118,7 +118,7 @@ public ResultSet build(Object o) { @Override public Response query(String graphId, String query, Map params) { String preparedQuery = Utils.prepareQuery(query, params); - client.sendCommand(RedisGraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -138,7 +138,7 @@ public ResultSet build(Object o) { @Override public Response readOnlyQuery(String graphId, String query, Map params) { String preparedQuery = Utils.prepareQuery(query, params); - client.sendCommand(RedisGraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -162,7 +162,7 @@ public ResultSet build(Object o) { @Override public Response query(String graphId, String query, Map params, long timeout) { String preparedQuery = Utils.prepareQuery(query, params); - client.sendCommand(RedisGraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, + client.sendCommand(GraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return getResponse(new Builder() { @SuppressWarnings("unchecked") @@ -187,7 +187,7 @@ public ResultSet build(Object o) { @Override public Response readOnlyQuery(String graphId, String query, Map params, long timeout) { String preparedQuery = Utils.prepareQuery(query, params); - client.sendCommand(RedisGraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, + client.sendCommand(GraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return getResponse(new Builder() { @@ -243,14 +243,14 @@ public Response callProcedure(String graphId, String procedure, List< */ public Response deleteGraph(String graphId){ - client.sendCommand(RedisGraphCommand.DELETE, graphId); + client.sendCommand(GraphCommand.DELETE, graphId); Response response = getResponse(BuilderFactory.STRING); caches.removeGraphCache(graphId); return response; } @Override - public void setRedisGraphCaches(RedisGraphCaches caches) { + public void setGraphCaches(GraphCaches caches) { this.caches = caches; } } diff --git a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphTransaction.java b/src/main/java/com/falkordb/impl/api/GraphTransaction.java similarity index 84% rename from src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphTransaction.java rename to src/main/java/com/falkordb/impl/api/GraphTransaction.java index 5294993..dd4c59a 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphTransaction.java +++ b/src/main/java/com/falkordb/impl/api/GraphTransaction.java @@ -1,10 +1,10 @@ -package com.redislabs.redisgraph.impl.api; +package com.falkordb.impl.api; -import com.redislabs.redisgraph.RedisGraph; -import com.redislabs.redisgraph.ResultSet; -import com.redislabs.redisgraph.impl.Utils; -import com.redislabs.redisgraph.impl.graph_cache.RedisGraphCaches; -import com.redislabs.redisgraph.impl.resultset.ResultSetImpl; +import com.falkordb.Graph; +import com.falkordb.ResultSet; +import com.falkordb.impl.Utils; +import com.falkordb.impl.graph_cache.GraphCaches; +import com.falkordb.impl.resultset.ResultSetImpl; import redis.clients.jedis.Builder; import redis.clients.jedis.BuilderFactory; import redis.clients.jedis.Client; @@ -17,13 +17,13 @@ /** * This class is extending Jedis Transaction */ -public class RedisGraphTransaction extends Transaction - implements com.redislabs.redisgraph.RedisGraphTransaction, RedisGraphCacheHolder { +public class GraphTransaction extends Transaction + implements com.falkordb.GraphTransaction, GraphCacheHolder { - private final RedisGraph redisGraph; - private RedisGraphCaches caches; + private final Graph redisGraph; + private GraphCaches caches; - public RedisGraphTransaction(Client client, RedisGraph redisGraph) { + public GraphTransaction(Client client, Graph redisGraph) { // init as in Jedis super(client); @@ -38,7 +38,7 @@ public RedisGraphTransaction(Client client, RedisGraph redisGraph) { */ @Override public Response query(String graphId, String query) { - client.sendCommand(RedisGraphCommand.QUERY, graphId, query, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.QUERY, graphId, query, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -56,7 +56,7 @@ public ResultSet build(Object o) { */ @Override public Response readOnlyQuery(String graphId, String query) { - client.sendCommand(RedisGraphCommand.RO_QUERY, graphId, query, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.RO_QUERY, graphId, query, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -77,7 +77,7 @@ public ResultSet build(Object o) { */ @Override public Response query(String graphId, String query, long timeout) { - client.sendCommand(RedisGraphCommand.QUERY, graphId, query, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, + client.sendCommand(GraphCommand.QUERY, graphId, query, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return getResponse(new Builder() { @SuppressWarnings("unchecked") @@ -99,7 +99,7 @@ public ResultSet build(Object o) { */ @Override public Response readOnlyQuery(String graphId, String query, long timeout) { - client.sendCommand(RedisGraphCommand.RO_QUERY, graphId, query, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, + client.sendCommand(GraphCommand.RO_QUERY, graphId, query, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return getResponse(new Builder() { @SuppressWarnings("unchecked") @@ -123,7 +123,7 @@ public ResultSet build(Object o) { @Override public Response query(String graphId, String query, Object... args) { String preparedQuery = Utils.prepareQuery(query, args); - client.sendCommand(RedisGraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -143,7 +143,7 @@ public ResultSet build(Object o) { @Override public Response query(String graphId, String query, Map params) { String preparedQuery = Utils.prepareQuery(query, params); - client.sendCommand(RedisGraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -163,7 +163,7 @@ public ResultSet build(Object o) { @Override public Response readOnlyQuery(String graphId, String query, Map params) { String preparedQuery = Utils.prepareQuery(query, params); - client.sendCommand(RedisGraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); + client.sendCommand(GraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING); return getResponse(new Builder() { @SuppressWarnings("unchecked") @Override @@ -186,7 +186,7 @@ public ResultSet build(Object o) { @Override public Response query(String graphId, String query, Map params, long timeout) { String preparedQuery = Utils.prepareQuery(query, params); - client.sendCommand(RedisGraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, + client.sendCommand(GraphCommand.QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return getResponse(new Builder() { @SuppressWarnings("unchecked") @@ -210,7 +210,7 @@ public ResultSet build(Object o) { @Override public Response readOnlyQuery(String graphId, String query, Map params, long timeout) { String preparedQuery = Utils.prepareQuery(query, params); - client.sendCommand(RedisGraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, + client.sendCommand(GraphCommand.RO_QUERY, graphId, preparedQuery, Utils.COMPACT_STRING, Utils.TIMEOUT_STRING, Long.toString(timeout)); return getResponse(new Builder() { @SuppressWarnings("unchecked") @@ -262,14 +262,14 @@ public Response callProcedure(String graphId, String procedure, List< * @return response with the deletion running time statistics */ public Response deleteGraph(String graphId) { - client.sendCommand(RedisGraphCommand.DELETE, graphId); + client.sendCommand(GraphCommand.DELETE, graphId); Response response = getResponse(BuilderFactory.STRING); caches.removeGraphCache(graphId); return response; } @Override - public void setRedisGraphCaches(RedisGraphCaches caches) { + public void setGraphCaches(GraphCaches caches) { this.caches = caches; } diff --git a/src/main/java/com/redislabs/redisgraph/impl/graph_cache/GraphCache.java b/src/main/java/com/falkordb/impl/graph_cache/GraphCache.java similarity index 78% rename from src/main/java/com/redislabs/redisgraph/impl/graph_cache/GraphCache.java rename to src/main/java/com/falkordb/impl/graph_cache/GraphCache.java index 565c916..a8df22b 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/graph_cache/GraphCache.java +++ b/src/main/java/com/falkordb/impl/graph_cache/GraphCache.java @@ -1,6 +1,6 @@ -package com.redislabs.redisgraph.impl.graph_cache; +package com.falkordb.impl.graph_cache; -import com.redislabs.redisgraph.RedisGraph; +import com.falkordb.Graph; /** * A class to store a local cache in the client, for a specific graph. @@ -26,7 +26,7 @@ public GraphCache(String graphId) { * @param index - index of label * @return requested label */ - public String getLabel(int index, RedisGraph redisGraph) { + public String getLabel(int index, Graph redisGraph) { return labels.getCachedData(index, redisGraph); } @@ -34,7 +34,7 @@ public String getLabel(int index, RedisGraph redisGraph) { * @param index index of the relationship type * @return requested relationship type */ - public String getRelationshipType(int index, RedisGraph redisGraph) { + public String getRelationshipType(int index, Graph redisGraph) { return relationshipTypes.getCachedData(index, redisGraph); } @@ -42,7 +42,7 @@ public String getRelationshipType(int index, RedisGraph redisGraph) { * @param index index of property name * @return requested property */ - public String getPropertyName(int index, RedisGraph redisGraph) { + public String getPropertyName(int index, Graph redisGraph) { return propertyNames.getCachedData(index, redisGraph); } diff --git a/src/main/java/com/redislabs/redisgraph/impl/graph_cache/GraphCacheList.java b/src/main/java/com/falkordb/impl/graph_cache/GraphCacheList.java similarity index 84% rename from src/main/java/com/redislabs/redisgraph/impl/graph_cache/GraphCacheList.java rename to src/main/java/com/falkordb/impl/graph_cache/GraphCacheList.java index 55035d1..6095286 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/graph_cache/GraphCacheList.java +++ b/src/main/java/com/falkordb/impl/graph_cache/GraphCacheList.java @@ -1,8 +1,8 @@ -package com.redislabs.redisgraph.impl.graph_cache; +package com.falkordb.impl.graph_cache; -import com.redislabs.redisgraph.Record; -import com.redislabs.redisgraph.RedisGraph; -import com.redislabs.redisgraph.ResultSet; +import com.falkordb.Record; +import com.falkordb.Graph; +import com.falkordb.ResultSet; import java.util.ArrayList; import java.util.List; @@ -34,7 +34,7 @@ public GraphCacheList(String graphId, String procedure) { * @param index index of data item * @return The string value of the specific procedure response, at the given index. */ - public String getCachedData(int index, RedisGraph redisGraph) { + public String getCachedData(int index, Graph redisGraph) { if (index >= data.size()) { synchronized (data){ if (index >= data.size()) { @@ -49,7 +49,7 @@ public String getCachedData(int index, RedisGraph redisGraph) { /** * Auxiliary method to parse a procedure result set and refresh the cache */ - private void getProcedureInfo(RedisGraph redisGraph) { + private void getProcedureInfo(Graph redisGraph) { ResultSet resultSet = redisGraph.callProcedure(graphId, procedure); List newData = new ArrayList<>(); int i = 0; diff --git a/src/main/java/com/redislabs/redisgraph/impl/graph_cache/RedisGraphCaches.java b/src/main/java/com/falkordb/impl/graph_cache/GraphCaches.java similarity index 76% rename from src/main/java/com/redislabs/redisgraph/impl/graph_cache/RedisGraphCaches.java rename to src/main/java/com/falkordb/impl/graph_cache/GraphCaches.java index 528ed34..f75c80e 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/graph_cache/RedisGraphCaches.java +++ b/src/main/java/com/falkordb/impl/graph_cache/GraphCaches.java @@ -1,11 +1,11 @@ -package com.redislabs.redisgraph.impl.graph_cache; +package com.falkordb.impl.graph_cache; -import com.redislabs.redisgraph.RedisGraph; +import com.falkordb.Graph; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class RedisGraphCaches { +public class GraphCaches { private final Map graphCaches = new ConcurrentHashMap<>(); @@ -20,10 +20,10 @@ public GraphCache getGraphCache(String graphId){ * Returns a String which represents the name of the label mapped to the label id * @param graphId graph to perform the query * @param index label index - * @param redisGraph RedisGraphAPI implementation + * @param redisGraph GraphAPI implementation * @return label name */ - public String getLabel(String graphId, int index, RedisGraph redisGraph) { + public String getLabel(String graphId, int index, Graph redisGraph) { return getGraphCache(graphId).getLabel(index, redisGraph); } @@ -31,10 +31,10 @@ public String getLabel(String graphId, int index, RedisGraph redisGraph) { * Returns a String which represents the name of the relationship mapped to the label id * @param graphId graph to perform the query * @param index relationship index - * @param redisGraph RedisGraphAPI implementation + * @param redisGraph GraphAPI implementation * @return relationship name */ - public String getRelationshipType(String graphId, int index, RedisGraph redisGraph){ + public String getRelationshipType(String graphId, int index, Graph redisGraph){ return getGraphCache(graphId).getRelationshipType(index, redisGraph); } @@ -42,10 +42,10 @@ public String getRelationshipType(String graphId, int index, RedisGraph redisGra * Returns a String which represents the name of the property mapped to the label id * @param graphId graph to perform the query * @param index property index - * @param redisGraph RedisGraphAPI implementation + * @param redisGraph GraphAPI implementation * @return property name */ - public String getPropertyName(String graphId, int index, RedisGraph redisGraph){ + public String getPropertyName(String graphId, int index, Graph redisGraph){ return getGraphCache(graphId).getPropertyName(index, redisGraph); } diff --git a/src/main/java/com/redislabs/redisgraph/impl/resultset/HeaderImpl.java b/src/main/java/com/falkordb/impl/resultset/HeaderImpl.java similarity index 96% rename from src/main/java/com/redislabs/redisgraph/impl/resultset/HeaderImpl.java rename to src/main/java/com/falkordb/impl/resultset/HeaderImpl.java index c4e6c1e..70666e3 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/resultset/HeaderImpl.java +++ b/src/main/java/com/falkordb/impl/resultset/HeaderImpl.java @@ -1,6 +1,6 @@ -package com.redislabs.redisgraph.impl.resultset; +package com.falkordb.impl.resultset; -import com.redislabs.redisgraph.Header; +import com.falkordb.Header; import redis.clients.jedis.util.SafeEncoder; import java.util.ArrayList; diff --git a/src/main/java/com/redislabs/redisgraph/impl/resultset/RecordImpl.java b/src/main/java/com/falkordb/impl/resultset/RecordImpl.java similarity index 94% rename from src/main/java/com/redislabs/redisgraph/impl/resultset/RecordImpl.java rename to src/main/java/com/falkordb/impl/resultset/RecordImpl.java index 31bec44..5924f52 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/resultset/RecordImpl.java +++ b/src/main/java/com/falkordb/impl/resultset/RecordImpl.java @@ -1,9 +1,9 @@ -package com.redislabs.redisgraph.impl.resultset; +package com.falkordb.impl.resultset; import java.util.List; import java.util.Objects; -import com.redislabs.redisgraph.Record; +import com.falkordb.Record; public class RecordImpl implements Record { diff --git a/src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetImpl.java b/src/main/java/com/falkordb/impl/resultset/ResultSetImpl.java similarity index 94% rename from src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetImpl.java rename to src/main/java/com/falkordb/impl/resultset/ResultSetImpl.java index 62a9e2f..519fb09 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetImpl.java +++ b/src/main/java/com/falkordb/impl/resultset/ResultSetImpl.java @@ -1,13 +1,13 @@ -package com.redislabs.redisgraph.impl.resultset; - -import com.redislabs.redisgraph.Header; -import com.redislabs.redisgraph.Record; -import com.redislabs.redisgraph.RedisGraph; -import com.redislabs.redisgraph.ResultSet; -import com.redislabs.redisgraph.Statistics; -import com.redislabs.redisgraph.exceptions.JRedisGraphException; -import com.redislabs.redisgraph.graph_entities.*; -import com.redislabs.redisgraph.impl.graph_cache.GraphCache; +package com.falkordb.impl.resultset; + +import com.falkordb.Header; +import com.falkordb.Record; +import com.falkordb.Graph; +import com.falkordb.ResultSet; +import com.falkordb.Statistics; +import com.falkordb.exceptions.GraphException; +import com.falkordb.graph_entities.*; +import com.falkordb.impl.graph_cache.GraphCache; import redis.clients.jedis.BuilderFactory; import redis.clients.jedis.util.SafeEncoder; import redis.clients.jedis.exceptions.JedisDataException; @@ -21,7 +21,7 @@ public class ResultSetImpl implements ResultSet { private final List results; private int position = 0; - private final RedisGraph redisGraph; + private final Graph redisGraph; private final GraphCache cache; /** @@ -31,7 +31,7 @@ public class ResultSetImpl implements ResultSet { * @param cache the graph local cache */ @SuppressWarnings("unchecked") - public ResultSetImpl(List rawResponse, RedisGraph redisGraph, GraphCache cache) { + public ResultSetImpl(List rawResponse, Graph redisGraph, GraphCache cache) { this.redisGraph = redisGraph; this.cache = cache; @@ -39,7 +39,7 @@ public ResultSetImpl(List rawResponse, RedisGraph redisGraph, GraphCache // JedisDataException. if (rawResponse.get(rawResponse.size() - 1) instanceof JedisDataException) { - throw new JRedisGraphException((Throwable) rawResponse.get(rawResponse.size() - 1)); + throw new GraphException((Throwable) rawResponse.get(rawResponse.size() - 1)); } if (rawResponse.size() != 3) { diff --git a/src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetScalarTypes.java b/src/main/java/com/falkordb/impl/resultset/ResultSetScalarTypes.java similarity index 92% rename from src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetScalarTypes.java rename to src/main/java/com/falkordb/impl/resultset/ResultSetScalarTypes.java index 1a8dc43..414e2ac 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetScalarTypes.java +++ b/src/main/java/com/falkordb/impl/resultset/ResultSetScalarTypes.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.impl.resultset; +package com.falkordb.impl.resultset; import redis.clients.jedis.exceptions.JedisDataException; diff --git a/src/main/java/com/redislabs/redisgraph/impl/resultset/StatisticsImpl.java b/src/main/java/com/falkordb/impl/resultset/StatisticsImpl.java similarity index 96% rename from src/main/java/com/redislabs/redisgraph/impl/resultset/StatisticsImpl.java rename to src/main/java/com/falkordb/impl/resultset/StatisticsImpl.java index 1f58fe5..28a20b5 100644 --- a/src/main/java/com/redislabs/redisgraph/impl/resultset/StatisticsImpl.java +++ b/src/main/java/com/falkordb/impl/resultset/StatisticsImpl.java @@ -1,11 +1,11 @@ -package com.redislabs.redisgraph.impl.resultset; +package com.falkordb.impl.resultset; import java.util.EnumMap; import java.util.List; import java.util.Map; import java.util.Objects; -import com.redislabs.redisgraph.Statistics; +import com.falkordb.Statistics; import redis.clients.jedis.util.SafeEncoder; @@ -134,7 +134,7 @@ public int propertiesSet() { /** * - * @return The execution plan was cached on RedisGraph. + * @return The execution plan was cached on Graph. */ @Override public boolean cachedExecution() { diff --git a/src/main/java/com/redislabs/redisgraph/RedisGraphContextGenerator.java b/src/main/java/com/redislabs/redisgraph/RedisGraphContextGenerator.java deleted file mode 100644 index fe3718f..0000000 --- a/src/main/java/com/redislabs/redisgraph/RedisGraphContextGenerator.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.redislabs.redisgraph; - -public interface RedisGraphContextGenerator extends RedisGraph { - - /** - * Generate a connection bounded api - * @return a connection bounded api - */ - RedisGraphContext getContext(); - -} diff --git a/src/main/java/com/redislabs/redisgraph/exceptions/JRedisGraphException.java b/src/main/java/com/redislabs/redisgraph/exceptions/JRedisGraphException.java deleted file mode 100644 index db33370..0000000 --- a/src/main/java/com/redislabs/redisgraph/exceptions/JRedisGraphException.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.redislabs.redisgraph.exceptions; - -import redis.clients.jedis.exceptions.JedisDataException; - -/** - * RedisGraph query evaluation exception. An instance of JRedisGraphException is - * thrown when RedisGraph encounters an error during query evaluation. - */ -public class JRedisGraphException extends JedisDataException { - private static final long serialVersionUID = -476099681322055468L; - - public JRedisGraphException(String message) { - super(message); - } - - public JRedisGraphException(Throwable cause) { - super(cause); - } - - public JRedisGraphException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphCacheHolder.java b/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphCacheHolder.java deleted file mode 100644 index 97cab72..0000000 --- a/src/main/java/com/redislabs/redisgraph/impl/api/RedisGraphCacheHolder.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.redislabs.redisgraph.impl.api; - -import com.redislabs.redisgraph.impl.graph_cache.RedisGraphCaches; - -public interface RedisGraphCacheHolder { - - void setRedisGraphCaches(RedisGraphCaches caches); -} diff --git a/src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java b/src/test/java/com/falkordb/GraphAPITest.java similarity index 98% rename from src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java rename to src/test/java/com/falkordb/GraphAPITest.java index 6fc132a..36356e4 100644 --- a/src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java +++ b/src/test/java/com/falkordb/GraphAPITest.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import java.util.*; import java.util.stream.Collectors; @@ -9,22 +9,26 @@ import org.junit.Before; import org.junit.Test; -import com.redislabs.redisgraph.Statistics.Label; -import com.redislabs.redisgraph.graph_entities.Edge; -import com.redislabs.redisgraph.graph_entities.Node; -import com.redislabs.redisgraph.graph_entities.Path; -import com.redislabs.redisgraph.graph_entities.Point; -import com.redislabs.redisgraph.graph_entities.Property; -import com.redislabs.redisgraph.impl.api.RedisGraph; -import com.redislabs.redisgraph.test.utils.PathBuilder; +import com.falkordb.Statistics.Label; +import com.falkordb.graph_entities.Edge; +import com.falkordb.graph_entities.Node; +import com.falkordb.graph_entities.Path; +import com.falkordb.graph_entities.Point; +import com.falkordb.graph_entities.Property; +import com.falkordb.impl.api.Graph; +import com.falkordb.test.utils.PathBuilder; +import com.falkordb.Header; +import com.falkordb.GraphContext; +import com.falkordb.GraphContextGenerator; +import com.falkordb.ResultSet; -public class RedisGraphAPITest { +public class GraphAPITest { - private RedisGraphContextGenerator client; + private GraphContextGenerator client; @Before public void createApi() { - client = new RedisGraph(); + client = new Graph(); } @After @@ -520,7 +524,7 @@ public void testContextedAPI() { params.put("age", age); params.put("boolValue", boolValue); params.put("doubleValue", doubleValue); - try (RedisGraphContext c = client.getContext()) { + try (GraphContext c = client.getContext()) { Assert.assertNotNull(c.query("social", "CREATE (:person{name:$name, age:$age, doubleValue:$doubleValue, boolValue:$boolValue})", params)); Assert.assertNotNull(c.query("social", "CREATE (:person{name:'amit',age:30})")); diff --git a/src/test/java/com/redislabs/redisgraph/InstantiationTest.java b/src/test/java/com/falkordb/InstantiationTest.java similarity index 76% rename from src/test/java/com/redislabs/redisgraph/InstantiationTest.java rename to src/test/java/com/falkordb/InstantiationTest.java index 5771279..6e06f2c 100644 --- a/src/test/java/com/redislabs/redisgraph/InstantiationTest.java +++ b/src/test/java/com/falkordb/InstantiationTest.java @@ -1,36 +1,38 @@ -package com.redislabs.redisgraph; +package com.falkordb; import org.junit.After; import org.junit.Assert; -import com.redislabs.redisgraph.impl.api.RedisGraph; +import com.falkordb.impl.api.Graph; +import com.falkordb.GraphContextGenerator; +import com.falkordb.ResultSet; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; public class InstantiationTest { - private RedisGraphContextGenerator client; + private GraphContextGenerator client; public void createDefaultClient() { - client = new RedisGraph(); + client = new Graph(); ResultSet resultSet = client.query("g", "CREATE ({name:'bsb'})"); Assert.assertEquals(1, resultSet.getStatistics().nodesCreated()); } public void createClientWithHostAndPort() { - client = new RedisGraph("localhost", 6379); + client = new Graph("localhost", 6379); ResultSet resultSet = client.query("g", "CREATE ({name:'bsb'})"); Assert.assertEquals(1, resultSet.getStatistics().nodesCreated()); } public void createClientWithJedisInstance() { - client = new RedisGraph(new Jedis()); + client = new Graph(new Jedis()); ResultSet resultSet = client.query("g", "CREATE ({name:'bsb'})"); Assert.assertEquals(1, resultSet.getStatistics().nodesCreated()); } public void createClientWithJedisPool() { - client = new RedisGraph(new JedisPool()); + client = new Graph(new JedisPool()); ResultSet resultSet = client.query("g", "CREATE ({name:'bsb'})"); Assert.assertEquals(1, resultSet.getStatistics().nodesCreated()); } diff --git a/src/test/java/com/redislabs/redisgraph/IterableTest.java b/src/test/java/com/falkordb/IterableTest.java similarity index 84% rename from src/test/java/com/redislabs/redisgraph/IterableTest.java rename to src/test/java/com/falkordb/IterableTest.java index 4cec849..438525a 100644 --- a/src/test/java/com/redislabs/redisgraph/IterableTest.java +++ b/src/test/java/com/falkordb/IterableTest.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -6,15 +6,17 @@ import org.junit.Before; import org.junit.Test; -import com.redislabs.redisgraph.impl.api.RedisGraph; +import com.falkordb.impl.api.Graph; +import com.falkordb.GraphContextGenerator; +import com.falkordb.ResultSet; public class IterableTest { - private RedisGraphContextGenerator api; + private GraphContextGenerator api; @Before public void createApi() { - api = new RedisGraph(); + api = new Graph(); } @After diff --git a/src/test/java/com/redislabs/redisgraph/PipelineTest.java b/src/test/java/com/falkordb/PipelineTest.java similarity index 91% rename from src/test/java/com/redislabs/redisgraph/PipelineTest.java rename to src/test/java/com/falkordb/PipelineTest.java index 1ec8beb..cf837d7 100644 --- a/src/test/java/com/redislabs/redisgraph/PipelineTest.java +++ b/src/test/java/com/falkordb/PipelineTest.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import java.util.Arrays; import java.util.List; @@ -8,21 +8,26 @@ import org.junit.Before; import org.junit.Test; -import com.redislabs.redisgraph.graph_entities.Node; -import com.redislabs.redisgraph.graph_entities.Property; -import com.redislabs.redisgraph.impl.api.RedisGraph; -import com.redislabs.redisgraph.impl.resultset.ResultSetImpl; +import com.falkordb.graph_entities.Node; +import com.falkordb.graph_entities.Property; +import com.falkordb.impl.api.Graph; +import com.falkordb.impl.resultset.ResultSetImpl; +import com.falkordb.Header; +import com.falkordb.GraphContext; +import com.falkordb.GraphContextGenerator; +import com.falkordb.GraphPipeline; +import com.falkordb.ResultSet; public class PipelineTest { - private RedisGraphContextGenerator api; + private GraphContextGenerator api; public PipelineTest() { } @Before public void createApi() { - api = new RedisGraph(); + api = new Graph(); } @After @@ -33,8 +38,8 @@ public void deleteGraph() { @Test public void testSync() { - try (RedisGraphContext c = api.getContext()) { - RedisGraphPipeline pipeline = c.pipelined(); + try (GraphContext c = api.getContext()) { + GraphPipeline pipeline = c.pipelined(); pipeline.set("x", "1"); pipeline.query("social", "CREATE (:Person {name:'a'})"); pipeline.query("g", "CREATE (:Person {name:'a'})"); @@ -116,8 +121,8 @@ record = resultSet.next(); @Test public void testReadOnlyQueries() { - try (RedisGraphContext c = api.getContext()) { - RedisGraphPipeline pipeline = c.pipelined(); + try (GraphContext c = api.getContext()) { + GraphPipeline pipeline = c.pipelined(); pipeline.set("x", "1"); pipeline.query("social", "CREATE (:Person {name:'a'})"); @@ -190,8 +195,8 @@ record = resultSet.next(); @Test public void testWaitReplicas() { - try (RedisGraphContext c = api.getContext()) { - RedisGraphPipeline pipeline = c.pipelined(); + try (GraphContext c = api.getContext()) { + GraphPipeline pipeline = c.pipelined(); pipeline.set("x", "1"); pipeline.query("social", "CREATE (:Person {name:'a'})"); pipeline.query("g", "CREATE (:Person {name:'a'})"); diff --git a/src/test/java/com/redislabs/redisgraph/TransactionTest.java b/src/test/java/com/falkordb/TransactionTest.java similarity index 90% rename from src/test/java/com/redislabs/redisgraph/TransactionTest.java rename to src/test/java/com/falkordb/TransactionTest.java index 0df475b..f7b5701 100644 --- a/src/test/java/com/redislabs/redisgraph/TransactionTest.java +++ b/src/test/java/com/falkordb/TransactionTest.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph; +package com.falkordb; import java.util.Arrays; import java.util.HashMap; @@ -10,21 +10,26 @@ import org.junit.Before; import org.junit.Test; -import com.redislabs.redisgraph.graph_entities.Node; -import com.redislabs.redisgraph.graph_entities.Property; -import com.redislabs.redisgraph.impl.api.RedisGraph; -import com.redislabs.redisgraph.impl.resultset.ResultSetImpl; +import com.falkordb.graph_entities.Node; +import com.falkordb.graph_entities.Property; +import com.falkordb.impl.api.Graph; +import com.falkordb.impl.resultset.ResultSetImpl; +import com.falkordb.Header; +import com.falkordb.GraphContext; +import com.falkordb.GraphContextGenerator; +import com.falkordb.GraphTransaction; +import com.falkordb.ResultSet; public class TransactionTest { - private RedisGraphContextGenerator api; + private GraphContextGenerator api; public TransactionTest() { } @Before public void createApi(){ - api = new RedisGraph(); + api = new Graph(); } @After @@ -35,8 +40,8 @@ public void deleteGraph() { @Test public void testMultiExec(){ - try (RedisGraphContext c = api.getContext()) { - RedisGraphTransaction transaction = c.multi(); + try (GraphContext c = api.getContext()) { + GraphTransaction transaction = c.multi(); transaction.set("x", "1"); transaction.query("social", "CREATE (:Person {name:'a'})"); @@ -123,11 +128,11 @@ record = resultSet.next(); @Test public void testWriteTransactionWatch(){ - RedisGraphContext c1 = api.getContext(); - RedisGraphContext c2 = api.getContext(); + GraphContext c1 = api.getContext(); + GraphContext c2 = api.getContext(); c1.watch("social"); - RedisGraphTransaction t1 = c1.multi(); + GraphTransaction t1 = c1.multi(); t1.query("social", "CREATE (:Person {name:'a'})"); @@ -141,12 +146,12 @@ public void testWriteTransactionWatch(){ @Test public void testReadTransactionWatch(){ - RedisGraphContext c1 = api.getContext(); - RedisGraphContext c2 = api.getContext(); + GraphContext c1 = api.getContext(); + GraphContext c2 = api.getContext(); Assert.assertNotEquals(c1.getConnectionContext(), c2.getConnectionContext()); c1.query("social", "CREATE (:Person {name:'a'})"); c1.watch("social"); - RedisGraphTransaction t1 = c1.multi(); + GraphTransaction t1 = c1.multi(); Map params = new HashMap<>(); params.put("name", 'b'); @@ -161,8 +166,8 @@ public void testReadTransactionWatch(){ @Test public void testMultiExecWithReadOnlyQueries(){ - try (RedisGraphContext c = api.getContext()) { - RedisGraphTransaction transaction = c.multi(); + try (GraphContext c = api.getContext()) { + GraphTransaction transaction = c.multi(); transaction.set("x", "1"); transaction.query("social", "CREATE (:Person {name:'a'})"); diff --git a/src/test/java/com/redislabs/redisgraph/exceptions/JRedisGraphErrorTest.java b/src/test/java/com/falkordb/exceptions/GraphErrorTest.java similarity index 73% rename from src/test/java/com/redislabs/redisgraph/exceptions/JRedisGraphErrorTest.java rename to src/test/java/com/falkordb/exceptions/GraphErrorTest.java index f29bdaa..8d468e7 100644 --- a/src/test/java/com/redislabs/redisgraph/exceptions/JRedisGraphErrorTest.java +++ b/src/test/java/com/falkordb/exceptions/GraphErrorTest.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.exceptions; +package com.falkordb.exceptions; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; @@ -10,17 +10,18 @@ import org.junit.Before; import org.junit.Test; -import com.redislabs.redisgraph.RedisGraphContext; -import com.redislabs.redisgraph.RedisGraphContextGenerator; -import com.redislabs.redisgraph.impl.api.RedisGraph; +import com.falkordb.GraphContext; +import com.falkordb.GraphContextGenerator; +import com.falkordb.impl.api.Graph; +import com.falkordb.exceptions.GraphException; -public class JRedisGraphErrorTest { +public class GraphErrorTest { - private RedisGraphContextGenerator api; + private GraphContextGenerator api; @Before public void createApi() { - api = new RedisGraph(); + api = new Graph(); Assert.assertNotNull(api.query("social", "CREATE (:person{mixed_prop: 'strval'}), (:person{mixed_prop: 50})")); } @@ -33,14 +34,14 @@ public void deleteGraph() { @Test public void testSyntaxErrorReporting() { - JRedisGraphException exception = assertThrows(JRedisGraphException.class, + GraphException exception = assertThrows(GraphException.class, () -> api.query("social", "RETURN toUpper(5)")); assertTrue(exception.getMessage().contains("Type mismatch: expected String or Null but was Integer")); } @Test public void testRuntimeErrorReporting() { - JRedisGraphException exception = assertThrows(JRedisGraphException.class, + GraphException exception = assertThrows(GraphException.class, () -> api.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)")); assertTrue(exception.getMessage().contains("Type mismatch: expected String or Null but was Integer")); } @@ -52,7 +53,7 @@ public void testExceptionFlow() { // Issue a query that causes a compile-time error api.query("social", "RETURN toUpper(5)"); } catch (Exception e) { - Assert.assertEquals(JRedisGraphException.class, e.getClass()); + Assert.assertEquals(GraphException.class, e.getClass()); Assert.assertTrue(e.getMessage().contains("Type mismatch: expected String or Null but was Integer")); } @@ -62,39 +63,39 @@ public void testExceptionFlow() { // Issue a query that causes a compile-time error api.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); } catch (Exception e) { - Assert.assertEquals(JRedisGraphException.class, e.getClass()); + Assert.assertEquals(GraphException.class, e.getClass()); Assert.assertTrue(e.getMessage().contains("Type mismatch: expected String or Null but was Integer")); } } @Test public void testContextSyntaxErrorReporting() { - RedisGraphContext c = api.getContext(); + GraphContext c = api.getContext(); - JRedisGraphException exception = assertThrows(JRedisGraphException.class, + GraphException exception = assertThrows(GraphException.class, () -> c.query("social", "RETURN toUpper(5)")); assertTrue(exception.getMessage().contains("Type mismatch: expected String or Null but was Integer")); } @Test public void testMissingParametersSyntaxErrorReporting() { - JRedisGraphException exception = assertThrows(JRedisGraphException.class, + GraphException exception = assertThrows(GraphException.class, () -> api.query("social", "RETURN $param")); assertTrue(exception.getMessage().contains("Missing parameters")); } @Test public void testMissingParametersSyntaxErrorReporting2() { - JRedisGraphException exception = assertThrows(JRedisGraphException.class, + GraphException exception = assertThrows(GraphException.class, () -> api.query("social", "RETURN $param", new HashMap<>())); assertTrue(exception.getMessage().contains("Missing parameters")); } @Test public void testContextRuntimeErrorReporting() { - RedisGraphContext c = api.getContext(); + GraphContext c = api.getContext(); - JRedisGraphException exception = assertThrows(JRedisGraphException.class, + GraphException exception = assertThrows(GraphException.class, () -> c.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)")); assertTrue(exception.getMessage().contains("Type mismatch: expected String or Null but was Integer")); } @@ -102,12 +103,12 @@ public void testContextRuntimeErrorReporting() { @Test public void testContextExceptionFlow() { - RedisGraphContext c = api.getContext(); + GraphContext c = api.getContext(); try { // Issue a query that causes a compile-time error c.query("social", "RETURN toUpper(5)"); } catch (Exception e) { - Assert.assertEquals(JRedisGraphException.class, e.getClass()); + Assert.assertEquals(GraphException.class, e.getClass()); Assert.assertTrue(e.getMessage().contains("Type mismatch: expected String or Null but was Integer")); } @@ -116,14 +117,14 @@ public void testContextExceptionFlow() { // Issue a query that causes a compile-time error c.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); } catch (Exception e) { - Assert.assertEquals(JRedisGraphException.class, e.getClass()); + Assert.assertEquals(GraphException.class, e.getClass()); Assert.assertTrue(e.getMessage().contains("Type mismatch: expected String or Null but was Integer")); } } @Test public void timeoutException() { - JRedisGraphException exception = assertThrows(JRedisGraphException.class, + GraphException exception = assertThrows(GraphException.class, () -> api.query("social", "UNWIND range(0,100000) AS x WITH x AS x WHERE x = 10000 RETURN x", 1L)); assertTrue(exception.getMessage().contains("Query timed out")); } diff --git a/src/test/java/com/redislabs/redisgraph/graph_entities/PathTest.java b/src/test/java/com/falkordb/graph_entities/PathTest.java similarity index 93% rename from src/test/java/com/redislabs/redisgraph/graph_entities/PathTest.java rename to src/test/java/com/falkordb/graph_entities/PathTest.java index ee65e68..fbfb387 100644 --- a/src/test/java/com/redislabs/redisgraph/graph_entities/PathTest.java +++ b/src/test/java/com/falkordb/graph_entities/PathTest.java @@ -1,8 +1,12 @@ -package com.redislabs.redisgraph.graph_entities; +package com.falkordb.graph_entities; import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.Test; +import com.falkordb.graph_entities.Edge; +import com.falkordb.graph_entities.Node; +import com.falkordb.graph_entities.Path; + import java.util.List; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; diff --git a/src/test/java/com/redislabs/redisgraph/impl/UtilsTest.java b/src/test/java/com/falkordb/impl/UtilsTest.java similarity index 98% rename from src/test/java/com/redislabs/redisgraph/impl/UtilsTest.java rename to src/test/java/com/falkordb/impl/UtilsTest.java index b745754..52a0bf3 100644 --- a/src/test/java/com/redislabs/redisgraph/impl/UtilsTest.java +++ b/src/test/java/com/falkordb/impl/UtilsTest.java @@ -1,4 +1,4 @@ -package com.redislabs.redisgraph.impl; +package com.falkordb.impl; import static org.junit.Assert.assertThrows; @@ -11,6 +11,8 @@ import org.junit.Assert; import org.junit.Test; +import com.falkordb.impl.Utils; + public class UtilsTest { @Test diff --git a/src/test/java/com/redislabs/redisgraph/test/utils/PathBuilder.java b/src/test/java/com/falkordb/test/utils/PathBuilder.java similarity index 87% rename from src/test/java/com/redislabs/redisgraph/test/utils/PathBuilder.java rename to src/test/java/com/falkordb/test/utils/PathBuilder.java index cf6db87..63c906e 100644 --- a/src/test/java/com/redislabs/redisgraph/test/utils/PathBuilder.java +++ b/src/test/java/com/falkordb/test/utils/PathBuilder.java @@ -1,8 +1,8 @@ -package com.redislabs.redisgraph.test.utils; +package com.falkordb.test.utils; -import com.redislabs.redisgraph.graph_entities.Edge; -import com.redislabs.redisgraph.graph_entities.Node; -import com.redislabs.redisgraph.graph_entities.Path; +import com.falkordb.graph_entities.Edge; +import com.falkordb.graph_entities.Node; +import com.falkordb.graph_entities.Path; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/com/redislabs/redisgraph/test/utils/PathBuilderTest.java b/src/test/java/com/falkordb/test/utils/PathBuilderTest.java similarity index 90% rename from src/test/java/com/redislabs/redisgraph/test/utils/PathBuilderTest.java rename to src/test/java/com/falkordb/test/utils/PathBuilderTest.java index d6a0c03..88805ba 100644 --- a/src/test/java/com/redislabs/redisgraph/test/utils/PathBuilderTest.java +++ b/src/test/java/com/falkordb/test/utils/PathBuilderTest.java @@ -1,11 +1,11 @@ -package com.redislabs.redisgraph.test.utils; +package com.falkordb.test.utils; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import org.junit.Test; -import com.redislabs.redisgraph.graph_entities.Edge; +import com.falkordb.graph_entities.Edge; public class PathBuilderTest { From 267e6d09e32ffd7514c660f1ee47aa9a0f7b2787 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Mon, 27 Nov 2023 13:08:55 +0200 Subject: [PATCH 2/2] fix tests --- .vscode/settings.json | 7 ++++++ src/main/java/com/falkordb/Header.java | 3 --- .../com/falkordb/impl/api/GraphCommand.java | 2 -- .../com/falkordb/impl/api/GraphPipeline.java | 22 ++++++++--------- .../falkordb/impl/api/GraphTransaction.java | 24 +++++++++---------- .../falkordb/impl/graph_cache/GraphCache.java | 12 +++++----- .../impl/graph_cache/GraphCacheList.java | 8 +++---- .../impl/graph_cache/GraphCaches.java | 18 +++++++------- .../impl/resultset/ResultSetImpl.java | 23 ++++++++++-------- src/test/java/com/falkordb/GraphAPITest.java | 17 ++++++------- .../java/com/falkordb/InstantiationTest.java | 2 -- src/test/java/com/falkordb/IterableTest.java | 3 --- src/test/java/com/falkordb/PipelineTest.java | 8 ------- .../java/com/falkordb/TransactionTest.java | 5 ---- .../falkordb/exceptions/GraphErrorTest.java | 1 - .../com/falkordb/graph_entities/PathTest.java | 4 ---- .../java/com/falkordb/impl/UtilsTest.java | 2 -- 17 files changed, 71 insertions(+), 90 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f5612be --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "cSpell.words": [ + "CYPHER", + "falkordb", + "jedis" + ] +} \ No newline at end of file diff --git a/src/main/java/com/falkordb/Header.java b/src/main/java/com/falkordb/Header.java index 1058f39..0466e4e 100644 --- a/src/main/java/com/falkordb/Header.java +++ b/src/main/java/com/falkordb/Header.java @@ -7,16 +7,13 @@ */ public interface Header { - enum ResultSetColumnTypes { COLUMN_UNKNOWN, COLUMN_SCALAR, COLUMN_NODE, COLUMN_RELATION - } - List getSchemaNames(); List getSchemaTypes(); diff --git a/src/main/java/com/falkordb/impl/api/GraphCommand.java b/src/main/java/com/falkordb/impl/api/GraphCommand.java index 476ab63..906609e 100644 --- a/src/main/java/com/falkordb/impl/api/GraphCommand.java +++ b/src/main/java/com/falkordb/impl/api/GraphCommand.java @@ -4,8 +4,6 @@ /** * - * - * */ public enum GraphCommand implements ProtocolCommand { QUERY("graph.QUERY"), diff --git a/src/main/java/com/falkordb/impl/api/GraphPipeline.java b/src/main/java/com/falkordb/impl/api/GraphPipeline.java index f723c77..c52e84c 100644 --- a/src/main/java/com/falkordb/impl/api/GraphPipeline.java +++ b/src/main/java/com/falkordb/impl/api/GraphPipeline.java @@ -19,13 +19,13 @@ */ public class GraphPipeline extends Pipeline implements com.falkordb.GraphPipeline, GraphCacheHolder { - private final Graph redisGraph; + private final Graph graph; private GraphCaches caches; - public GraphPipeline(Client client, Graph redisGraph){ + public GraphPipeline(Client client, Graph graph){ super.setClient(client); - this.redisGraph = redisGraph; + this.graph = graph; } /** @@ -41,7 +41,7 @@ public Response query(String graphId, String query) { @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -59,7 +59,7 @@ public Response readOnlyQuery(String graphId, String query) { @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -81,7 +81,7 @@ public Response query(String graphId, String query, long timeout) { @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -103,7 +103,7 @@ public Response readOnlyQuery(String graphId, String query, long time @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -123,7 +123,7 @@ public Response query(String graphId, String query, Map) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -143,7 +143,7 @@ public Response readOnlyQuery(String graphId, String query, Map) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -168,7 +168,7 @@ public Response query(String graphId, String query, Map) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -194,7 +194,7 @@ public Response readOnlyQuery(String graphId, String query, Map) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } diff --git a/src/main/java/com/falkordb/impl/api/GraphTransaction.java b/src/main/java/com/falkordb/impl/api/GraphTransaction.java index dd4c59a..e73c89e 100644 --- a/src/main/java/com/falkordb/impl/api/GraphTransaction.java +++ b/src/main/java/com/falkordb/impl/api/GraphTransaction.java @@ -20,14 +20,14 @@ public class GraphTransaction extends Transaction implements com.falkordb.GraphTransaction, GraphCacheHolder { - private final Graph redisGraph; + private final Graph graph; private GraphCaches caches; - public GraphTransaction(Client client, Graph redisGraph) { + public GraphTransaction(Client client, Graph graph) { // init as in Jedis super(client); - this.redisGraph = redisGraph; + this.graph = graph; } /** @@ -43,7 +43,7 @@ public Response query(String graphId, String query) { @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -61,7 +61,7 @@ public Response readOnlyQuery(String graphId, String query) { @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -83,7 +83,7 @@ public Response query(String graphId, String query, long timeout) { @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -105,7 +105,7 @@ public Response readOnlyQuery(String graphId, String query, long time @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -128,7 +128,7 @@ public Response query(String graphId, String query, Object... args) { @SuppressWarnings("unchecked") @Override public ResultSet build(Object o) { - return new ResultSetImpl((List) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -148,7 +148,7 @@ public Response query(String graphId, String query, Map) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -168,7 +168,7 @@ public Response readOnlyQuery(String graphId, String query, Map) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -192,7 +192,7 @@ public Response query(String graphId, String query, Map) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } @@ -216,7 +216,7 @@ public Response readOnlyQuery(String graphId, String query, Map) o, redisGraph, caches.getGraphCache(graphId)); + return new ResultSetImpl((List) o, graph, caches.getGraphCache(graphId)); } }); } 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 a8df22b..8f08f16 100644 --- a/src/main/java/com/falkordb/impl/graph_cache/GraphCache.java +++ b/src/main/java/com/falkordb/impl/graph_cache/GraphCache.java @@ -26,24 +26,24 @@ public GraphCache(String graphId) { * @param index - index of label * @return requested label */ - public String getLabel(int index, Graph redisGraph) { - return labels.getCachedData(index, redisGraph); + public String getLabel(int index, Graph graph) { + return labels.getCachedData(index, graph); } /** * @param index index of the relationship type * @return requested relationship type */ - public String getRelationshipType(int index, Graph redisGraph) { - return relationshipTypes.getCachedData(index, redisGraph); + public String getRelationshipType(int index, Graph graph) { + return relationshipTypes.getCachedData(index, graph); } /** * @param index index of property name * @return requested property */ - public String getPropertyName(int index, Graph redisGraph) { + public String getPropertyName(int index, Graph graph) { - return propertyNames.getCachedData(index, redisGraph); + return propertyNames.getCachedData(index, graph); } } diff --git a/src/main/java/com/falkordb/impl/graph_cache/GraphCacheList.java b/src/main/java/com/falkordb/impl/graph_cache/GraphCacheList.java index 6095286..92d40f6 100644 --- a/src/main/java/com/falkordb/impl/graph_cache/GraphCacheList.java +++ b/src/main/java/com/falkordb/impl/graph_cache/GraphCacheList.java @@ -34,11 +34,11 @@ public GraphCacheList(String graphId, String procedure) { * @param index index of data item * @return The string value of the specific procedure response, at the given index. */ - public String getCachedData(int index, Graph redisGraph) { + public String getCachedData(int index, Graph graph) { if (index >= data.size()) { synchronized (data){ if (index >= data.size()) { - getProcedureInfo(redisGraph); + getProcedureInfo(graph); } } } @@ -49,8 +49,8 @@ public String getCachedData(int index, Graph redisGraph) { /** * Auxiliary method to parse a procedure result set and refresh the cache */ - private void getProcedureInfo(Graph redisGraph) { - ResultSet resultSet = redisGraph.callProcedure(graphId, procedure); + private void getProcedureInfo(Graph graph) { + ResultSet resultSet = graph.callProcedure(graphId, procedure); List newData = new ArrayList<>(); int i = 0; while (resultSet.hasNext()) { diff --git a/src/main/java/com/falkordb/impl/graph_cache/GraphCaches.java b/src/main/java/com/falkordb/impl/graph_cache/GraphCaches.java index f75c80e..87b4c3c 100644 --- a/src/main/java/com/falkordb/impl/graph_cache/GraphCaches.java +++ b/src/main/java/com/falkordb/impl/graph_cache/GraphCaches.java @@ -20,33 +20,33 @@ public GraphCache getGraphCache(String graphId){ * Returns a String which represents the name of the label mapped to the label id * @param graphId graph to perform the query * @param index label index - * @param redisGraph GraphAPI implementation + * @param graph GraphAPI implementation * @return label name */ - public String getLabel(String graphId, int index, Graph redisGraph) { - return getGraphCache(graphId).getLabel(index, redisGraph); + public String getLabel(String graphId, int index, Graph graph) { + return getGraphCache(graphId).getLabel(index, graph); } /** * Returns a String which represents the name of the relationship mapped to the label id * @param graphId graph to perform the query * @param index relationship index - * @param redisGraph GraphAPI implementation + * @param graph GraphAPI implementation * @return relationship name */ - public String getRelationshipType(String graphId, int index, Graph redisGraph){ - return getGraphCache(graphId).getRelationshipType(index, redisGraph); + public String getRelationshipType(String graphId, int index, Graph graph){ + return getGraphCache(graphId).getRelationshipType(index, graph); } /** * Returns a String which represents the name of the property mapped to the label id * @param graphId graph to perform the query * @param index property index - * @param redisGraph GraphAPI implementation + * @param graph GraphAPI implementation * @return property name */ - public String getPropertyName(String graphId, int index, Graph redisGraph){ - return getGraphCache(graphId).getPropertyName(index, redisGraph); + public String getPropertyName(String graphId, int index, Graph graph){ + return getGraphCache(graphId).getPropertyName(index, graph); } /** diff --git a/src/main/java/com/falkordb/impl/resultset/ResultSetImpl.java b/src/main/java/com/falkordb/impl/resultset/ResultSetImpl.java index 519fb09..cf7e1e0 100644 --- a/src/main/java/com/falkordb/impl/resultset/ResultSetImpl.java +++ b/src/main/java/com/falkordb/impl/resultset/ResultSetImpl.java @@ -21,18 +21,18 @@ public class ResultSetImpl implements ResultSet { private final List results; private int position = 0; - private final Graph redisGraph; + private final Graph graph; private final GraphCache cache; /** * @param rawResponse the raw representation of response is at most 3 lists of * objects. The last list is the statistics list. - * @param redisGraph the graph connection + * @param graph the graph connection * @param cache the graph local cache */ @SuppressWarnings("unchecked") - public ResultSetImpl(List rawResponse, Graph redisGraph, GraphCache cache) { - this.redisGraph = redisGraph; + public ResultSetImpl(List rawResponse, Graph graph, GraphCache cache) { + this.graph = graph; this.cache = cache; // If a run-time error occurred, the last member of the rawResponse will be a @@ -148,7 +148,7 @@ private Node deserializeNode(List rawNodeData) { deserializeGraphEntityId(node, (Long) rawNodeData.get(0)); for (Long labelIndex : labelsIndices) { - String label = cache.getLabel(labelIndex.intValue(), redisGraph); + String label = cache.getLabel(labelIndex.intValue(), graph); node.addLabel(label); } @@ -180,7 +180,7 @@ private Edge deserializeEdge(List rawEdgeData) { Edge edge = new Edge(rawProperties.size()); deserializeGraphEntityId(edge, (Long) rawEdgeData.get(0)); - String relationshipType = cache.getRelationshipType(((Long) rawEdgeData.get(1)).intValue(), redisGraph); + String relationshipType = cache.getRelationshipType(((Long) rawEdgeData.get(1)).intValue(), graph); edge.setRelationshipType(relationshipType); edge.setSource((long) rawEdgeData.get(2)); @@ -203,7 +203,7 @@ private void deserializeGraphEntityProperties(GraphEntity entity, List rawProperty : rawProperties) { Property property = new Property<>(); - property.setName(cache.getPropertyName(((Long) rawProperty.get(0)).intValue(), redisGraph)); + property.setName(cache.getPropertyName(((Long) rawProperty.get(0)).intValue(), graph)); // trimmed for getting to value using deserializeScalar List propertyScalar = rawProperty.subList(1, rawProperty.size()); @@ -310,8 +310,9 @@ public boolean hasNext() { @Override @Deprecated public Record next() { - if (!hasNext()) + if (!hasNext()) { throw new NoSuchElementException(); + } return results.get(position++); } @@ -322,10 +323,12 @@ public int size() { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof ResultSetImpl)) + } + if (!(o instanceof ResultSetImpl)) { return false; + } ResultSetImpl resultSet = (ResultSetImpl) o; return Objects.equals(getHeader(), resultSet.getHeader()) && Objects.equals(getStatistics(), resultSet.getStatistics()) diff --git a/src/test/java/com/falkordb/GraphAPITest.java b/src/test/java/com/falkordb/GraphAPITest.java index 36356e4..a1dc658 100644 --- a/src/test/java/com/falkordb/GraphAPITest.java +++ b/src/test/java/com/falkordb/GraphAPITest.java @@ -1,5 +1,7 @@ package com.falkordb; +import static org.junit.Assert.fail; + import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -17,10 +19,6 @@ import com.falkordb.graph_entities.Property; import com.falkordb.impl.api.Graph; import com.falkordb.test.utils.PathBuilder; -import com.falkordb.Header; -import com.falkordb.GraphContext; -import com.falkordb.GraphContextGenerator; -import com.falkordb.ResultSet; public class GraphAPITest { @@ -154,10 +152,13 @@ public void testIndex() { Assert.assertNotNull(createNonExistingIndexResult.getStatistics().getStringValue(Label.INDICES_ADDED)); Assert.assertEquals(1, createNonExistingIndexResult.getStatistics().indicesAdded()); - ResultSet createExistingIndexResult = client.query("social", "CREATE INDEX ON :person(age)"); - Assert.assertFalse(createExistingIndexResult.hasNext()); - Assert.assertNotNull(createExistingIndexResult.getStatistics().getStringValue(Label.INDICES_ADDED)); - Assert.assertEquals(0, createExistingIndexResult.getStatistics().indicesAdded()); + + try { + client.query("social", "CREATE INDEX ON :person(age)"); + fail(); + } catch (Exception e) { + // TODO: handle exception + } ResultSet deleteExistingIndexResult = client.query("social", "DROP INDEX ON :person(age)"); Assert.assertFalse(deleteExistingIndexResult.hasNext()); diff --git a/src/test/java/com/falkordb/InstantiationTest.java b/src/test/java/com/falkordb/InstantiationTest.java index 6e06f2c..c1ef2f1 100644 --- a/src/test/java/com/falkordb/InstantiationTest.java +++ b/src/test/java/com/falkordb/InstantiationTest.java @@ -4,8 +4,6 @@ import org.junit.Assert; import com.falkordb.impl.api.Graph; -import com.falkordb.GraphContextGenerator; -import com.falkordb.ResultSet; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; diff --git a/src/test/java/com/falkordb/IterableTest.java b/src/test/java/com/falkordb/IterableTest.java index 438525a..1907284 100644 --- a/src/test/java/com/falkordb/IterableTest.java +++ b/src/test/java/com/falkordb/IterableTest.java @@ -7,9 +7,6 @@ import org.junit.Test; import com.falkordb.impl.api.Graph; -import com.falkordb.GraphContextGenerator; -import com.falkordb.ResultSet; - public class IterableTest { private GraphContextGenerator api; diff --git a/src/test/java/com/falkordb/PipelineTest.java b/src/test/java/com/falkordb/PipelineTest.java index cf837d7..1ec3e6f 100644 --- a/src/test/java/com/falkordb/PipelineTest.java +++ b/src/test/java/com/falkordb/PipelineTest.java @@ -12,19 +12,11 @@ import com.falkordb.graph_entities.Property; import com.falkordb.impl.api.Graph; import com.falkordb.impl.resultset.ResultSetImpl; -import com.falkordb.Header; -import com.falkordb.GraphContext; -import com.falkordb.GraphContextGenerator; -import com.falkordb.GraphPipeline; -import com.falkordb.ResultSet; public class PipelineTest { private GraphContextGenerator api; - public PipelineTest() { - } - @Before public void createApi() { api = new Graph(); diff --git a/src/test/java/com/falkordb/TransactionTest.java b/src/test/java/com/falkordb/TransactionTest.java index f7b5701..98ff994 100644 --- a/src/test/java/com/falkordb/TransactionTest.java +++ b/src/test/java/com/falkordb/TransactionTest.java @@ -14,11 +14,6 @@ import com.falkordb.graph_entities.Property; import com.falkordb.impl.api.Graph; import com.falkordb.impl.resultset.ResultSetImpl; -import com.falkordb.Header; -import com.falkordb.GraphContext; -import com.falkordb.GraphContextGenerator; -import com.falkordb.GraphTransaction; -import com.falkordb.ResultSet; public class TransactionTest { diff --git a/src/test/java/com/falkordb/exceptions/GraphErrorTest.java b/src/test/java/com/falkordb/exceptions/GraphErrorTest.java index 8d468e7..6c5321e 100644 --- a/src/test/java/com/falkordb/exceptions/GraphErrorTest.java +++ b/src/test/java/com/falkordb/exceptions/GraphErrorTest.java @@ -13,7 +13,6 @@ import com.falkordb.GraphContext; import com.falkordb.GraphContextGenerator; import com.falkordb.impl.api.Graph; -import com.falkordb.exceptions.GraphException; public class GraphErrorTest { diff --git a/src/test/java/com/falkordb/graph_entities/PathTest.java b/src/test/java/com/falkordb/graph_entities/PathTest.java index fbfb387..93587ef 100644 --- a/src/test/java/com/falkordb/graph_entities/PathTest.java +++ b/src/test/java/com/falkordb/graph_entities/PathTest.java @@ -3,10 +3,6 @@ import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.Test; -import com.falkordb.graph_entities.Edge; -import com.falkordb.graph_entities.Node; -import com.falkordb.graph_entities.Path; - import java.util.List; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; diff --git a/src/test/java/com/falkordb/impl/UtilsTest.java b/src/test/java/com/falkordb/impl/UtilsTest.java index 52a0bf3..097867b 100644 --- a/src/test/java/com/falkordb/impl/UtilsTest.java +++ b/src/test/java/com/falkordb/impl/UtilsTest.java @@ -11,8 +11,6 @@ import org.junit.Assert; import org.junit.Test; -import com.falkordb.impl.Utils; - public class UtilsTest { @Test