tkalkirill commented on code in PR #791:
URL: https://github.com/apache/ignite-3/pull/791#discussion_r861491914


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PageMemoryImpl.java:
##########
@@ -1598,4 +1727,327 @@ public interface PageChangeTracker {
          */
         void apply(long page, FullPageId fullPageId, PageMemoryEx 
pageMemoryEx);
     }
+
+    /**
+     * Heuristic method which allows a thread to check if it is safe to start 
memory structure modifications in regard with checkpointing.
+     * May return false-negative result during or after partition eviction.
+     *
+     * @return {@code False} if there are too many dirty pages and a thread 
should wait for a checkpoint to begin.
+     */
+    public boolean safeToUpdate() {
+        if (segments != null) {
+            return safeToUpdate.get();
+        }
+
+        return true;
+    }
+
+    /**
+     * Returns number of pages used in checkpoint buffer.
+     */
+    public int usedCheckpointBufferPages() {
+        PagePool checkpointPool = this.checkpointPool;
+
+        return checkpointPool == null ? 0 : checkpointPool.size();
+    }
+
+    /**
+     * Returns max number of pages in checkpoint buffer.
+     */
+    public int maxCheckpointBufferPages() {
+        PagePool checkpointPool = this.checkpointPool;
+
+        return checkpointPool == null ? 0 : checkpointPool.pages();
+    }
+
+    private void releaseCheckpointBufferPage(long tmpBufPtr) {
+        checkpointPool.releaseFreePage(tmpBufPtr);
+    }
+
+    /**
+     * Returns {@code true} if it was added to the checkpoint list.
+     *
+     * @param pageId Page ID to check if it was added to the checkpoint list.
+     */
+    boolean isInCheckpoint(FullPageId pageId) {
+        Segment seg = segment(pageId.groupId(), pageId.pageId());
+
+        CheckpointPages pages0 = seg.checkpointPages;
+
+        return pages0 != null && pages0.contains(pageId);
+    }
+
+    /**
+     * Returns {@code true} if remove successfully.
+     *
+     * @param fullPageId Page ID to clear.
+     */
+    boolean clearCheckpoint(FullPageId fullPageId) {
+        Segment seg = segment(fullPageId.groupId(), fullPageId.pageId());
+
+        CheckpointPages pages0 = seg.checkpointPages;
+
+        assert pages0 != null;
+
+        return pages0.markAsSaved(fullPageId);
+    }
+
+    private void copyPageForCheckpoint(

Review Comment:
   Tried adding a comment.



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

Reply via email to