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


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointDirtyPages.java:
##########
@@ -17,89 +17,92 @@
 
 package org.apache.ignite.internal.pagememory.persistence.checkpoint;
 
-import static java.util.Collections.binarySearch;
+import static java.util.Arrays.binarySearch;
 import static java.util.stream.Collectors.toList;
 import static org.apache.ignite.internal.pagememory.util.PageIdUtils.pageId;
 import static 
org.apache.ignite.internal.pagememory.util.PageIdUtils.partitionId;
 
-import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 import java.util.RandomAccess;
-import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.internal.pagememory.FullPageId;
+import org.apache.ignite.internal.pagememory.persistence.GroupPartitionId;
 import org.apache.ignite.internal.pagememory.persistence.PersistentPageMemory;
+import org.apache.ignite.internal.util.IgniteConcurrentMultiPairQueue;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.jetbrains.annotations.Nullable;
 
 /**
- * Sorted dirty pages from data regions that should be checkpointed.
- *
- * <p>Dirty pages should be sorted by groupId -> partitionId -> pageIdx.
+ * Dirty pages of data regions, with sorted page IDs by {@link 
#DIRTY_PAGE_COMPARATOR} and unsorted partition IDs that should be
+ * checkpointed.
  */
 class CheckpointDirtyPages {
-    /** Dirty page ID comparator. */
+    /** Dirty page ID comparator by groupId -> partitionId -> pageIdx. */
     static final Comparator<FullPageId> DIRTY_PAGE_COMPARATOR = Comparator
             .comparingInt(FullPageId::groupId)
             .thenComparingLong(FullPageId::effectivePageId);
 
     /** Empty checkpoint dirty pages. */
     static final CheckpointDirtyPages EMPTY = new 
CheckpointDirtyPages(List.of());
 
-    /** Sorted dirty pages from data regions by groupId -> partitionId -> 
pageIdx. */
-    private final List<IgniteBiTuple<PersistentPageMemory, List<FullPageId>>> 
dirtyPages;
-
-    /** Total number of dirty pages. */
-    private final int dirtyPagesCount;
+    /** Dirty pages of data regions, with sorted page IDs by {@link 
#DIRTY_PAGE_COMPARATOR} and unsorted partition IDs. */
+    private final List<DataRegionDirtyPages<ArrayDirtyPages>> dirtyPages;
 
     /**
      * Constructor.
      *
-     * @param dirtyPages Sorted dirty pages from data regions by groupId -> 
partitionId -> pageIdx.
+     * @param dirtyPages Dirty pages of data regions, with sorted page IDs by 
{@link #DIRTY_PAGE_COMPARATOR} and unsorted partition IDs.
      */
-    public CheckpointDirtyPages(Map<PersistentPageMemory, List<FullPageId>> 
dirtyPages) {
-        this(dirtyPages.entrySet().stream().map(e -> new 
IgniteBiTuple<>(e.getKey(), e.getValue())).collect(toList()));
+    public CheckpointDirtyPages(Map<PersistentPageMemory, ArrayDirtyPages> 
dirtyPages) {
+        this(dirtyPages.entrySet().stream()
+                .map(e -> new DataRegionDirtyPages<>(e.getKey(), e.getValue()))
+                .collect(toList())
+        );
     }
 
     /**
      * Constructor.
      *
-     * @param dirtyPages Sorted dirty pages from data regions by groupId -> 
partitionId -> pageIdx.
+     * @param dirtyPages Dirty pages of data regions, with sorted page IDs by 
{@link #DIRTY_PAGE_COMPARATOR} and unsorted partition IDs.
      */
-    public CheckpointDirtyPages(List<IgniteBiTuple<PersistentPageMemory, 
List<FullPageId>>> dirtyPages) {
+    public CheckpointDirtyPages(List<DataRegionDirtyPages<ArrayDirtyPages>> 
dirtyPages) {
         assert dirtyPages instanceof RandomAccess : dirtyPages;
 
         this.dirtyPages = dirtyPages;
-
-        int count = 0;
-
-        for (IgniteBiTuple<PersistentPageMemory, List<FullPageId>> pages : 
dirtyPages) {
-            assert !pages.getValue().isEmpty() : pages.getKey();
-            assert pages.getValue() instanceof RandomAccess : pages.getValue();
-
-            count += pages.getValue().size();
-        }
-
-        dirtyPagesCount = count;
     }
 
     /**
-     * Returns total number of dirty pages.
+     * Returns total number of dirty page IDs.
      */
     public int dirtyPagesCount() {
-        return dirtyPagesCount;
+        return dirtyPages.stream().mapToInt(pages -> 
pages.dirtyPages.pageIds.length).sum();
     }
 
     /**
-     * Returns a queue of dirty pages to be written to a checkpoint.
+     * Returns a queue of dirty page IDs to be written to a checkpoint.
      */
-    public CheckpointDirtyPagesQueue toQueue() {
-        return new CheckpointDirtyPagesQueue();
+    public IgniteConcurrentMultiPairQueue<PersistentPageMemory, FullPageId> 
toDirtyPageIdQueue() {
+        List<IgniteBiTuple<PersistentPageMemory, FullPageId[]>> dirtyPageIds = 
dirtyPages.stream()
+                .map(pages -> new IgniteBiTuple<>(pages.pageMemory, 
pages.dirtyPages.pageIds))
+                .collect(toList());
+
+        return new IgniteConcurrentMultiPairQueue<>(dirtyPageIds);

Review Comment:
   Okay, let's talk in person.



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