You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/07/06 06:47:44 UTC

[GitHub] [iceberg] jun-he commented on a change in pull request #1165: Make CharSequenceSet thread safe

jun-he commented on a change in pull request #1165:
URL: https://github.com/apache/iceberg/pull/1165#discussion_r450014758



##########
File path: api/src/main/java/org/apache/iceberg/util/CharSequenceSet.java
##########
@@ -54,10 +54,21 @@ public boolean isEmpty() {
     return wrapperSet.isEmpty();
   }
 
+  public CharSequenceWrapper wrapper() {
+    if (containsWrapper == null) {
+      synchronized (this) {
+        if (containsWrapper == null) {
+          this.containsWrapper = ThreadLocal.withInitial(() -> CharSequenceWrapper.wrap(null));
+        }
+      }
+    }
+    return containsWrapper.get();
+  }
+
   @Override
   public boolean contains(Object obj) {
     if (obj instanceof CharSequence) {
-      return wrapperSet.contains(containsWrapper.set((CharSequence) obj));
+      return wrapperSet.contains(wrapper().set((CharSequence) obj));

Review comment:
       should it be set back to `null` after the operation?

##########
File path: api/src/main/java/org/apache/iceberg/util/CharSequenceSet.java
##########
@@ -54,10 +54,21 @@ public boolean isEmpty() {
     return wrapperSet.isEmpty();
   }
 
+  public CharSequenceWrapper wrapper() {
+    if (containsWrapper == null) {
+      synchronized (this) {
+        if (containsWrapper == null) {
+          this.containsWrapper = ThreadLocal.withInitial(() -> CharSequenceWrapper.wrap(null));

Review comment:
       Wondering if making sense to have a static ThreadLocal object shared by all `CharSequenceSet`?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org