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


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/AbstractPageMemoryMvPartitionStorage.java:
##########
@@ -922,4 +960,58 @@ protected <T> T inUpdateVersionChainLock(RowId rowId, 
Supplier<T> supplier) {
             });
         }
     }
+
+    @Override
+    public @Nullable BinaryRowAndRowId pollForVacuum(HybridTimestamp 
lowWatermark) {
+        return busy(() -> {
+            throwExceptionIfStorageNotInRunnableState();
+
+            GarbageCollectionRowVersion first = gcQueue.findFirstFromGc();
+
+            // Garbage collection queue is empty.
+            if (first == null) {
+                return null;
+            }
+
+            HybridTimestamp rowTimestamp = first.getTimestamp();
+
+            // There are no versions in the garbage collection queue before 
watermark.
+            if (rowTimestamp.compareTo(lowWatermark) > 0) {
+                return null;
+            }
+
+            RowId rowId = first.getRowId();
+
+            return inUpdateVersionChainLock(rowId, () -> {
+                // Someone processed the element in parallel.
+                if (!gcQueue.removeFromGc(rowId, rowTimestamp)) {
+                    return null;
+                }
+
+                RowVersion removedRowVersion = removeWriteOnGc(rowId, 
rowTimestamp);
+
+                return new 
BinaryRowAndRowId(rowVersionToBinaryRow(removedRowVersion), rowId);
+            });
+        });
+    }
+
+    private RowVersion removeWriteOnGc(RowId rowId, HybridTimestamp 
rowTimestamp) {
+        RemoveWriteOnGcInvokeClosure removeWriteOnGc = new 
RemoveWriteOnGcInvokeClosure(rowId, rowTimestamp, this);

Review Comment:
   You're right, I'll fix it.



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