zhongyujiang commented on code in PR #7133:
URL: https://github.com/apache/iceberg/pull/7133#discussion_r1142031246
##########
api/src/main/java/org/apache/iceberg/util/CharSequenceSet.java:
##########
@@ -139,16 +139,26 @@ public boolean addAll(Collection<? extends CharSequence>
charSequences) {
@Override
public boolean retainAll(Collection<?> objects) {
if (objects != null) {
- return Iterables.removeAll(wrapperSet, objects);
+ Set<CharSequenceWrapper> toRetain =
+ objects.stream()
+ .filter(CharSequence.class::isInstance)
+ .map(CharSequence.class::cast)
+ .map(CharSequenceWrapper::wrap)
+ .collect(Collectors.toSet());
+
+ return Iterables.retainAll(wrapperSet, toRetain);
}
+
return false;
}
@Override
+ @SuppressWarnings("CollectionUndefinedEquality")
public boolean removeAll(Collection<?> objects) {
if (objects != null) {
- return Iterables.removeAll(wrapperSet, objects);
+ return objects.stream().filter(this::remove).count() != 0;
Review Comment:
`removeAll` iterates the `objects` and checks whether these elements exist
in the `removeFrom` set, in this case we don't need to wrap all elements at
once, use `this#remove` can take advantage of the wrapper in the `ThreadLocal`
`wrappers`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]