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

Eagerly deserialize responses consisting of list of data [API-1964] #618

Merged
merged 3 commits into from
Mar 23, 2023

Conversation

mdumandag
Copy link
Contributor

We were performing lazy deserialization on APIs that return a list of data, such as map#values(). This was not going to work with Compact, as after returning the list to the user, there might be Compact serialized data on the list which we don't have the schema on the client yet. If it was a normal response, the client would have fetched the schema, but it is not possible with these lazy APIs. We perform the deserialization while getting the list items and this is a sync API. We can't perform a blocking call there, because there is a chance that this will be executed in the reactor thread, which would result in a deadlock.

So, the only possible way of making these APIs work with Compact is to convert them to eager deserialization.

This PR removes lazy deserialization in everything apart from SQL, which will be handled in another PR.

We were performing lazy deserialization on APIs that return
a list of data, such  as map#values(). This was not going to work
with Compact, as after returning the list to the user, there might
be Compact serialized data on the list which we don't have the
schema on the client yet. If it was a normal response, the client
would have fetched the schema, but it is not possible with
these lazy APIs. We perform the deserialization while getting
the list items and this is a sync API. We can't perform a blocking
call there, because there is a chance that this will be executed
in the reactor thread, which would result in a deadlock.

So, the only possible way of making these APIs work with Compact
is to convert them to eager deserialization.

This PR removes lazy deserialization in everything apart from SQL,
which will be handled in another PR.
@mdumandag mdumandag added this to the 5.2.0 milestone Mar 20, 2023
@mdumandag mdumandag requested a review from yuce March 20, 2023 07:43
@mdumandag mdumandag self-assigned this Mar 20, 2023
Copy link
Contributor

@yuce yuce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a minor idea...

@@ -175,6 +135,21 @@ def get_portable_version(portable, default_version):
return version


def deserialize_list_in_place(data_list, to_object_fn):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be type annotation for the new functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I wish we fully type hint the code base so that we can add checks for such things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov-commenter
Copy link

Codecov Report

Merging #618 (c8ff71b) into master (b728a54) will increase coverage by 0.00%.
The diff coverage is 97.24%.

@@           Coverage Diff           @@
##           master     #618   +/-   ##
=======================================
  Coverage   96.48%   96.49%           
=======================================
  Files         357      357           
  Lines       20519    20554   +35     
=======================================
+ Hits        19798    19833   +35     
  Misses        721      721           
Impacted Files Coverage Δ
hazelcast/proxy/reliable_topic.py 94.60% <ø> (ø)
hazelcast/proxy/ringbuffer.py 97.94% <87.50%> (-1.32%) ⬇️
hazelcast/util.py 92.41% <91.66%> (+0.60%) ⬆️
hazelcast/proxy/list.py 99.57% <100.00%> (+<0.01%) ⬆️
hazelcast/proxy/map.py 98.10% <100.00%> (+0.27%) ⬆️
hazelcast/proxy/multi_map.py 99.23% <100.00%> (+0.01%) ⬆️
hazelcast/proxy/queue.py 99.50% <100.00%> (+<0.01%) ⬆️
hazelcast/proxy/replicated_map.py 98.42% <100.00%> (+0.02%) ⬆️
hazelcast/proxy/set.py 99.31% <100.00%> (+<0.01%) ⬆️
hazelcast/proxy/transactional_map.py 100.00% <100.00%> (ø)
... and 3 more

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mdumandag mdumandag merged commit cd9a317 into hazelcast:master Mar 23, 2023
@mdumandag mdumandag deleted the compact-lazy-apis branch March 23, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants