sashapolo commented on code in PR #3933:
URL: https://github.com/apache/ignite-3/pull/3933#discussion_r1642807074


##########
modules/storage-page-memory/src/test/java/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryMvTableStorageTest.java:
##########
@@ -57,6 +58,7 @@ public class PersistentPageMemoryMvTableStorageTest extends 
AbstractMvTableStora
 
     @BeforeEach
     void setUp(
+            TestInfo testInfo,

Review Comment:
   ?



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageIdAllocator.java:
##########
@@ -39,14 +48,85 @@ public interface PageIdAllocator {
     // TODO IGNITE-16350 Use constant from the table configuration.
     int MAX_PARTITION_ID = 65500;
 
+    /**
+     * Allocates a page from the space for the given partition ID and the 
given flags. Does not reuse pages.
+     *
+     * @param groupId Group ID.
+     * @param partitionId Partition ID.
+     * @return Allocated page ID.
+     */
+    long allocatePageNoReuse(int groupId, int partitionId, byte flags) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Allocates a page from the space for the given partition ID and the 
given flags. If reuse list is provided, tries to reuse page.
+     *
+     * @param reuseList Reuse list to reuse pages from.
+     * @param groupId Group ID.
+     * @param partitionId Partition ID.
+     * @return Allocated page ID.
+     */
+    default long allocatePage(@Nullable ReuseList reuseList, int groupId, int 
partitionId, byte flags)
+            throws IgniteInternalCheckedException {
+        return allocatePage(reuseList, null, true, groupId, partitionId, 
flags);
+    }
+
     /**
      * Allocates a page from the space for the given partition ID and the 
given flags.
      *
+     * @param reuseList Reuse list to reuse pages from.
+     * @param bag Reuse Bag.
+     * @param useRecycled Use recycled page.
      * @param groupId Group ID.
      * @param partitionId Partition ID.
      * @return Allocated page ID.
      */
-    long allocatePage(int groupId, int partitionId, byte flags) throws 
IgniteInternalCheckedException;
+    default long allocatePage(
+            @Nullable ReuseList reuseList,
+            @Nullable ReuseBag bag,
+            boolean useRecycled,
+            int groupId,
+            int partitionId,
+            byte flags
+    ) throws IgniteInternalCheckedException {
+        long pageId = 0;
+
+        if (useRecycled && reuseList != null) {
+            pageId = bag != null ? bag.pollFreePage() : 0;
+
+            if (pageId == 0) {
+                pageId = reuseList.takeRecycledPage();
+            }
+
+            // Recycled. "pollFreePage" result should be reinitialized to move 
rotatedId to itemId.
+            if (pageId != 0) {
+                // Replace the partition ID, because the reused page might 
have come from a different data structure if the reuse
+                // list is shared between them.
+                pageId = replacePartitionId(pageId, partitionId);
+
+                pageId = reuseList.initRecycledPage(pageId, flags, null);
+            }
+        }
+
+        if (pageId == 0) {
+            pageId = allocatePageNoReuse(groupId, partitionId, flags);
+        }
+
+        assert pageId != 0;
+
+        assert partitionId(pageId) >= 0 && partitionId(pageId) <= 
MAX_PARTITION_ID : toDetailString(pageId);
+
+        assert flag(pageId) != FLAG_DATA || itemId(pageId) == 0 : 
toDetailString(pageId);
+
+        return pageId;
+    }
+
+    private static long replacePartitionId(long pageId, int partId) {

Review Comment:
   Why did you remove the javadoc?



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