-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
remove_all public API and implementation are added remove_all code sample is added related unittests are added to map_test
Codecov Report
@@ Coverage Diff @@
## master #566 +/- ##
=======================================
Coverage 96.42% 96.43%
=======================================
Files 354 355 +1
Lines 20182 20203 +21
=======================================
+ Hits 19461 19482 +21
Misses 721 721
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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 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) |
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.
How about using f-strings: predicate_map.put(f"key{i}", i)
|
||
try: | ||
predicate_data = self._to_data(predicate) | ||
|
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.
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]: |
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.
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
Returns: | ||
None |
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 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() |
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.
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): |
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.
Can you also create a PR in the protocol repo with the changes you did to generate this codec?
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.
Sure, I created👍
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.
Thanks @feysahin for your work. We will add the required near cache changes in another PR.
map.remove_all method is introduced and implemented with following details:
Closes #520