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 3, 2023
1 parent 68c34a6 commit 2e2b048
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 152 deletions.
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 2e2b048

Please sign in to comment.