Skip to content

Commit

Permalink
Use Collection instead of List as arguments type in TarantoolClient
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akudiyar committed Oct 5, 2023
1 parent c478588 commit 6ac393c
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 152 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
37 changes: 19 additions & 18 deletions src/main/java/io/tarantool/driver/api/TarantoolCallOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +52,7 @@ public interface TarantoolCallOperations {
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
CompletableFuture<List<?>> call(String functionName, List<?> arguments) throws TarantoolClientException;
CompletableFuture<List<?>> call(String functionName, Collection<?> arguments) throws TarantoolClientException;

/**
* Execute a function defined on Tarantool instance
Expand All @@ -62,7 +63,7 @@ public interface TarantoolCallOperations {
* @return some result
* @throws TarantoolClientException if the client is not connected
*/
CompletableFuture<List<?>> call(String functionName, List<?> arguments, MessagePackMapper mapper)
CompletableFuture<List<?>> call(String functionName, Collection<?> arguments, MessagePackMapper mapper)
throws TarantoolClientException;

/**
Expand Down Expand Up @@ -108,7 +109,7 @@ <T> CompletableFuture<T> call(
*/
<T> CompletableFuture<TarantoolResult<T>> callForTupleResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
Class<T> entityClass)
throws TarantoolClientException;

Expand All @@ -125,7 +126,7 @@ <T> CompletableFuture<TarantoolResult<T>> callForTupleResult(
*/
<T> CompletableFuture<T> call(
String functionName,
List<?> arguments,
Collection<?> arguments,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
throws TarantoolClientException;

Expand All @@ -144,7 +145,7 @@ <T> CompletableFuture<T> call(
*/
<T> CompletableFuture<TarantoolResult<T>> callForTupleResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Class<T> entityClass)
throws TarantoolClientException;
Expand All @@ -162,7 +163,7 @@ <T> CompletableFuture<TarantoolResult<T>> callForTupleResult(
*/
<T> CompletableFuture<T> call(
String functionName,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
throws TarantoolClientException;
Expand All @@ -181,7 +182,7 @@ <T> CompletableFuture<T> call(
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Class<T> resultClass)
throws TarantoolClientException;
Expand All @@ -200,7 +201,7 @@ <T> CompletableFuture<T> callForSingleResult(
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
ValueConverter<Value, T> valueConverter)
throws TarantoolClientException;
Expand All @@ -219,7 +220,7 @@ <T> CompletableFuture<T> callForSingleResult(
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
throws TarantoolClientException;
Expand All @@ -237,7 +238,7 @@ <T> CompletableFuture<T> callForSingleResult(
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
Class<T> resultClass)
throws TarantoolClientException;

Expand All @@ -254,7 +255,7 @@ <T> CompletableFuture<T> callForSingleResult(
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
ValueConverter<Value, T> valueConverter)
throws TarantoolClientException;

Expand All @@ -271,7 +272,7 @@ <T> CompletableFuture<T> callForSingleResult(
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
throws TarantoolClientException;

Expand Down Expand Up @@ -335,7 +336,7 @@ <T> CompletableFuture<T> callForSingleResult(
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Supplier<R> resultContainerSupplier,
Class<T> resultClass)
Expand All @@ -356,7 +357,7 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Supplier<R> resultContainerSupplier,
ValueConverter<Value, T> valueConverter)
Expand All @@ -376,7 +377,7 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
CallResultMapper<R, MultiValueCallResult<T, R>> resultMapper)
throws TarantoolClientException;
Expand All @@ -395,7 +396,7 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
Supplier<R> resultContainerSupplier,
Class<T> resultClass)
throws TarantoolClientException;
Expand All @@ -414,7 +415,7 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
Supplier<R> resultContainerSupplier,
ValueConverter<Value, T> valueConverter)
throws TarantoolClientException;
Expand All @@ -432,7 +433,7 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
List<?> arguments,
Collection<?> arguments,
CallResultMapper<R, MultiValueCallResult<T, R>> resultMapper)
throws TarantoolClientException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -35,7 +36,7 @@ public interface TarantoolEvalOperations {
* @return some result
* @throws TarantoolClientException if the client is not connected
*/
CompletableFuture<List<?>> eval(String expression, List<?> arguments) throws TarantoolClientException;
CompletableFuture<List<?>> 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
Expand All @@ -60,7 +61,7 @@ CompletableFuture<List<?>> eval(String expression, MessagePackValueMapper result
* @return some result
* @throws TarantoolClientException if the client is not connected
*/
CompletableFuture<List<?>> eval(String expression, List<?> arguments, MessagePackValueMapper resultMapper)
CompletableFuture<List<?>> eval(String expression, Collection<?> arguments, MessagePackValueMapper resultMapper)
throws TarantoolClientException;

/**
Expand All @@ -76,7 +77,7 @@ CompletableFuture<List<?>> eval(String expression, List<?> arguments, MessagePac
*/
CompletableFuture<List<?>> eval(
String expression,
List<?> arguments,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
MessagePackValueMapper resultMapper) throws TarantoolClientException;
}
Loading

0 comments on commit 6ac393c

Please sign in to comment.