Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new benchmarks and mapper cache #412

Merged
merged 16 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ tmp/
*.swo
.bloop/
.metals/
.vscode/
17 changes: 12 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.35</version>
<scope>test</scope>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.35</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -413,12 +413,19 @@
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>org.openjdk.jmh.Main</argument>]
<argument>org.openjdk.jmh.Main</argument>
<argument>${benchmark}</argument>
<argument>${benchmarkArgs}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<skipTests>true</skipTests>
<benchmark>SingleInstanceBenchmarkRunner</benchmark>
<benchmarkArgs></benchmarkArgs>
</properties>
</profile>
<profile>
<id>release</id>
Expand Down
81 changes: 34 additions & 47 deletions src/main/java/io/tarantool/driver/api/TarantoolCallOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.tarantool.driver.exceptions.TarantoolClientException;
import io.tarantool.driver.mappers.CallResultMapper;
import io.tarantool.driver.mappers.MessagePackMapper;
import io.tarantool.driver.mappers.MessagePackObjectMapper;
import io.tarantool.driver.mappers.converters.ValueConverter;
import io.tarantool.driver.mappers.factories.ResultMapperFactoryFactory;
Expand Down Expand Up @@ -54,18 +53,6 @@ public interface TarantoolCallOperations {
*/
CompletableFuture<List<?>> call(String functionName, Collection<?> arguments) throws TarantoolClientException;

/**
* Execute a function defined on Tarantool instance
*
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param mapper mapper for arguments object-to-MessagePack entity conversion and result values conversion
* @return some result
* @throws TarantoolClientException if the client is not connected
*/
CompletableFuture<List<?>> call(String functionName, Collection<?> arguments, MessagePackMapper mapper)
throws TarantoolClientException;

/**
* Execute a function defined on Tarantool instance. The call result is interpreted as an array of tuples. The value
* mapper specified in the client configuration will be used for converting the result values from MessagePack
Expand All @@ -85,13 +72,13 @@ <T> CompletableFuture<TarantoolResult<T>> callForTupleResult(String functionName
*
* @param <T> desired function call result type
* @param functionName function name, must not be null or empty
* @param resultMapper mapper for result value MessagePack entity-to-object conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<T> call(
String functionName,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
Supplier<CallResultMapper<T, SingleValueCallResult<T>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand Down Expand Up @@ -120,14 +107,14 @@ <T> CompletableFuture<TarantoolResult<T>> callForTupleResult(
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments. The object mapper specified in the client configuration
* will be used for arguments conversion to MessagePack entities
* @param resultMapper mapper for result value MessagePack entity-to-object conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<T> call(
String functionName,
Collection<?> arguments,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
Supplier<CallResultMapper<T, SingleValueCallResult<T>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand All @@ -138,15 +125,15 @@ <T> CompletableFuture<T> call(
* @param <T> desired function call result type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param entityClass target result entity class
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<TarantoolResult<T>> callForTupleResult(
String functionName,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
Class<T> entityClass)
throws TarantoolClientException;

Expand All @@ -156,16 +143,16 @@ <T> CompletableFuture<TarantoolResult<T>> callForTupleResult(
* @param <T> desired function call result type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param resultMapper mapper for result value MessagePack entity-to-object conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<T> call(
String functionName,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
Supplier<CallResultMapper<T, SingleValueCallResult<T>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand All @@ -175,15 +162,15 @@ <T> CompletableFuture<T> call(
* @param <T> target result content type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param resultClass target result entity class
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
Class<T> resultClass)
throws TarantoolClientException;

Expand All @@ -194,15 +181,15 @@ <T> CompletableFuture<T> callForSingleResult(
* @param <T> target result content type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param valueConverter MessagePack value to entity converter for each result item
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
ValueConverter<Value, T> valueConverter)
throws TarantoolClientException;

Expand All @@ -213,16 +200,16 @@ <T> CompletableFuture<T> callForSingleResult(
* @param <T> target result content type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param resultMapper mapper for result conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
Supplier<CallResultMapper<T, SingleValueCallResult<T>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand Down Expand Up @@ -266,14 +253,14 @@ <T> CompletableFuture<T> callForSingleResult(
* @param <T> target result content type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param resultMapper mapper for result conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
Collection<?> arguments,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
Supplier<CallResultMapper<T, SingleValueCallResult<T>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand Down Expand Up @@ -312,13 +299,13 @@ <T> CompletableFuture<T> callForSingleResult(
*
* @param <T> target result content type
* @param functionName function name, must not be null or empty
* @param resultMapper mapper for result conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T> CompletableFuture<T> callForSingleResult(
String functionName,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
Supplier<CallResultMapper<T, SingleValueCallResult<T>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand All @@ -328,7 +315,7 @@ <T> CompletableFuture<T> callForSingleResult(
* @param <R> target result type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param resultContainerSupplier supplier function for new empty result collection
* @param resultClass target result entity class
* @return some result
Expand All @@ -337,7 +324,7 @@ <T> CompletableFuture<T> callForSingleResult(
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
Supplier<R> resultContainerSupplier,
Class<T> resultClass)
throws TarantoolClientException;
Expand All @@ -349,7 +336,7 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
* @param <R> target result type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param resultContainerSupplier supplier function for new empty result collection
* @param valueConverter MessagePack value to entity converter for each result item
* @return some result
Expand All @@ -358,7 +345,7 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
Supplier<R> resultContainerSupplier,
ValueConverter<Value, T> valueConverter)
throws TarantoolClientException;
Expand All @@ -370,16 +357,16 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
* @param <R> target result type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param resultMapper mapper for result conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
CallResultMapper<R, MultiValueCallResult<T, R>> resultMapper)
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
Supplier<CallResultMapper<R, MultiValueCallResult<T, R>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand Down Expand Up @@ -427,14 +414,14 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
* @param <R> target result type
* @param functionName function name, must not be null or empty
* @param arguments list of function arguments
* @param resultMapper mapper for result conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
Collection<?> arguments,
CallResultMapper<R, MultiValueCallResult<T, R>> resultMapper)
Supplier<CallResultMapper<R, MultiValueCallResult<T, R>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand Down Expand Up @@ -477,13 +464,13 @@ <T, R extends List<T>> CompletableFuture<R> callForMultiResult(
* @param <T> target result content type
* @param <R> target result type
* @param functionName function name, must not be null or empty
* @param resultMapper mapper for result conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected or some other error occurred
*/
<T, R extends List<T>> CompletableFuture<R> callForMultiResult(
String functionName,
CallResultMapper<R, MultiValueCallResult<T, R>> resultMapper)
Supplier<CallResultMapper<R, MultiValueCallResult<T, R>>> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/io/tarantool/driver/api/TarantoolEvalOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;

/**
* Aggregates all value operation variants
Expand Down Expand Up @@ -43,11 +44,11 @@ public interface TarantoolEvalOperations {
* keyword <code>return</code>.
*
* @param expression lua expression, must not be null or empty
* @param resultMapper mapper for result value MessagePack entity-to-object conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected
*/
CompletableFuture<List<?>> eval(String expression, MessagePackValueMapper resultMapper)
CompletableFuture<List<?>> eval(String expression, Supplier<? extends MessagePackValueMapper> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand All @@ -57,11 +58,12 @@ CompletableFuture<List<?>> eval(String expression, MessagePackValueMapper result
* @param expression lua expression, must not be null or empty
* @param arguments the list of function arguments. The object mapper specified in the client configuration
* will be used for arguments conversion to MessagePack entities
* @param resultMapper mapper for result value MessagePack entity-to-object conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected
*/
CompletableFuture<List<?>> eval(String expression, Collection<?> arguments, MessagePackValueMapper resultMapper)
CompletableFuture<List<?>> eval(
String expression, Collection<?> arguments, Supplier<? extends MessagePackValueMapper> resultMapperSupplier)
throws TarantoolClientException;

/**
Expand All @@ -70,14 +72,14 @@ CompletableFuture<List<?>> eval(String expression, Collection<?> arguments, Mess
*
* @param expression lua expression, must not be null or empty
* @param arguments the list of function arguments
* @param argumentsMapper mapper for arguments object-to-MessagePack entity conversion
* @param resultMapper mapper for result value MessagePack entity-to-object conversion
* @param argumentsMapperSupplier mapper supplier for arguments object-to-MessagePack entity conversion
* @param resultMapperSupplier mapper supplier for result value MessagePack entity-to-object conversion
* @return some result
* @throws TarantoolClientException if the client is not connected
*/
CompletableFuture<List<?>> eval(
String expression,
Collection<?> arguments,
MessagePackObjectMapper argumentsMapper,
MessagePackValueMapper resultMapper) throws TarantoolClientException;
Supplier<? extends MessagePackObjectMapper> argumentsMapperSupplier,
Supplier<? extends MessagePackValueMapper> resultMapperSupplier) throws TarantoolClientException;
}
Loading
Loading