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


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PersistentPageMemory.java:
##########
@@ -2056,39 +2076,39 @@ public FullPageId pullPageFromCpBuffer() {
     }
 
     /**
-     * Gets a collection of dirty page IDs since the last checkpoint. If a 
dirty page is being written after the checkpointing operation
-     * begun, the modifications will be written to a temporary buffer which 
will be flushed to the main memory after the checkpointing
-     * finished. This method must be called when no concurrent operations on 
pages are performed.
+     * Returns the container of dirty page IDs and partition IDs since the 
last checkpoint. If a dirty page is being written after the
+     * checkpointing operation begun, the modifications will be written to a 
temporary buffer which will be flushed to the main memory after
+     * the checkpointing finished. This method must be called when no 
concurrent operations on pages are performed.
      *
      * @param allowToReplace The sign which allows replacing pages from a 
checkpoint by page replacer.
-     * @return Collection view of dirty page IDs.
      * @throws IgniteInternalException If checkpoint has been already started 
and was not finished.
      */
-    public Collection<FullPageId> beginCheckpoint(CompletableFuture<?> 
allowToReplace) throws IgniteInternalException {
+    public CollectionDirtyPages beginCheckpoint(CompletableFuture<?> 
allowToReplace) throws IgniteInternalException {
         if (segments == null) {
-            return List.of();
+            return new CollectionDirtyPages(List.of(), List.of());
         }
 
-        Collection<FullPageId>[] collections = new Collection[segments.length];
+        Set<FullPageId>[] dirtyPageIds = new Set[segments.length];
+
+        Set<GroupPartitionId> dirtyPartitionIds = new HashSet<>();
 
         for (int i = 0; i < segments.length; i++) {
-            Segment seg = segments[i];
+            Segment segment = segments[i];
 
-            if (seg.checkpointPages != null) {
-                throw new IgniteInternalException("Failed to begin checkpoint 
(it is already in progress).");
-            }
+            assert segment.checkpointPages == null : "Failed to begin 
checkpoint (it is already in progress)";
+
+            Set<FullPageId> segmentDirtyPages = (dirtyPageIds[i] = 
segment.dirtyPages);
 
-            Set<FullPageId> dirtyPages = seg.dirtyPages;
-            collections[i] = dirtyPages;
+            dirtyPartitionIds.addAll(segment.dirtyPartitions);

Review Comment:
   I don't know how to do it faster yet, we will have to choose between memory 
usage and contention anyway, while I chose to use more memory. I think that the 
merging of these collections should not be long in time.



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