JingsongLi commented on code in PR #714:
URL: https://github.com/apache/incubator-paimon/pull/714#discussion_r1151306796


##########
paimon-common/src/main/java/org/apache/paimon/io/cache/CachedRandomInputView.java:
##########
@@ -50,12 +52,24 @@ public class CachedRandomInputView extends 
AbstractPagedInputView
 
     private int currentSegmentIndex;
 
+    /**
+     * The thread pool is involved to solve computeIfAbsent issue. From JDK 9, 
computeIfAbsent will
+     * throw ConcurrentModificationException if it is detected that the 
mapping function modifies
+     * this map during computation. So we add the thread pool to remove 
segments expired page. To
+     * guarantee the concurrency safety, we need to replace the HashMap with 
ConcurrentHashMap.
+     *
+     * <p>Note: if the cache expires many pages in a while, the single thread 
executor can't process
+     * it. That means, some remove actions are blocked, this will cause dirty 
data read. But this
+     * occurs with low probability.
+     */
+    ExecutorService executor = Executors.newSingleThreadExecutor();

Review Comment:
   We don't need to introduce this complex codes.
   How about just modify `getCurrentPage`.
   ```
       private MemorySegment getCurrentPage() {
           MemorySegment segment = segments.get(currentSegmentIndex);
           if (segment == null) {
               segment = cacheManager.getPage(file, currentSegmentIndex, 
this::invalidPage);
               segments.put(currentSegmentIndex, segment);
           }
           return segment;
       }
   ```



-- 
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: issues-unsubscr...@paimon.apache.org

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

Reply via email to