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

map.remove_all implementation #566

Merged
merged 3 commits into from
Aug 19, 2022

Conversation

feysahin
Copy link
Contributor

@feysahin feysahin commented Aug 17, 2022

map.remove_all method is introduced and implemented with following details:

  • remove_all public API and implementation are added
  • remove_all code sample is added
  • related unittests are added to map_test

Closes #520

remove_all public API and implementation are added
remove_all code sample is added
related unittests are added to map_test
@codecov-commenter
Copy link

Codecov Report

Merging #566 (f89cadf) into master (18326a7) will increase coverage by 0.00%.
The diff coverage is 90.47%.

@@           Coverage Diff           @@
##           master     #566   +/-   ##
=======================================
  Coverage   96.42%   96.43%           
=======================================
  Files         354      355    +1     
  Lines       20182    20203   +21     
=======================================
+ Hits        19461    19482   +21     
  Misses        721      721           
Impacted Files Coverage Δ
hazelcast/proxy/map.py 97.57% <80.00%> (-0.22%) ⬇️
hazelcast/protocol/codec/map_remove_all_codec.py 100.00% <100.00%> (ø)
hazelcast/listener.py 90.76% <0.00%> (-1.09%) ⬇️
hazelcast/connection.py 92.35% <0.00%> (+0.16%) ⬆️
hazelcast/invocation.py 93.84% <0.00%> (+1.08%) ⬆️

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

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 two minor ideas...

predicate_map = client.get_map("predicate-map").blocking()

for i in range(10):
predicate_map.put("key" + str(i), i)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using f-strings: predicate_map.put(f"key{i}", i)


try:
predicate_data = self._to_data(predicate)

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you remove the unnecessary blank lines in this method?

@@ -1283,6 +1284,28 @@ def remove(self, key: KeyType) -> Future[typing.Optional[ValueType]]:

return self._remove_internal(key_data)

def remove_all(self, predicate: Predicate) -> Future[None]:
Copy link
Contributor

Choose a reason for hiding this comment

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

From the Javadocs:

     * Note that calling this method also removes all entries from
     * caller's Near Cache.

So, I believe we should have some code changes in the near cached map as well

Comment on lines +1293 to +1294
Returns:
None
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can remove this part, as it is visible from the method signature

@@ -2215,6 +2238,9 @@ def remove( # type: ignore[override]
) -> typing.Optional[ValueType]:
return self._wrapped.remove(key).result()

def remove_all(self, predicate: Predicate) -> None: # type: ignore[override]
return self._wrapped.remove_all(predicate).result()
Copy link
Contributor

Choose a reason for hiding this comment

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

Java does this instead, to clear the near cache

    @Override
    protected void removeAllInternal(Predicate predicate) {
        try {
            super.removeAllInternal(predicate);
        } finally {
            nearCache.clear();
        }
    }

_REQUEST_INITIAL_FRAME_SIZE = REQUEST_HEADER_SIZE


def encode_request(name, predicate):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also create a PR in the protocol repo with the changes you did to generate this codec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I created👍

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.

Thanks @feysahin for your work. We will add the required near cache changes in another PR.

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.

removeAll implementation [API-1499]
4 participants