-
Notifications
You must be signed in to change notification settings - Fork 8
Bump cartridge-java version #124
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
Conversation
| metadata = { | ||
| {name='testId', type=''}, | ||
| {name='testBoolean', type=''}, | ||
| {name='testString', type=''}, | ||
| {name='testInteger', type=''}, | ||
| {name='testDouble', type=''} | ||
| }, | ||
| rows = { { nil, true, "abc", 123, 1.23 } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We expect that crud response either contains metadata or it's not a crud response
...main/java/org/springframework/data/tarantool/core/convert/MappingTarantoolReadConverter.java
Outdated
Show resolved
Hide resolved
|
|
||
| private <T> CallResultMapper<T, SingleValueCallResult<T>> | ||
| withDefaultSingleValueMapper(MessagePackMapper customMapper, | ||
| Class<T> entityClass) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that entityClass is now missing. Aren't there any compiler warnings visible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't used properly in the cartridge-java part, we never get real entityClass. It was used as a stub for the target class which isn't used anywhere except tuple value mapping. This is what I was talking about implying that the mapping functionality is overloaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, its purpose is broader. It allows the Java compiler to have a certain assumption about the expression type at compile time. That's the limitation of Java, but it helps t avoid some runtime errors earlier, or you will get a clearer error message. Also it saves you from further spurious unchecked casts at different places that just make the readability worse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It's w/a to get all types by one Mapper
<T> CompletableFuture<T> callForSingleResult(
String functionName,
List<?> arguments,
CallResultMapper<T, SingleValueCallResult<T>> resultMapper)
throws TarantoolClientException;We have a generic T in all methods with callForSingleResult in the result mapper. It forces us to make a specific class that we should obtain, only this one. That obliges us to have a container for results like TarantoolResult. And I just used Object as a generic type for further values except for the first layer which is SingleValueCallResult
I agree that it's not good way. Maybe we can use MessagePackValueMapper as a mapper for generic calls, but with MessagePackValueMapper you should parse singleValue result every time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created PR about changing this clunky problem tarantool/cartridge-java#391
With this one you can use methods with CallResultMapper<T, SingleValueCallResult<T>> resultMapper in a method signature and so you'll get the result, not SingleValueResult class
CallResultMapper<Object, SingleValueCallResult<Object>> callReturnMapper = factory.createMapper(valueMapper)
.buildSingleValueResultMapper(
factory.createMapper(valueMapper)
.withArrayValueToTarantoolTupleResultConverter()
.withRowsMetadataToTarantoolTupleResultConverter()
.buildCallResultMapper()
);With this one you'll get a SingleValueResult as return of methods
MessagePackValueMapper returnMapper = factory.createMapper(valueMapper)
.withSingleValueConverter(
factory.createMapper(valueMapper)
.withArrayValueToTarantoolTupleResultConverter()
.withRowsMetadataToTarantoolTupleResultConverter()
.buildCallResultMapper()
).buildCallResultMapper();There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that we have raw Objects here. One of the targets of our driver API is to avoid any casts and raw Object usage whenever possible. And we shouldn't try to minimize the conversion code here in the SpringData module, if that worsens the user-facing API.
...main/java/org/springframework/data/tarantool/core/convert/MappingTarantoolReadConverter.java
Outdated
Show resolved
Hide resolved
|
|
||
| private <T> CallResultMapper<T, SingleValueCallResult<T>> | ||
| withDefaultSingleValueMapper(MessagePackMapper customMapper, | ||
| Class<T> entityClass) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, its purpose is broader. It allows the Java compiler to have a certain assumption about the expression type at compile time. That's the limitation of Java, but it helps t avoid some runtime errors earlier, or you will get a clearer error message. Also it saves you from further spurious unchecked casts at different places that just make the readability worse.
| .withRowsMetadataToTarantoolTupleResultConverter() | ||
| .buildCallResultMapper( | ||
| DefaultMessagePackMapperFactory.getInstance().emptyMapper())) | ||
| .buildCallResultMapper(DefaultMessagePackMapperFactory.getInstance().emptyMapper()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That empty mapper here looks a bit confusing. Seems that it should be either a default mapper, or no mapper parameter at all (the empty mapper as a default value in the method).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is confusing logic. I suggest fixing it after #124 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a ticket to the driver at least?
| MessagePackMapper customMapper = getDefaultComplexTypesMapper(); | ||
| registerTupleResultMapper(customMapper, spaceMetadata); | ||
| return withDefaultSingleValueMapper(customMapper, entityClass); | ||
| getAutoResultMapper(Optional<TarantoolSpaceMetadata> spaceMetadata) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like that we could combine this builder sequence with the same one above and make a factory method that accepts a single mapper (that's the only difference it seems).
...main/java/org/springframework/data/tarantool/core/convert/MappingTarantoolReadConverter.java
Outdated
Show resolved
Hide resolved
…MappingTarantoolReadConverter.java Co-authored-by: Alexey Kuzin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question about the used concrete type
src/main/java/org/springframework/data/tarantool/core/BaseTarantoolTemplate.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The blocker PR tarantool/cartridge-java#391 is merged now, let's make a new release and update this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I haven't forgotten about:
Related issues:
Closes #123