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


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/StorageUpdateHandler.java:
##########
@@ -252,10 +254,34 @@ private void tryRemoveFromIndexes(BinaryRow rowToRemove, 
RowId rowId, Cursor<Rea
         }
     }
 
-    private void removeFromIndex(BinaryRow row, RowId rowId) {
-        for (TableSchemaAwareIndexStorage index : indexes.get().values()) {
-            index.remove(row, rowId);
-        }
+    /**
+     * Tries removing partition's oldest stale entry and its indexes.
+     *
+     * @param lowWatermark Low watermark for the vacuum.
+     */
+    public boolean vacuum(HybridTimestamp lowWatermark) {

Review Comment:
   Please describe the return value.



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/StorageUpdateHandler.java:
##########
@@ -252,10 +254,34 @@ private void tryRemoveFromIndexes(BinaryRow rowToRemove, 
RowId rowId, Cursor<Rea
         }
     }
 
-    private void removeFromIndex(BinaryRow row, RowId rowId) {
-        for (TableSchemaAwareIndexStorage index : indexes.get().values()) {
-            index.remove(row, rowId);
-        }
+    /**
+     * Tries removing partition's oldest stale entry and its indexes.
+     *
+     * @param lowWatermark Low watermark for the vacuum.
+     */
+    public boolean vacuum(HybridTimestamp lowWatermark) {
+        return storage.runConsistently(() -> {
+            BinaryRowAndRowId vacuumed = storage.pollForVacuum(lowWatermark);
+
+            if (vacuumed == null) {
+                // Nothing was garbage collected.
+                return false;
+            }
+
+            BinaryRow binaryRow = vacuumed.binaryRow();
+
+            assert binaryRow != null;

Review Comment:
   Looks like there might be a mistake and we can remove the tombstone.



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/snapshot/outgoing/SnapshotAwarePartitionDataStorage.java:
##########
@@ -136,6 +137,11 @@ public Cursor<ReadResult> scanVersions(RowId rowId) throws 
StorageException {
         return partitionStorage.scanVersions(rowId);
     }
 
+    @Override
+    public BinaryRowAndRowId pollForVacuum(HybridTimestamp lowWatermark) {

Review Comment:
   ```suggestion
       public @Nullable BinaryRowAndRowId pollForVacuum(HybridTimestamp 
lowWatermark) {
   ```



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/PartitionDataStorage.java:
##########
@@ -165,6 +166,14 @@ public interface PartitionDataStorage extends 
ManuallyCloseable {
      */
     Cursor<ReadResult> scanVersions(RowId rowId) throws StorageException;
 
+    /**
+     * Tries to garbage collect the oldest stale entry of the partition.
+     *
+     * @see MvPartitionStorage#pollForVacuum(HybridTimestamp)
+     */
+    @Nullable
+    BinaryRowAndRowId pollForVacuum(HybridTimestamp lowWatermark);

Review Comment:
   ```suggestion
       @Nullable BinaryRowAndRowId pollForVacuum(HybridTimestamp lowWatermark);
   ```



##########
modules/table/src/testFixtures/java/org/apache/ignite/distributed/TestPartitionDataStorage.java:
##########
@@ -111,6 +112,11 @@ public Cursor<ReadResult> scanVersions(RowId rowId) throws 
StorageException {
         return partitionStorage.scanVersions(rowId);
     }
 
+    @Override
+    public BinaryRowAndRowId pollForVacuum(HybridTimestamp lowWatermark) {

Review Comment:
   ```suggestion
       public @Nullable BinaryRowAndRowId pollForVacuum(HybridTimestamp 
lowWatermark) {
   ```



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