From 75c6903ad3626e1e63e94ab10cdfa3b5dffc34a4 Mon Sep 17 00:00:00 2001 From: Alexey Kuzin Date: Tue, 3 Oct 2023 21:27:50 +0200 Subject: [PATCH 1/3] Add Collection to ArrayValue object converter Also replace unnecessary stream usage with less GC-pressing code in the List object converter --- .gitignore | 3 ++ .../driver/api/MessagePackMapperBuilder.java | 7 ++++ .../mappers/DefaultMessagePackMapper.java | 22 ++++++++-- ...efaultCollectionToArrayValueConverter.java | 35 ++++++++++++++++ .../DefaultListToArrayValueConverter.java | 10 +++-- .../DefaultMessagePackMapperFactory.java | 1 + .../mappers/DefaultMessagePackMapperTest.java | 40 +++++++++++++++++++ 7 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 src/main/java/io/tarantool/driver/mappers/converters/object/DefaultCollectionToArrayValueConverter.java diff --git a/.gitignore b/.gitignore index b4111e738..b6174007b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ target/ .idea/ +.settings/ +.classpath +.project .rocks/ tmp/ *.iml diff --git a/src/main/java/io/tarantool/driver/api/MessagePackMapperBuilder.java b/src/main/java/io/tarantool/driver/api/MessagePackMapperBuilder.java index 59f104601..7b1392a4c 100644 --- a/src/main/java/io/tarantool/driver/api/MessagePackMapperBuilder.java +++ b/src/main/java/io/tarantool/driver/api/MessagePackMapperBuilder.java @@ -35,6 +35,13 @@ public interface MessagePackMapperBuilder { */ MessagePackMapperBuilder withDefaultArrayValueConverter(); + /** + * Configure the mapper with default {@link Collection} to {@code MP_ARRAY} entity converter + * + * @return builder + */ + MessagePackMapperBuilder withDefaultCollectionObjectConverter(); + /** * Configure the mapper with default {@link List} to {@code MP_ARRAY} entity converter * diff --git a/src/main/java/io/tarantool/driver/mappers/DefaultMessagePackMapper.java b/src/main/java/io/tarantool/driver/mappers/DefaultMessagePackMapper.java index c7b198803..795bffb0e 100644 --- a/src/main/java/io/tarantool/driver/mappers/DefaultMessagePackMapper.java +++ b/src/main/java/io/tarantool/driver/mappers/DefaultMessagePackMapper.java @@ -5,6 +5,7 @@ import io.tarantool.driver.mappers.converters.ConverterWrapper; import io.tarantool.driver.mappers.converters.ObjectConverter; import io.tarantool.driver.mappers.converters.ValueConverter; +import io.tarantool.driver.mappers.converters.object.DefaultCollectionToArrayValueConverter; import io.tarantool.driver.mappers.converters.object.DefaultListToArrayValueConverter; import io.tarantool.driver.mappers.converters.object.DefaultMapToMapValueConverter; import io.tarantool.driver.mappers.converters.value.defaults.DefaultArrayValueToListConverter; @@ -14,7 +15,9 @@ import org.msgpack.value.Value; import org.msgpack.value.ValueType; +import java.util.AbstractCollection; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -299,9 +302,10 @@ public Builder withDefaultMapValueConverter() { @Override public Builder withDefaultMapObjectConverter() { - mapper.registerObjectConverter(new DefaultMapToMapValueConverter(mapper)); + DefaultMapToMapValueConverter converter = new DefaultMapToMapValueConverter(mapper); + mapper.registerObjectConverter(converter); Class> cls = (Class>) (Object) HashMap.class; - mapper.registerObjectConverter(cls, new DefaultMapToMapValueConverter(mapper)); + mapper.registerObjectConverter(cls, converter); return this; } @@ -311,11 +315,21 @@ public Builder withDefaultArrayValueConverter() { return this; } + @Override + public Builder withDefaultCollectionObjectConverter() { + DefaultCollectionToArrayValueConverter converter = new DefaultCollectionToArrayValueConverter(mapper); + mapper.registerObjectConverter(converter); + mapper.registerObjectConverter((Class>) (Object) Collection.class, converter); + mapper.registerObjectConverter((Class>) (Object) AbstractCollection.class, converter); + return this; + } + @Override public Builder withDefaultListObjectConverter() { - mapper.registerObjectConverter(new DefaultListToArrayValueConverter(mapper)); + DefaultListToArrayValueConverter converter = new DefaultListToArrayValueConverter(mapper); + mapper.registerObjectConverter(converter); Class> cls = (Class>) (Object) ArrayList.class; - mapper.registerObjectConverter(cls, new DefaultListToArrayValueConverter(mapper)); + mapper.registerObjectConverter(cls, converter); return this; } diff --git a/src/main/java/io/tarantool/driver/mappers/converters/object/DefaultCollectionToArrayValueConverter.java b/src/main/java/io/tarantool/driver/mappers/converters/object/DefaultCollectionToArrayValueConverter.java new file mode 100644 index 000000000..379ba3916 --- /dev/null +++ b/src/main/java/io/tarantool/driver/mappers/converters/object/DefaultCollectionToArrayValueConverter.java @@ -0,0 +1,35 @@ +package io.tarantool.driver.mappers.converters.object; + +import io.tarantool.driver.mappers.MessagePackObjectMapper; +import io.tarantool.driver.mappers.converters.ObjectConverter; +import org.msgpack.value.ArrayValue; +import org.msgpack.value.Value; +import org.msgpack.value.ValueFactory; + +import java.util.Collection; + +/** + * Default {@link Collection} to {@link ArrayValue} converter + * + * @author Alexey Kuzin + */ +public class DefaultCollectionToArrayValueConverter implements ObjectConverter, ArrayValue> { + + private static final long serialVersionUID = 20231003L; + + private final MessagePackObjectMapper mapper; + + public DefaultCollectionToArrayValueConverter(MessagePackObjectMapper mapper) { + this.mapper = mapper; + } + + @Override + public ArrayValue toValue(Collection object) { + Value[] values = new Value[object.size()]; + int i = 0; + for (Object value : object) { + values[i++] = value == null ? ValueFactory.newNil() : mapper.toValue(value); + } + return ValueFactory.newArray(values, false); + } +} diff --git a/src/main/java/io/tarantool/driver/mappers/converters/object/DefaultListToArrayValueConverter.java b/src/main/java/io/tarantool/driver/mappers/converters/object/DefaultListToArrayValueConverter.java index 7aa195557..920644d5f 100644 --- a/src/main/java/io/tarantool/driver/mappers/converters/object/DefaultListToArrayValueConverter.java +++ b/src/main/java/io/tarantool/driver/mappers/converters/object/DefaultListToArrayValueConverter.java @@ -7,8 +7,6 @@ import org.msgpack.value.ValueFactory; import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * Default {@link List} to {@link ArrayValue} converter @@ -27,7 +25,11 @@ public DefaultListToArrayValueConverter(MessagePackObjectMapper mapper) { @Override public ArrayValue toValue(List object) { - Stream values = object.stream().map(v -> v == null ? ValueFactory.newNil() : mapper.toValue(v)); - return ValueFactory.newArray(values.collect(Collectors.toList())); + Value[] values = new Value[object.size()]; + int i = 0; + for (Object value : object) { + values[i++] = value == null ? ValueFactory.newNil() : mapper.toValue(value); + } + return ValueFactory.newArray(values, false); } } diff --git a/src/main/java/io/tarantool/driver/mappers/factories/DefaultMessagePackMapperFactory.java b/src/main/java/io/tarantool/driver/mappers/factories/DefaultMessagePackMapperFactory.java index 590205bdc..c085b7f49 100644 --- a/src/main/java/io/tarantool/driver/mappers/factories/DefaultMessagePackMapperFactory.java +++ b/src/main/java/io/tarantool/driver/mappers/factories/DefaultMessagePackMapperFactory.java @@ -131,6 +131,7 @@ public DefaultMessagePackMapper defaultComplexTypesMapper() { .withDefaultArrayValueConverter() .withDefaultMapObjectConverter() .withDefaultMapValueConverter() + .withDefaultCollectionObjectConverter() .build(); // internal types converter diff --git a/src/test/java/io/tarantool/driver/mappers/DefaultMessagePackMapperTest.java b/src/test/java/io/tarantool/driver/mappers/DefaultMessagePackMapperTest.java index accece744..974ab281a 100644 --- a/src/test/java/io/tarantool/driver/mappers/DefaultMessagePackMapperTest.java +++ b/src/test/java/io/tarantool/driver/mappers/DefaultMessagePackMapperTest.java @@ -18,8 +18,11 @@ import java.lang.reflect.Field; import java.math.BigDecimal; +import java.util.AbstractCollection; import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; @@ -92,6 +95,43 @@ void testDefaultComplexConverters() { ValueFactory.newString("Hello"), ValueFactory.newInteger(111)); assertEquals(expectedValue, mapper.toValue(testList)); + Collection testCollection = new AbstractCollection() { + public Iterator iterator() { + return new Iterator() { + private Iterator i = testList.iterator(); + + public boolean hasNext() { + return i.hasNext(); + } + + public Object next() { + return i.next(); + } + + public void remove() { + i.remove(); + } + }; + } + + public int size() { + return testList.size(); + } + + public boolean isEmpty() { + return testList.isEmpty(); + } + + public void clear() { + testList.clear(); + } + + public boolean contains(Object v) { + return testList.contains(v); + } + }; + assertEquals(expectedValue, mapper.toValue(testCollection)); + expectedValue = ValueFactory.newArray(new ImmutableLongValueImpl(1L), new ImmutableLongValueImpl(2L)); assertEquals(expectedValue, mapper.toValue(new long[]{1L, 2L})); From 68c34a629401c47a6896ab81aeff1ff590df6d9f Mon Sep 17 00:00:00 2001 From: Alexey Kuzin Date: Tue, 3 Oct 2023 21:38:30 +0200 Subject: [PATCH 2/3] Do not use streams in ArrayValue to List value converter Replace streams usage with less GC-pressing code --- .../defaults/DefaultArrayValueToListConverter.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/tarantool/driver/mappers/converters/value/defaults/DefaultArrayValueToListConverter.java b/src/main/java/io/tarantool/driver/mappers/converters/value/defaults/DefaultArrayValueToListConverter.java index 22f202fa8..af19eb9a5 100644 --- a/src/main/java/io/tarantool/driver/mappers/converters/value/defaults/DefaultArrayValueToListConverter.java +++ b/src/main/java/io/tarantool/driver/mappers/converters/value/defaults/DefaultArrayValueToListConverter.java @@ -3,9 +3,10 @@ import io.tarantool.driver.mappers.MessagePackValueMapper; import io.tarantool.driver.mappers.converters.ValueConverter; import org.msgpack.value.ArrayValue; +import org.msgpack.value.Value; +import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * Default {@link ArrayValue} to {@link List} converter @@ -23,7 +24,11 @@ public DefaultArrayValueToListConverter(MessagePackValueMapper mapper) { } @Override - public List fromValue(ArrayValue value) { - return value.list().stream().map(mapper::fromValue).collect(Collectors.toList()); + public List fromValue(ArrayValue values) { + ArrayList objects = new ArrayList<>(values.size()); + for (Value value : values) { + objects.add(mapper.fromValue(value)); + } + return objects; } } From 585d827094f8a06521d7091d6d555c786cde3557 Mon Sep 17 00:00:00 2001 From: Alexey Kuzin Date: Tue, 3 Oct 2023 22:24:09 +0200 Subject: [PATCH 3/3] Use Collection instead of List as arguments type in TarantoolClient Replace arguments type in call* and eval* methods to Collection. This improves the API and allows to remove redundant creation of intermediate ArrayLists on each call. --- CHANGELOG.md | 1 + .../driver/api/TarantoolCallOperations.java | 37 +++++++------- .../driver/api/TarantoolEvalOperations.java | 7 +-- .../driver/core/AbstractTarantoolClient.java | 49 ++++++++++--------- .../driver/core/ProxyTarantoolClient.java | 44 +++++++++-------- .../driver/core/RetryingTarantoolClient.java | 44 +++++++++-------- .../core/proxy/AbstractProxyOperation.java | 8 +-- .../core/proxy/DeleteProxyOperation.java | 8 ++- .../core/proxy/InsertManyProxyOperation.java | 7 +-- .../core/proxy/InsertProxyOperation.java | 7 +-- .../core/proxy/ReplaceManyProxyOperation.java | 7 +-- .../core/proxy/ReplaceProxyOperation.java | 7 +-- .../core/proxy/SelectProxyOperation.java | 8 ++- .../core/proxy/TruncateProxyOperation.java | 11 ++--- .../core/proxy/UpdateProxyOperation.java | 8 ++- .../core/proxy/UpsertProxyOperation.java | 7 +-- .../requests/TarantoolCallRequest.java | 4 +- .../requests/TarantoolEvalRequest.java | 4 +- .../proxy/ProxyOperationBuildersTest.java | 25 +++++----- 19 files changed, 141 insertions(+), 152 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 330fcec26..badb249e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Internal and API changes +- **[breaking change]** replace `List` type with `Collection` for the `arguments` client API method parameters - Bump testcontainers-java-tarantool to 1.0.1 ([#400](https://github.com/tarantool/cartridge-java/issues/400)) - Add `"mode"` option for select operation ([#107](https://github.com/tarantool/cartridge-java/issues/107)) - Change using of proxy client parameters (`mode`, `rollback_on_error`, `stop_on_error`) with enum classes ([#419](https://github.com/tarantool/cartridge-java/issues/419)) diff --git a/src/main/java/io/tarantool/driver/api/TarantoolCallOperations.java b/src/main/java/io/tarantool/driver/api/TarantoolCallOperations.java index feb7b7f26..eb6ff7ae3 100644 --- a/src/main/java/io/tarantool/driver/api/TarantoolCallOperations.java +++ b/src/main/java/io/tarantool/driver/api/TarantoolCallOperations.java @@ -8,6 +8,7 @@ import io.tarantool.driver.mappers.factories.ResultMapperFactoryFactory; import org.msgpack.value.Value; +import java.util.Collection; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; @@ -51,7 +52,7 @@ public interface TarantoolCallOperations { * @return some result * @throws TarantoolClientException if the client is not connected or some other error occurred */ - CompletableFuture> call(String functionName, List arguments) throws TarantoolClientException; + CompletableFuture> call(String functionName, Collection arguments) throws TarantoolClientException; /** * Execute a function defined on Tarantool instance @@ -62,7 +63,7 @@ public interface TarantoolCallOperations { * @return some result * @throws TarantoolClientException if the client is not connected */ - CompletableFuture> call(String functionName, List arguments, MessagePackMapper mapper) + CompletableFuture> call(String functionName, Collection arguments, MessagePackMapper mapper) throws TarantoolClientException; /** @@ -108,7 +109,7 @@ CompletableFuture call( */ CompletableFuture> callForTupleResult( String functionName, - List arguments, + Collection arguments, Class entityClass) throws TarantoolClientException; @@ -125,7 +126,7 @@ CompletableFuture> callForTupleResult( */ CompletableFuture call( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException; @@ -144,7 +145,7 @@ CompletableFuture call( */ CompletableFuture> callForTupleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Class entityClass) throws TarantoolClientException; @@ -162,7 +163,7 @@ CompletableFuture> callForTupleResult( */ CompletableFuture call( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException; @@ -181,7 +182,7 @@ CompletableFuture call( */ CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Class resultClass) throws TarantoolClientException; @@ -200,7 +201,7 @@ CompletableFuture callForSingleResult( */ CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, ValueConverter valueConverter) throws TarantoolClientException; @@ -219,7 +220,7 @@ CompletableFuture callForSingleResult( */ CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException; @@ -237,7 +238,7 @@ CompletableFuture callForSingleResult( */ CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, Class resultClass) throws TarantoolClientException; @@ -254,7 +255,7 @@ CompletableFuture callForSingleResult( */ CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, ValueConverter valueConverter) throws TarantoolClientException; @@ -271,7 +272,7 @@ CompletableFuture callForSingleResult( */ CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException; @@ -335,7 +336,7 @@ CompletableFuture callForSingleResult( */ > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Supplier resultContainerSupplier, Class resultClass) @@ -356,7 +357,7 @@ > CompletableFuture callForMultiResult( */ > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Supplier resultContainerSupplier, ValueConverter valueConverter) @@ -376,7 +377,7 @@ > CompletableFuture callForMultiResult( */ > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException; @@ -395,7 +396,7 @@ > CompletableFuture callForMultiResult( */ > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, Supplier resultContainerSupplier, Class resultClass) throws TarantoolClientException; @@ -414,7 +415,7 @@ > CompletableFuture callForMultiResult( */ > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, Supplier resultContainerSupplier, ValueConverter valueConverter) throws TarantoolClientException; @@ -432,7 +433,7 @@ > CompletableFuture callForMultiResult( */ > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException; diff --git a/src/main/java/io/tarantool/driver/api/TarantoolEvalOperations.java b/src/main/java/io/tarantool/driver/api/TarantoolEvalOperations.java index a69a144bf..68173bb05 100644 --- a/src/main/java/io/tarantool/driver/api/TarantoolEvalOperations.java +++ b/src/main/java/io/tarantool/driver/api/TarantoolEvalOperations.java @@ -4,6 +4,7 @@ import io.tarantool.driver.mappers.MessagePackObjectMapper; import io.tarantool.driver.mappers.MessagePackValueMapper; +import java.util.Collection; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -35,7 +36,7 @@ public interface TarantoolEvalOperations { * @return some result * @throws TarantoolClientException if the client is not connected */ - CompletableFuture> eval(String expression, List arguments) throws TarantoolClientException; + CompletableFuture> eval(String expression, Collection arguments) throws TarantoolClientException; /** * Execute a Lua expression in the Tarantool instance. If a result is expected, the expression must start with @@ -60,7 +61,7 @@ CompletableFuture> eval(String expression, MessagePackValueMapper result * @return some result * @throws TarantoolClientException if the client is not connected */ - CompletableFuture> eval(String expression, List arguments, MessagePackValueMapper resultMapper) + CompletableFuture> eval(String expression, Collection arguments, MessagePackValueMapper resultMapper) throws TarantoolClientException; /** @@ -76,7 +77,7 @@ CompletableFuture> eval(String expression, List arguments, MessagePac */ CompletableFuture> eval( String expression, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, MessagePackValueMapper resultMapper) throws TarantoolClientException; } diff --git a/src/main/java/io/tarantool/driver/core/AbstractTarantoolClient.java b/src/main/java/io/tarantool/driver/core/AbstractTarantoolClient.java index c497804b2..28d4e1616 100644 --- a/src/main/java/io/tarantool/driver/core/AbstractTarantoolClient.java +++ b/src/main/java/io/tarantool/driver/core/AbstractTarantoolClient.java @@ -234,13 +234,13 @@ public CompletableFuture> call(String functionName, Object... arguments) } @Override - public CompletableFuture> call(String functionName, List arguments) + public CompletableFuture> call(String functionName, Collection arguments) throws TarantoolClientException { return call(functionName, arguments, config.getMessagePackMapper()); } @Override - public CompletableFuture> call(String functionName, List arguments, MessagePackMapper mapper) + public CompletableFuture> call(String functionName, Collection arguments, MessagePackMapper mapper) throws TarantoolClientException { return makeRequest(functionName, arguments, mapper, mapper); } @@ -261,7 +261,7 @@ public CompletableFuture call( @Override public CompletableFuture> callForTupleResult( - String functionName, List arguments, Class tupleClass) + String functionName, Collection arguments, Class tupleClass) throws TarantoolClientException { return callForTupleResult(functionName, arguments, config.getMessagePackMapper(), tupleClass); } @@ -269,7 +269,7 @@ public CompletableFuture> callForTupleResult( @Override public CompletableFuture call( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return call(functionName, arguments, config.getMessagePackMapper(), resultMapper); @@ -278,7 +278,7 @@ public CompletableFuture call( @Override public CompletableFuture> callForTupleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Class tupleClass) throws TarantoolClientException { @@ -289,7 +289,7 @@ public CompletableFuture> callForTupleResult( @Override public CompletableFuture call( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { @@ -299,7 +299,7 @@ public CompletableFuture call( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, Class resultClass) throws TarantoolClientException { return callForSingleResult(functionName, arguments, config.getMessagePackMapper(), resultClass); @@ -308,7 +308,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, ValueConverter valueConverter) throws TarantoolClientException { return callForSingleResult(functionName, arguments, config.getMessagePackMapper(), valueConverter); @@ -317,7 +317,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return callForSingleResult(functionName, arguments, config.getMessagePackMapper(), resultMapper); } @@ -344,7 +344,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Class resultClass) throws TarantoolClientException { @@ -355,7 +355,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, ValueConverter valueConverter) throws TarantoolClientException { @@ -366,7 +366,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { @@ -377,7 +377,7 @@ public CompletableFuture callForSingleResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, Supplier resultContainerSupplier, Class resultClass) throws TarantoolClientException { @@ -388,7 +388,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, Supplier resultContainerSupplier, ValueConverter valueConverter) throws TarantoolClientException { return callForMultiResult(functionName, arguments, config.getMessagePackMapper(), @@ -398,7 +398,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return callForMultiResult(functionName, arguments, config.getMessagePackMapper(), resultMapper); } @@ -432,7 +432,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Supplier resultContainerSupplier, Class resultClass) @@ -444,7 +444,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Supplier resultContainerSupplier, ValueConverter valueConverter) @@ -456,7 +456,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { @@ -466,7 +466,7 @@ public > CompletableFuture callForMultiResult( private CompletableFuture> makeRequestForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { return makeRequest(functionName, arguments, argumentsMapper, resultMapper); @@ -474,7 +474,7 @@ private CompletableFuture> makeRequestForSingleResult( private > CompletableFuture> makeRequestForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { return makeRequest(functionName, arguments, argumentsMapper, resultMapper); @@ -482,7 +482,7 @@ private > CompletableFuture> makeRequestForMu private CompletableFuture makeRequest( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, MessagePackValueMapper resultMapper) throws TarantoolClientException { @@ -507,7 +507,7 @@ public CompletableFuture> eval(String expression) throws TarantoolClient } @Override - public CompletableFuture> eval(String expression, List arguments) + public CompletableFuture> eval(String expression, Collection arguments) throws TarantoolClientException { return eval(expression, arguments, config.getMessagePackMapper()); } @@ -519,7 +519,8 @@ public CompletableFuture> eval(String expression, MessagePackValueMapper } @Override - public CompletableFuture> eval(String expression, List arguments, MessagePackValueMapper resultMapper) + public CompletableFuture> eval( + String expression, Collection arguments, MessagePackValueMapper resultMapper) throws TarantoolClientException { return eval(expression, arguments, config.getMessagePackMapper(), resultMapper); } @@ -527,7 +528,7 @@ public CompletableFuture> eval(String expression, List arguments, Mes @Override public CompletableFuture> eval( String expression, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, MessagePackValueMapper resultMapper) throws TarantoolClientException { try { diff --git a/src/main/java/io/tarantool/driver/core/ProxyTarantoolClient.java b/src/main/java/io/tarantool/driver/core/ProxyTarantoolClient.java index c194a5ab6..e25860c19 100644 --- a/src/main/java/io/tarantool/driver/core/ProxyTarantoolClient.java +++ b/src/main/java/io/tarantool/driver/core/ProxyTarantoolClient.java @@ -177,13 +177,13 @@ public CompletableFuture> call(String functionName, Object... arguments) } @Override - public CompletableFuture> call(String functionName, List arguments) + public CompletableFuture> call(String functionName, Collection arguments) throws TarantoolClientException { return client.call(functionName, arguments); } @Override - public CompletableFuture> call(String functionName, List arguments, MessagePackMapper mapper) + public CompletableFuture> call(String functionName, Collection arguments, MessagePackMapper mapper) throws TarantoolClientException { return client.call(functionName, arguments, mapper); } @@ -201,25 +201,25 @@ public CompletableFuture call(String functionName, } @Override - public CompletableFuture> callForTupleResult(String functionName, List arguments, + public CompletableFuture> callForTupleResult(String functionName, Collection arguments, Class entityClass) throws TarantoolClientException { return client.callForTupleResult(functionName, arguments, entityClass); } @Override - public CompletableFuture call(String functionName, List arguments, + public CompletableFuture call(String functionName, Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return client.call(functionName, arguments, resultMapper); } @Override - public CompletableFuture> callForTupleResult(String functionName, List arguments, + public CompletableFuture> callForTupleResult(String functionName, Collection arguments, MessagePackObjectMapper argumentsMapper, Class entityClass) throws TarantoolClientException { return client.callForTupleResult(functionName, arguments, argumentsMapper, entityClass); } @Override - public CompletableFuture call(String functionName, List arguments, + public CompletableFuture call(String functionName, Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { return client.call(functionName, arguments, argumentsMapper, resultMapper); @@ -228,7 +228,7 @@ public CompletableFuture call(String functionName, List arguments, @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Class resultClass) throws TarantoolClientException { @@ -238,7 +238,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, ValueConverter valueConverter) throws TarantoolClientException { @@ -248,7 +248,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { @@ -256,7 +256,8 @@ public CompletableFuture callForSingleResult( } @Override - public CompletableFuture callForSingleResult(String functionName, List arguments, Class resultClass) + public CompletableFuture callForSingleResult( + String functionName, Collection arguments, Class resultClass) throws TarantoolClientException { return client.callForSingleResult(functionName, arguments, resultClass); } @@ -264,7 +265,7 @@ public CompletableFuture callForSingleResult(String functionName, List @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, ValueConverter valueConverter) throws TarantoolClientException { return client.callForSingleResult(functionName, arguments, valueConverter); @@ -273,7 +274,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return client.callForSingleResult(functionName, arguments, resultMapper); } @@ -300,7 +301,7 @@ public CompletableFuture callForSingleResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Supplier resultContainerSupplier, Class resultClass) throws TarantoolClientException { @@ -311,7 +312,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Supplier resultContainerSupplier, ValueConverter valueConverter) throws TarantoolClientException { @@ -322,7 +323,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { return client.callForMultiResult(functionName, arguments, argumentsMapper, resultMapper); @@ -331,7 +332,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, Supplier resultContainerSupplier, Class resultClass) throws TarantoolClientException { @@ -341,7 +342,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, Supplier resultContainerSupplier, ValueConverter valueConverter) throws TarantoolClientException { @@ -351,7 +352,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return client.callForMultiResult(functionName, arguments, resultMapper); } @@ -388,7 +389,7 @@ public CompletableFuture> eval(String expression) throws TarantoolClient } @Override - public CompletableFuture> eval(String expression, List arguments) throws TarantoolClientException { + public CompletableFuture> eval(String expression, Collection arguments) throws TarantoolClientException { return client.eval(expression, arguments); } @@ -399,7 +400,8 @@ public CompletableFuture> eval(String expression, MessagePackValueMapper } @Override - public CompletableFuture> eval(String expression, List arguments, MessagePackValueMapper resultMapper) + public CompletableFuture> eval( + String expression, Collection arguments, MessagePackValueMapper resultMapper) throws TarantoolClientException { return client.eval(expression, arguments, resultMapper); } @@ -407,7 +409,7 @@ public CompletableFuture> eval(String expression, List arguments, Mes @Override public CompletableFuture> eval( String expression, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, MessagePackValueMapper resultMapper) throws TarantoolClientException { return client.eval(expression, arguments, argumentsMapper, resultMapper); diff --git a/src/main/java/io/tarantool/driver/core/RetryingTarantoolClient.java b/src/main/java/io/tarantool/driver/core/RetryingTarantoolClient.java index c032efb31..99f96bba8 100644 --- a/src/main/java/io/tarantool/driver/core/RetryingTarantoolClient.java +++ b/src/main/java/io/tarantool/driver/core/RetryingTarantoolClient.java @@ -141,14 +141,15 @@ public CompletableFuture> call(String functionName, Object... arguments) } @Override - public CompletableFuture> call(String functionName, List arguments) throws TarantoolClientException { + public CompletableFuture> call(String functionName, Collection arguments) + throws TarantoolClientException { return wrapOperation(() -> client.call(functionName, arguments)); } @Override public CompletableFuture> call( String functionName, - List arguments, + Collection arguments, MessagePackMapper mapper) throws TarantoolClientException { return wrapOperation(() -> client.call(functionName, arguments, mapper)); } @@ -166,25 +167,25 @@ public CompletableFuture call(String functionName, } @Override - public CompletableFuture> callForTupleResult(String functionName, List arguments, + public CompletableFuture> callForTupleResult(String functionName, Collection arguments, Class entityClass) throws TarantoolClientException { return wrapOperation(() -> client.callForTupleResult(functionName, arguments, entityClass)); } @Override - public CompletableFuture call(String functionName, List arguments, + public CompletableFuture call(String functionName, Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return wrapOperation(() -> client.call(functionName, arguments, resultMapper)); } @Override - public CompletableFuture> callForTupleResult(String functionName, List arguments, + public CompletableFuture> callForTupleResult(String functionName, Collection arguments, MessagePackObjectMapper argumentsMapper, Class entityClass) throws TarantoolClientException { return wrapOperation(() -> client.callForTupleResult(functionName, arguments, argumentsMapper, entityClass)); } @Override - public CompletableFuture call(String functionName, List arguments, + public CompletableFuture call(String functionName, Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { return wrapOperation(() -> client.call(functionName, arguments, argumentsMapper, resultMapper)); @@ -193,7 +194,7 @@ public CompletableFuture call(String functionName, List arguments, @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Class resultClass) throws TarantoolClientException { return wrapOperation(() -> client.callForSingleResult(functionName, arguments, argumentsMapper, resultClass)); @@ -202,7 +203,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, ValueConverter valueConverter) throws TarantoolClientException { @@ -213,7 +214,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { @@ -221,7 +222,8 @@ public CompletableFuture callForSingleResult( } @Override - public CompletableFuture callForSingleResult(String functionName, List arguments, Class resultClass) + public CompletableFuture callForSingleResult( + String functionName, Collection arguments, Class resultClass) throws TarantoolClientException { return wrapOperation(() -> client.callForSingleResult(functionName, arguments, resultClass)); } @@ -229,7 +231,7 @@ public CompletableFuture callForSingleResult(String functionName, List @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, ValueConverter valueConverter) throws TarantoolClientException { return wrapOperation(() -> client.callForSingleResult(functionName, arguments, valueConverter)); @@ -238,7 +240,7 @@ public CompletableFuture callForSingleResult( @Override public CompletableFuture callForSingleResult( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return wrapOperation(() -> client.callForSingleResult(functionName, arguments, resultMapper)); @@ -267,7 +269,7 @@ public CompletableFuture callForSingleResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Supplier resultContainerSupplier, Class resultClass) @@ -279,7 +281,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, Supplier resultContainerSupplier, ValueConverter valueConverter) @@ -291,7 +293,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) throws TarantoolClientException { @@ -301,7 +303,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, Supplier resultContainerSupplier, Class resultClass) throws TarantoolClientException { @@ -312,7 +314,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, Supplier resultContainerSupplier, ValueConverter valueConverter) throws TarantoolClientException { @@ -323,7 +325,7 @@ public > CompletableFuture callForMultiResult( @Override public > CompletableFuture callForMultiResult( String functionName, - List arguments, + Collection arguments, CallResultMapper> resultMapper) throws TarantoolClientException { return wrapOperation(() -> client.callForMultiResult(functionName, arguments, resultMapper)); } @@ -364,7 +366,7 @@ public CompletableFuture> eval(String expression) throws TarantoolClient } @Override - public CompletableFuture> eval(String expression, List arguments) throws TarantoolClientException { + public CompletableFuture> eval(String expression, Collection arguments) throws TarantoolClientException { return wrapOperation(() -> client.eval(expression, arguments)); } @@ -378,14 +380,14 @@ public CompletableFuture> eval( @Override public CompletableFuture> eval( String expression, - List arguments, + Collection arguments, MessagePackValueMapper resultMapper) throws TarantoolClientException { return wrapOperation(() -> client.eval(expression, arguments, resultMapper)); } @Override public CompletableFuture> eval( - String expression, List arguments, + String expression, Collection arguments, MessagePackObjectMapper argumentsMapper, MessagePackValueMapper resultMapper) throws TarantoolClientException { return wrapOperation(() -> client.eval(expression, arguments, argumentsMapper, resultMapper)); diff --git a/src/main/java/io/tarantool/driver/core/proxy/AbstractProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/AbstractProxyOperation.java index 475f16c1d..4c0dc5604 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/AbstractProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/AbstractProxyOperation.java @@ -8,8 +8,8 @@ import io.tarantool.driver.mappers.CallResultMapper; import io.tarantool.driver.mappers.MessagePackObjectMapper; +import java.util.Collection; import java.util.EnumMap; -import java.util.List; import java.util.concurrent.CompletableFuture; /** @@ -23,14 +23,14 @@ abstract class AbstractProxyOperation implements ProxyOperation { protected final TarantoolCallOperations client; protected final String functionName; - protected final List arguments; + protected final Collection arguments; protected final CallResultMapper> resultMapper; private final MessagePackObjectMapper argumentsMapper; AbstractProxyOperation( TarantoolCallOperations client, String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { this.client = client; @@ -48,7 +48,7 @@ public String getFunctionName() { return functionName; } - public List getArguments() { + public Collection getArguments() { return arguments; } diff --git a/src/main/java/io/tarantool/driver/core/proxy/DeleteProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/DeleteProxyOperation.java index 29a479d4e..905b3fa57 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/DeleteProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/DeleteProxyOperation.java @@ -6,8 +6,7 @@ import io.tarantool.driver.mappers.CallResultMapper; import io.tarantool.driver.mappers.MessagePackObjectMapper; -import java.util.ArrayList; -import java.util.List; +import java.util.Collection; /** * Proxy operation for delete @@ -21,7 +20,7 @@ public final class DeleteProxyOperation extends AbstractProxyOperation { private DeleteProxyOperation( TarantoolCallOperations client, String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { super(client, functionName, arguments, argumentsMapper, resultMapper); @@ -45,8 +44,7 @@ public Builder self() { public DeleteProxyOperation build() { return new DeleteProxyOperation<>( - this.client, this.functionName, new ArrayList<>(arguments.values()), this.argumentsMapper, - this.resultMapper); + this.client, this.functionName, this.arguments.values(), this.argumentsMapper, this.resultMapper); } } } diff --git a/src/main/java/io/tarantool/driver/core/proxy/InsertManyProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/InsertManyProxyOperation.java index d8de0407f..a3d925c0d 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/InsertManyProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/InsertManyProxyOperation.java @@ -7,9 +7,7 @@ import io.tarantool.driver.mappers.MessagePackObjectMapper; import io.tarantool.driver.protocol.Packable; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; /** * Proxy operation for inserting many records at once @@ -24,7 +22,7 @@ public final class InsertManyProxyOperation arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { super(client, functionName, arguments, argumentsMapper, resultMapper); @@ -47,8 +45,7 @@ public Builder self() { public InsertManyProxyOperation build() { return new InsertManyProxyOperation<>( - this.client, this.functionName, new ArrayList<>(arguments.values()), this.argumentsMapper, - this.resultMapper); + this.client, this.functionName, this.arguments.values(), this.argumentsMapper, this.resultMapper); } } } diff --git a/src/main/java/io/tarantool/driver/core/proxy/InsertProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/InsertProxyOperation.java index 0aa994b49..b0ad065df 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/InsertProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/InsertProxyOperation.java @@ -7,9 +7,7 @@ import io.tarantool.driver.mappers.MessagePackObjectMapper; import io.tarantool.driver.protocol.Packable; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; /** * Proxy operation for insert @@ -24,7 +22,7 @@ public final class InsertProxyOperation arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { super(client, functionName, arguments, argumentsMapper, resultMapper); @@ -48,8 +46,7 @@ public Builder self() { public InsertProxyOperation build() { return new InsertProxyOperation<>( - this.client, this.functionName, new ArrayList<>(arguments.values()), this.argumentsMapper, - this.resultMapper); + this.client, this.functionName, this.arguments.values(), this.argumentsMapper, this.resultMapper); } } } diff --git a/src/main/java/io/tarantool/driver/core/proxy/ReplaceManyProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/ReplaceManyProxyOperation.java index 314f2847f..1dd4eaae0 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/ReplaceManyProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/ReplaceManyProxyOperation.java @@ -7,9 +7,7 @@ import io.tarantool.driver.mappers.MessagePackObjectMapper; import io.tarantool.driver.protocol.Packable; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; /** * Proxy operation for replacing many records at once @@ -24,7 +22,7 @@ public final class ReplaceManyProxyOperation arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { super(client, functionName, arguments, argumentsMapper, resultMapper); @@ -48,8 +46,7 @@ public Builder self() { public ReplaceManyProxyOperation build() { return new ReplaceManyProxyOperation<>( - this.client, this.functionName, new ArrayList<>(arguments.values()), this.argumentsMapper, - this.resultMapper); + this.client, this.functionName, this.arguments.values(), this.argumentsMapper, this.resultMapper); } } } diff --git a/src/main/java/io/tarantool/driver/core/proxy/ReplaceProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/ReplaceProxyOperation.java index 56155c024..ccf09ffaa 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/ReplaceProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/ReplaceProxyOperation.java @@ -7,9 +7,7 @@ import io.tarantool.driver.mappers.MessagePackObjectMapper; import io.tarantool.driver.protocol.Packable; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; /** * Proxy operation for replace @@ -25,7 +23,7 @@ public final class ReplaceProxyOperation arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { super(client, functionName, arguments, argumentsMapper, resultMapper); @@ -49,8 +47,7 @@ public Builder self() { public ReplaceProxyOperation build() { return new ReplaceProxyOperation<>( - this.client, this.functionName, new ArrayList<>(arguments.values()), this.argumentsMapper, - this.resultMapper); + this.client, this.functionName, this.arguments.values(), this.argumentsMapper, this.resultMapper); } } } diff --git a/src/main/java/io/tarantool/driver/core/proxy/SelectProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/SelectProxyOperation.java index d6f42c880..3a39358b9 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/SelectProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/SelectProxyOperation.java @@ -11,8 +11,7 @@ import io.tarantool.driver.mappers.CallResultMapper; import io.tarantool.driver.mappers.MessagePackObjectMapper; -import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import java.util.Map; import java.util.Optional; @@ -28,7 +27,7 @@ public final class SelectProxyOperation extends AbstractProxyOperation { private SelectProxyOperation( TarantoolCallOperations client, String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { super(client, functionName, arguments, argumentsMapper, resultMapper); @@ -71,8 +70,7 @@ public SelectProxyOperation build() { .ifPresent(after -> options.put(ProxyOption.AFTER.toString(), after)); return new SelectProxyOperation<>( - this.client, this.functionName, new ArrayList<>(arguments.values()), this.argumentsMapper, - this.resultMapper); + this.client, this.functionName, this.arguments.values(), this.argumentsMapper, this.resultMapper); } } } diff --git a/src/main/java/io/tarantool/driver/core/proxy/TruncateProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/TruncateProxyOperation.java index 123736433..6dac3a6df 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/TruncateProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/TruncateProxyOperation.java @@ -4,8 +4,7 @@ import io.tarantool.driver.api.TarantoolVoidResult; import io.tarantool.driver.api.space.options.crud.OperationWithTimeoutOptions; -import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import java.util.concurrent.CompletableFuture; /** @@ -18,12 +17,12 @@ public final class TruncateProxyOperation implements ProxyOperation { private final TarantoolCallOperations client; private final String functionName; - private final List arguments; + private final Collection arguments; private TruncateProxyOperation( TarantoolCallOperations client, String functionName, - List arguments) { + Collection arguments) { this.client = client; this.arguments = arguments; this.functionName = functionName; @@ -46,7 +45,7 @@ public String getFunctionName() { return functionName; } - public List getArguments() { + public Collection getArguments() { return arguments; } @@ -74,7 +73,7 @@ public Builder self() { */ public TruncateProxyOperation build() { - return new TruncateProxyOperation(this.client, this.functionName, new ArrayList<>(arguments.values())); + return new TruncateProxyOperation(this.client, this.functionName, this.arguments.values()); } } } diff --git a/src/main/java/io/tarantool/driver/core/proxy/UpdateProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/UpdateProxyOperation.java index 63fd7ef30..869499cc8 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/UpdateProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/UpdateProxyOperation.java @@ -6,8 +6,7 @@ import io.tarantool.driver.mappers.CallResultMapper; import io.tarantool.driver.mappers.MessagePackObjectMapper; -import java.util.ArrayList; -import java.util.List; +import java.util.Collection; /** * Proxy operation for update @@ -21,7 +20,7 @@ public final class UpdateProxyOperation extends AbstractProxyOperation { UpdateProxyOperation( TarantoolCallOperations client, String functionName, - List arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { super(client, functionName, arguments, argumentsMapper, resultMapper); @@ -45,8 +44,7 @@ public Builder self() { public UpdateProxyOperation build() { return new UpdateProxyOperation<>( - this.client, this.functionName, new ArrayList<>(arguments.values()), this.argumentsMapper, - this.resultMapper); + this.client, this.functionName, this.arguments.values(), this.argumentsMapper, this.resultMapper); } } } diff --git a/src/main/java/io/tarantool/driver/core/proxy/UpsertProxyOperation.java b/src/main/java/io/tarantool/driver/core/proxy/UpsertProxyOperation.java index ab40936ce..fcc2046e0 100644 --- a/src/main/java/io/tarantool/driver/core/proxy/UpsertProxyOperation.java +++ b/src/main/java/io/tarantool/driver/core/proxy/UpsertProxyOperation.java @@ -7,9 +7,7 @@ import io.tarantool.driver.mappers.MessagePackObjectMapper; import io.tarantool.driver.protocol.Packable; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; /** * Proxy operation for upsert @@ -24,7 +22,7 @@ public final class UpsertProxyOperation arguments, + Collection arguments, MessagePackObjectMapper argumentsMapper, CallResultMapper> resultMapper) { super(client, functionName, arguments, argumentsMapper, resultMapper); @@ -48,8 +46,7 @@ public Builder self() { public UpsertProxyOperation build() { return new UpsertProxyOperation<>( - this.client, this.functionName, new ArrayList<>(arguments.values()), this.argumentsMapper, - this.resultMapper); + this.client, this.functionName, this.arguments.values(), this.argumentsMapper, this.resultMapper); } } } diff --git a/src/main/java/io/tarantool/driver/protocol/requests/TarantoolCallRequest.java b/src/main/java/io/tarantool/driver/protocol/requests/TarantoolCallRequest.java index 5dcae48cb..a566e73f4 100644 --- a/src/main/java/io/tarantool/driver/protocol/requests/TarantoolCallRequest.java +++ b/src/main/java/io/tarantool/driver/protocol/requests/TarantoolCallRequest.java @@ -7,8 +7,8 @@ import io.tarantool.driver.protocol.TarantoolRequestFieldType; import io.tarantool.driver.protocol.TarantoolRequestType; +import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -52,7 +52,7 @@ public Builder withFunctionName(String functionName) { * @param arguments function arguments * @return builder */ - public Builder withArguments(List arguments) { + public Builder withArguments(Collection arguments) { this.bodyMap.put(TarantoolRequestFieldType.IPROTO_TUPLE.getCode(), arguments); return this; } diff --git a/src/main/java/io/tarantool/driver/protocol/requests/TarantoolEvalRequest.java b/src/main/java/io/tarantool/driver/protocol/requests/TarantoolEvalRequest.java index 2883c4f93..d3e1ec95b 100644 --- a/src/main/java/io/tarantool/driver/protocol/requests/TarantoolEvalRequest.java +++ b/src/main/java/io/tarantool/driver/protocol/requests/TarantoolEvalRequest.java @@ -7,8 +7,8 @@ import io.tarantool.driver.protocol.TarantoolRequestFieldType; import io.tarantool.driver.protocol.TarantoolRequestType; +import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -52,7 +52,7 @@ public Builder withExpression(String expression) { * @param arguments eval arguments * @return builder */ - public Builder withArguments(List arguments) { + public Builder withArguments(Collection arguments) { this.bodyMap.put(TarantoolRequestFieldType.IPROTO_TUPLE.getCode(), arguments); return this; } diff --git a/src/test/java/io/tarantool/driver/core/proxy/ProxyOperationBuildersTest.java b/src/test/java/io/tarantool/driver/core/proxy/ProxyOperationBuildersTest.java index df4754a06..99f5ae789 100644 --- a/src/test/java/io/tarantool/driver/core/proxy/ProxyOperationBuildersTest.java +++ b/src/test/java/io/tarantool/driver/core/proxy/ProxyOperationBuildersTest.java @@ -32,12 +32,14 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertIterableEquals; public class ProxyOperationBuildersTest { @@ -76,7 +78,7 @@ public void deleteOperationBuilderTest() { assertEquals(client, deleteProxyOperation.getClient()); assertEquals("function1", deleteProxyOperation.getFunctionName()); - assertEquals(Arrays.asList("space1", Collections.singletonList(42L), options), + assertIterableEquals(Arrays.asList("space1", Collections.singletonList(42L), options), deleteProxyOperation.getArguments()); assertEquals(defaultResultMapper, deleteProxyOperation.getResultMapper()); } @@ -104,7 +106,7 @@ public void insertOperationBuilderTest() { assertEquals(client, insertOperation.getClient()); assertEquals("function1", insertOperation.getFunctionName()); - assertEquals(Arrays.asList("space1", tarantoolTuple, options), insertOperation.getArguments()); + assertIterableEquals(Arrays.asList("space1", tarantoolTuple, options), insertOperation.getArguments()); assertEquals(defaultResultMapper, insertOperation.getResultMapper()); } @@ -136,7 +138,7 @@ public void insertManyOperationBuilderTest() { assertEquals(client, operation.getClient()); assertEquals("function1", operation.getFunctionName()); - assertEquals(Arrays.asList("space1", tarantoolTuples, options), operation.getArguments()); + assertIterableEquals(Arrays.asList("space1", tarantoolTuples, options), operation.getArguments()); assertEquals(defaultResultMapper, operation.getResultMapper()); } @@ -163,7 +165,7 @@ public void replaceOperationBuilderTest() { assertEquals(client, operation.getClient()); assertEquals("function1", operation.getFunctionName()); - assertEquals(Arrays.asList("space1", tarantoolTuple, options), operation.getArguments()); + assertIterableEquals(Arrays.asList("space1", tarantoolTuple, options), operation.getArguments()); assertEquals(defaultResultMapper, operation.getResultMapper()); } @@ -196,7 +198,7 @@ public void replaceManyOperationBuilderTest() { assertEquals(client, operation.getClient()); assertEquals("function1", operation.getFunctionName()); - assertEquals(Arrays.asList("space1", tarantoolTuples, options), operation.getArguments()); + assertIterableEquals(Arrays.asList("space1", tarantoolTuples, options), operation.getArguments()); assertEquals(defaultResultMapper, operation.getResultMapper()); } @@ -236,9 +238,10 @@ public void selectOperationBuilderTest() { assertEquals(client, op.getClient()); assertEquals("function1", op.getFunctionName()); assertEquals(3, op.getArguments().size()); - assertEquals("space1", op.getArguments().get(0)); - assertEquals(selectArguments, op.getArguments().get(1)); - Map actualOptions = (Map) op.getArguments().get(2); + List argumentValues = new ArrayList<>(op.getArguments()); + assertEquals("space1", argumentValues.get(0)); + assertEquals(selectArguments, argumentValues.get(1)); + Map actualOptions = (Map) argumentValues.get(2); assertEquals(options.toString(), actualOptions.toString()); assertEquals(defaultResultMapper, op.getResultMapper()); } @@ -268,7 +271,7 @@ public void updateOperationBuilderTest() { assertEquals("function1", operation.getFunctionName()); assertEquals(4, operation.getArguments().size()); - assertEquals(Arrays.asList("space1", + assertIterableEquals(Arrays.asList("space1", Collections.singletonList(10), TupleOperations.add(3, 90).andAdd(4, 5).asProxyOperationList(), options), operation.getArguments()); @@ -303,7 +306,7 @@ public void upsertOperationBuilderTest() { assertEquals(client, operation.getClient()); assertEquals("function1", operation.getFunctionName()); - assertEquals(Arrays.asList("space1", tarantoolTuple, + assertIterableEquals(Arrays.asList("space1", tarantoolTuple, TupleOperations.add(3, 90).andAdd(4, 5).asProxyOperationList(), options), operation.getArguments()); assertEquals(defaultResultMapper, operation.getResultMapper()); @@ -329,6 +332,6 @@ public void test_truncateOperationBuilder_shouldReturnTruncateOperationObjectsWi // then data is prepared check that is equals that we submitted to the builder assertEquals(client, truncateOperation.getClient()); assertEquals("function1", truncateOperation.getFunctionName()); - assertEquals(Arrays.asList("space1", options), truncateOperation.getArguments()); + assertIterableEquals(Arrays.asList("space1", options), truncateOperation.getArguments()); } }