skorotkov commented on code in PR #12026:
URL: https://github.com/apache/ignite/pull/12026#discussion_r2159172423


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/evict/Random2LruPageEvictionTracker.java:
##########
@@ -177,4 +214,79 @@ public Random2LruPageEvictionTracker(
 
         GridUnsafe.putLongVolatile(null, trackingArrPtr + trackingIdx * 8L, 
0L);
     }
+
+    /** {@inheritDoc} */
+    @Override public void trackFragmentPage(long pageId, long prevPageId, 
boolean isHeadPage) {
+        // Do nothing if called for tail page.
+        if (prevPageId == 0)
+            return;
+
+        if (isHeadPage) {
+            // Store link to head fragment page in tail fragment page.
+            linkFragmentPages(tailPageIdx(prevPageId), 
PageIdUtils.pageIndex(pageId));
+        }
+        else {
+            // Store link to tail fragment page in each fragment page.
+            linkFragmentPages(PageIdUtils.pageIndex(pageId), 
tailPageIdx(prevPageId));
+        }
+    }
+
+    /**
+     * Link two pages containing fragments of row.
+     * Link is stored as a page index in the second integer in the tracking 
data.
+     * First integer in the tracking data is set to -1.
+     *
+     * @param pageIdx Page index.
+     * @param nextPageIdx Index of page to link to.
+     */
+    private void linkFragmentPages(int pageIdx, int nextPageIdx) {
+        int trackingIdx = trackingIdx(pageIdx);
+
+        GridUnsafe.putLongVolatile(null, trackingArrPtr + trackingIdx * 8L, 
toLong(-1, nextPageIdx));
+    }
+
+    /**
+     * Helper to encode a pair of integer values into a single long.
+     */
+    private long toLong(int first, int second) {
+        return U.toLong(first, second);

Review Comment:
   Done



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/evict/Random2LruPageEvictionTracker.java:
##########
@@ -164,9 +194,16 @@ public Random2LruPageEvictionTracker(
     @Override protected boolean checkTouch(long pageId) {
         int trackingIdx = trackingIdx(PageIdUtils.pageIndex(pageId));
 
-        int firstTs = GridUnsafe.getIntVolatile(null, trackingArrPtr + 
trackingIdx * 8L);
+        int firstTs = first(GridUnsafe.getLongVolatile(null, trackingArrPtr + 
trackingIdx * 8L));
 
-        return firstTs != 0;
+        return firstTs > 0;
+    }
+
+    /** */
+    private long trackingData(long pageId) {

Review Comment:
   Done



-- 
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: notifications-unsubscr...@ignite.apache.org

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

Reply via email to