From 1eaefd6e86a8d1b9d99720b641aa8118e5b096a4 Mon Sep 17 00:00:00 2001 From: Avital Fine <79420960+AvitalFineRedis@users.noreply.github.com> Date: Thu, 28 Oct 2021 16:41:40 +0200 Subject: [PATCH] RedisModulePipelineCommands (#2680) --- .../redis/clients/jedis/ClusterPipeline.java | 57 ++++++++++++++++++- .../java/redis/clients/jedis/Pipeline.java | 54 +++++++++++++++++- .../clients/jedis/ReliableTransaction.java | 54 +++++++++++++++++- .../java/redis/clients/jedis/Transaction.java | 54 +++++++++++++++++- .../commands/RedisModulePipelineCommands.java | 7 +++ .../jedis/json/RedisJsonPipelineCommands.java | 18 ++++++ .../search/RediSearchPipelineCommands.java | 12 ++++ 7 files changed, 252 insertions(+), 4 deletions(-) create mode 100644 src/main/java/redis/clients/jedis/commands/RedisModulePipelineCommands.java create mode 100644 src/main/java/redis/clients/jedis/json/RedisJsonPipelineCommands.java create mode 100644 src/main/java/redis/clients/jedis/search/RediSearchPipelineCommands.java diff --git a/src/main/java/redis/clients/jedis/ClusterPipeline.java b/src/main/java/redis/clients/jedis/ClusterPipeline.java index 78819aab6f..499ae08a1f 100644 --- a/src/main/java/redis/clients/jedis/ClusterPipeline.java +++ b/src/main/java/redis/clients/jedis/ClusterPipeline.java @@ -3,16 +3,23 @@ import redis.clients.jedis.args.*; import redis.clients.jedis.commands.PipelineBinaryCommands; import redis.clients.jedis.commands.PipelineCommands; +import redis.clients.jedis.commands.RedisModulePipelineCommands; +import redis.clients.jedis.json.Path; import redis.clients.jedis.params.*; import redis.clients.jedis.providers.JedisClusterConnectionProvider; import redis.clients.jedis.resps.*; +import redis.clients.jedis.search.IndexOptions; +import redis.clients.jedis.search.Query; +import redis.clients.jedis.search.Schema; +import redis.clients.jedis.search.SearchResult; import redis.clients.jedis.stream.*; import java.util.List; import java.util.Map; import java.util.Set; -public class ClusterPipeline extends MultiNodePipelineBase implements PipelineCommands, PipelineBinaryCommands { +public class ClusterPipeline extends MultiNodePipelineBase implements PipelineCommands, PipelineBinaryCommands, + RedisModulePipelineCommands { private final JedisClusterConnectionProvider provider; private final RedisCommandObjects commandObjects; @@ -2713,4 +2720,52 @@ public Response strAlgoLCSKeys(byte[] keyA, byte[] keyB, StrAlgo throw new UnsupportedOperationException("Not supported yet."); // return appendCommand(provider.getNode(key), commandObjects.strAlgoLCSStrings(keyA, keyB, params)); } + + @Override + public Response jsonSet(String key, Object object) { + return appendCommand(provider.getNode(key), commandObjects.jsonSet(key, object)); + } + + @Override + public Response jsonSet(String key, Path path, Object object) { + return appendCommand(provider.getNode(key), commandObjects.jsonSet(key, path, object)); + } + + @Override + public Response jsonGet(String key, Class clazz) { + return appendCommand(provider.getNode(key), commandObjects.jsonGet(key, clazz)); + } + + @Override + public Response jsonGet(String key, Class clazz, Path... paths) { + return appendCommand(provider.getNode(key), commandObjects.jsonGet(key, clazz, paths)); + } + + @Override + public Response jsonDel(String key) { + return appendCommand(provider.getNode(key), commandObjects.jsonDel(key)); + } + + @Override + public Response jsonDel(String key, Path path) { + return appendCommand(provider.getNode(key), commandObjects.jsonDel(key, path)); + } + + @Override + public Response ftCreate(String indexName, IndexOptions indexOptions, Schema schema) { + throw new UnsupportedOperationException("Not supported yet."); + //return appendCommand(provider.getNode(key), commandObjects.ftCreate(indexName, indexOptions, schema)); + } + + @Override + public Response ftSearch(String indexName, Query query) { + throw new UnsupportedOperationException("Not supported yet."); + //return appendCommand(provider.getNode(key), commandObjects.ftCreate(indexName, query)); + } + + @Override + public Response ftSearch(byte[] indexName, Query query) { + throw new UnsupportedOperationException("Not supported yet."); + //return appendCommand(provider.getNode(key), commandObjects.ftCreate(indexName, query)); + } } diff --git a/src/main/java/redis/clients/jedis/Pipeline.java b/src/main/java/redis/clients/jedis/Pipeline.java index d249740a71..1ed849fff2 100644 --- a/src/main/java/redis/clients/jedis/Pipeline.java +++ b/src/main/java/redis/clients/jedis/Pipeline.java @@ -3,15 +3,22 @@ import redis.clients.jedis.args.*; import redis.clients.jedis.commands.PipelineBinaryCommands; import redis.clients.jedis.commands.PipelineCommands; +import redis.clients.jedis.commands.RedisModulePipelineCommands; +import redis.clients.jedis.json.Path; import redis.clients.jedis.params.*; import redis.clients.jedis.resps.*; +import redis.clients.jedis.search.IndexOptions; +import redis.clients.jedis.search.Query; +import redis.clients.jedis.search.Schema; +import redis.clients.jedis.search.SearchResult; import redis.clients.jedis.stream.*; import java.util.List; import java.util.Map; import java.util.Set; -public class Pipeline extends PipelineBase implements PipelineCommands, PipelineBinaryCommands { +public class Pipeline extends PipelineBase implements PipelineCommands, PipelineBinaryCommands, + RedisModulePipelineCommands { private final RedisCommandObjects commandObjects; @@ -2678,4 +2685,49 @@ public Response bitop(BitOP op, byte[] destKey, byte[]... srcKeys) { public Response strAlgoLCSKeys(byte[] keyA, byte[] keyB, StrAlgoLCSParams params) { return appendCommand(commandObjects.strAlgoLCSStrings(keyA, keyB, params)); } + + @Override + public Response jsonSet(String key, Object object) { + return appendCommand(commandObjects.jsonSet(key, object)); + } + + @Override + public Response jsonSet(String key, Path path, Object object) { + return appendCommand(commandObjects.jsonSet(key, path, object)); + } + + @Override + public Response jsonGet(String key, Class clazz) { + return appendCommand(commandObjects.jsonGet(key, clazz)); + } + + @Override + public Response jsonGet(String key, Class clazz, Path... paths) { + return appendCommand(commandObjects.jsonGet(key, clazz, paths)); + } + + @Override + public Response jsonDel(String key) { + return appendCommand(commandObjects.jsonDel(key)); + } + + @Override + public Response jsonDel(String key, Path path) { + return appendCommand(commandObjects.jsonDel(key, path)); + } + + @Override + public Response ftCreate(String indexName, IndexOptions indexOptions, Schema schema) { + return appendCommand(commandObjects.ftCreate(indexName, indexOptions, schema)); + } + + @Override + public Response ftSearch(String indexName, Query query) { + return appendCommand(commandObjects.ftSearch(indexName, query)); + } + + @Override + public Response ftSearch(byte[] indexName, Query query) { + return appendCommand(commandObjects.ftSearch(indexName, query)); + } } diff --git a/src/main/java/redis/clients/jedis/ReliableTransaction.java b/src/main/java/redis/clients/jedis/ReliableTransaction.java index 6dbe57d76a..fc2cf0ac51 100644 --- a/src/main/java/redis/clients/jedis/ReliableTransaction.java +++ b/src/main/java/redis/clients/jedis/ReliableTransaction.java @@ -3,15 +3,22 @@ import redis.clients.jedis.args.*; import redis.clients.jedis.commands.PipelineBinaryCommands; import redis.clients.jedis.commands.PipelineCommands; +import redis.clients.jedis.commands.RedisModulePipelineCommands; +import redis.clients.jedis.json.Path; import redis.clients.jedis.params.*; import redis.clients.jedis.resps.*; +import redis.clients.jedis.search.IndexOptions; +import redis.clients.jedis.search.Query; +import redis.clients.jedis.search.Schema; +import redis.clients.jedis.search.SearchResult; import redis.clients.jedis.stream.*; import java.util.List; import java.util.Map; import java.util.Set; -public class ReliableTransaction extends ReliableTransactionBase implements PipelineCommands, PipelineBinaryCommands { +public class ReliableTransaction extends ReliableTransactionBase implements PipelineCommands, + PipelineBinaryCommands, RedisModulePipelineCommands { private final RedisCommandObjects commandObjects; @@ -2678,4 +2685,49 @@ public Response bitop(BitOP op, byte[] destKey, byte[]... srcKeys) { public Response strAlgoLCSKeys(byte[] keyA, byte[] keyB, StrAlgoLCSParams params) { return appendCommand(commandObjects.strAlgoLCSStrings(keyA, keyB, params)); } + + @Override + public Response jsonSet(String key, Object object) { + return appendCommand(commandObjects.jsonSet(key, object)); + } + + @Override + public Response jsonSet(String key, Path path, Object object) { + return appendCommand(commandObjects.jsonSet(key, path, object)); + } + + @Override + public Response jsonGet(String key, Class clazz) { + return appendCommand(commandObjects.jsonGet(key, clazz)); + } + + @Override + public Response jsonGet(String key, Class clazz, Path... paths) { + return appendCommand(commandObjects.jsonGet(key, clazz, paths)); + } + + @Override + public Response jsonDel(String key) { + return appendCommand(commandObjects.jsonDel(key)); + } + + @Override + public Response jsonDel(String key, Path path) { + return appendCommand(commandObjects.jsonDel(key, path)); + } + + @Override + public Response ftCreate(String indexName, IndexOptions indexOptions, Schema schema) { + return appendCommand(commandObjects.ftCreate(indexName, indexOptions, schema)); + } + + @Override + public Response ftSearch(String indexName, Query query) { + return appendCommand(commandObjects.ftSearch(indexName, query)); + } + + @Override + public Response ftSearch(byte[] indexName, Query query) { + return appendCommand(commandObjects.ftSearch(indexName, query)); + } } diff --git a/src/main/java/redis/clients/jedis/Transaction.java b/src/main/java/redis/clients/jedis/Transaction.java index 64e0790260..18789ea89f 100644 --- a/src/main/java/redis/clients/jedis/Transaction.java +++ b/src/main/java/redis/clients/jedis/Transaction.java @@ -3,15 +3,22 @@ import redis.clients.jedis.args.*; import redis.clients.jedis.commands.PipelineBinaryCommands; import redis.clients.jedis.commands.PipelineCommands; +import redis.clients.jedis.commands.RedisModulePipelineCommands; +import redis.clients.jedis.json.Path; import redis.clients.jedis.params.*; import redis.clients.jedis.resps.*; +import redis.clients.jedis.search.IndexOptions; +import redis.clients.jedis.search.Query; +import redis.clients.jedis.search.Schema; +import redis.clients.jedis.search.SearchResult; import redis.clients.jedis.stream.*; import java.util.List; import java.util.Map; import java.util.Set; -public class Transaction extends PipelinedTransactionBase implements PipelineCommands, PipelineBinaryCommands { +public class Transaction extends PipelinedTransactionBase implements PipelineCommands, + PipelineBinaryCommands, RedisModulePipelineCommands { private final RedisCommandObjects commandObjects; @@ -2678,4 +2685,49 @@ public Response bitop(BitOP op, byte[] destKey, byte[]... srcKeys) { public Response strAlgoLCSKeys(byte[] keyA, byte[] keyB, StrAlgoLCSParams params) { return appendCommand(commandObjects.strAlgoLCSStrings(keyA, keyB, params)); } + + @Override + public Response jsonSet(String key, Object object) { + return appendCommand(commandObjects.jsonSet(key, object)); + } + + @Override + public Response jsonSet(String key, Path path, Object object) { + return appendCommand(commandObjects.jsonSet(key, path, object)); + } + + @Override + public Response jsonGet(String key, Class clazz) { + return appendCommand(commandObjects.jsonGet(key, clazz)); + } + + @Override + public Response jsonGet(String key, Class clazz, Path... paths) { + return appendCommand(commandObjects.jsonGet(key, clazz, paths)); + } + + @Override + public Response jsonDel(String key) { + return appendCommand(commandObjects.jsonDel(key)); + } + + @Override + public Response jsonDel(String key, Path path) { + return appendCommand(commandObjects.jsonDel(key, path)); + } + + @Override + public Response ftCreate(String indexName, IndexOptions indexOptions, Schema schema) { + return appendCommand(commandObjects.ftCreate(indexName, indexOptions, schema)); + } + + @Override + public Response ftSearch(String indexName, Query query) { + return appendCommand(commandObjects.ftSearch(indexName, query)); + } + + @Override + public Response ftSearch(byte[] indexName, Query query) { + return appendCommand(commandObjects.ftSearch(indexName, query)); + } } diff --git a/src/main/java/redis/clients/jedis/commands/RedisModulePipelineCommands.java b/src/main/java/redis/clients/jedis/commands/RedisModulePipelineCommands.java new file mode 100644 index 0000000000..21956fb37e --- /dev/null +++ b/src/main/java/redis/clients/jedis/commands/RedisModulePipelineCommands.java @@ -0,0 +1,7 @@ +package redis.clients.jedis.commands; + +import redis.clients.jedis.json.RedisJsonPipelineCommands; +import redis.clients.jedis.search.RediSearchPipelineCommands; + +public interface RedisModulePipelineCommands extends RediSearchPipelineCommands, RedisJsonPipelineCommands { +} diff --git a/src/main/java/redis/clients/jedis/json/RedisJsonPipelineCommands.java b/src/main/java/redis/clients/jedis/json/RedisJsonPipelineCommands.java new file mode 100644 index 0000000000..c2ee2fb5b7 --- /dev/null +++ b/src/main/java/redis/clients/jedis/json/RedisJsonPipelineCommands.java @@ -0,0 +1,18 @@ +package redis.clients.jedis.json; + +import redis.clients.jedis.Response; + +public interface RedisJsonPipelineCommands { + + Response jsonSet(String key, Object object); + + Response jsonSet(String key, Path path, Object object); + + Response jsonGet(String key, Class clazz); + + Response jsonGet(String key, Class clazz, Path... paths); + + Response jsonDel(String key); + + Response jsonDel(String key, Path path); +} diff --git a/src/main/java/redis/clients/jedis/search/RediSearchPipelineCommands.java b/src/main/java/redis/clients/jedis/search/RediSearchPipelineCommands.java new file mode 100644 index 0000000000..db517c3112 --- /dev/null +++ b/src/main/java/redis/clients/jedis/search/RediSearchPipelineCommands.java @@ -0,0 +1,12 @@ +package redis.clients.jedis.search; + +import redis.clients.jedis.Response; + +public interface RediSearchPipelineCommands { + + Response ftCreate(String indexName, IndexOptions indexOptions, Schema schema); + + Response ftSearch(String indexName, Query query); + + Response ftSearch(byte[] indexName, Query query); +}