yurinaryshkin commented on code in PR #11319:
URL: https://github.com/apache/ignite/pull/11319#discussion_r1574328812


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java:
##########
@@ -2761,43 +2774,37 @@ private int purgeExpiredInternal(
 
                     long now = U.currentTimeMillis();
 
-                    GridCursor<PendingRow> cur;
-
-                    if (grp.sharedGroup())
-                        cur = pendingTree.find(new PendingRow(cctx.cacheId()), 
new PendingRow(cctx.cacheId(), now, 0));
-                    else
-                        cur = pendingTree.find(null, new 
PendingRow(CU.UNDEFINED_CACHE_ID, now, 0));
-
-                    if (!cur.next())
-                        return 0;
-
-                    GridCacheVersion obsoleteVer = null;
+                    int cacheId = grp.sharedGroup() ? cctx.cacheId() : 
CU.UNDEFINED_CACHE_ID;
 
                     int cleared = 0;
 
                     do {
-                        PendingRow row = cur.get();
+                        List<PendingRow> rows = pendingTree.remove(new 
PendingRow(cacheId, Long.MIN_VALUE, 0),
+                            new PendingRow(cacheId, now, 0), amount - cleared);
+
+                        if (rows.isEmpty())
+                            break;
 
-                        if (amount != -1 && cleared > amount)
-                            return cleared;
+                        for (PendingRow row : rows) {
+                            row.key.partition(partId);
 
-                        assert row.key != null && row.link != 0 && 
row.expireTime != 0 : row;
+                            assert row.key != null && row.link != 0 && 
row.expireTime != 0 : row;
 
-                        row.key.partition(partId);
+                            GridCacheVersion obsoleteVer = null;
 
-                        if (pendingTree.removex(row)) {
                             if (obsoleteVer == null)
                                 obsoleteVer = cctx.cache().nextVersion();
 
-                            GridCacheEntryEx e1 = 
cctx.cache().entryEx(row.key);
+                            GridCacheEntryEx entry = 
cctx.cache().entryEx(row.key instanceof KeyCacheObjectImpl
+                                ? new 
ExpiredKeyCacheObject((KeyCacheObjectImpl)row.key, row.expireTime, row.link) : 
row.key);
 
-                            if (e1 != null)
-                                c.apply(e1, obsoleteVer);
+                            if (entry != null)
+                                c.apply(entry, obsoleteVer);
                         }
 
-                        cleared++;
+                        cleared += rows.size();
                     }
-                    while (cur.next());
+                    while (amount < 0 || cleared < amount);

Review Comment:
   What is this condition for ?
   `amount < 0`



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