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


##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/IndexGcTest.java:
##########
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table.distributed;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.UUID;
+import org.apache.ignite.internal.hlc.HybridTimestamp;
+import org.apache.ignite.internal.schema.BinaryRow;
+import org.apache.ignite.internal.storage.RowId;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/** Tests indexes cleaning up on garbage collection. */
+public class IndexGcTest extends IndexBaseTest {
+    @Test
+    void testRemoveStaleEntryWithSameIndex() {
+        UUID rowUuid = UUID.randomUUID();
+        RowId rowId = new RowId(1, rowUuid);
+
+        BinaryRow row = defaultRow();
+
+        addWrite(storageUpdateHandler, rowUuid, row);
+        commitWrite(rowId);
+
+        addWrite(storageUpdateHandler, rowUuid, row);
+        commitWrite(rowId);
+
+        assertTrue(storageUpdateHandler.vacuum(now()));
+
+        assertEquals(1, getRowVersions(rowId).size());
+        // Newer entry has the same index value, so it should not be removed.
+        assertTrue(inAllIndexes(row));
+    }
+
+    @Test
+    void testRemoveStaleEntriesWithDifferentIndexes() {
+        UUID rowUuid = UUID.randomUUID();
+        RowId rowId = new RowId(1, rowUuid);
+
+        var key = new TestKey(1, "foo");
+
+        BinaryRow tableRow1 = binaryRow(key, new TestValue(2, "bar"));
+        BinaryRow tableRow2 = binaryRow(key, new TestValue(5, "baz"));
+
+        addWrite(storageUpdateHandler, rowUuid, tableRow1);
+        commitWrite(rowId);
+
+        addWrite(storageUpdateHandler, rowUuid, tableRow1);
+        commitWrite(rowId);
+
+        addWrite(storageUpdateHandler, rowUuid, tableRow2);
+        commitWrite(rowId);
+
+        HybridTimestamp afterCommits = now();
+
+        assertTrue(storageUpdateHandler.vacuum(afterCommits));
+
+        // tableRow1 should still be in the index, because second write was 
identical to the first.
+        assertTrue(inAllIndexes(tableRow1));
+
+        assertTrue(storageUpdateHandler.vacuum(afterCommits));
+        assertFalse(storageUpdateHandler.vacuum(afterCommits));
+
+        assertEquals(1, getRowVersions(rowId).size());
+        // Older entries have different indexes, should be removed.
+        assertTrue(inIndexes(tableRow1, true, false));
+        assertTrue(inAllIndexes(tableRow2));
+    }
+
+    @Test
+    void testRemoveTombstonesRowNullNull() {
+        UUID rowUuid = UUID.randomUUID();
+        RowId rowId = new RowId(1, rowUuid);
+
+        BinaryRow row = defaultRow();
+
+        addWrite(storageUpdateHandler, rowUuid, row);
+        commitWrite(rowId);
+
+        addWrite(storageUpdateHandler, rowUuid, null);
+        commitWrite(rowId);
+
+        // Second tombstone won't be actually put into the storage, but still, 
let's check.
+        addWrite(storageUpdateHandler, rowUuid, null);
+        commitWrite(rowId);
+
+        HybridTimestamp afterCommits = now();
+
+        assertTrue(storageUpdateHandler.vacuum(afterCommits));
+        assertFalse(storageUpdateHandler.vacuum(afterCommits));
+
+        assertEquals(0, getRowVersions(rowId).size());
+        // The last entry was a tombstone, so no indexes should be left.
+        assertTrue(notInAnyIndex(row));
+    }
+
+    @Test
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-18882";)
+    void testRemoveTombstonesNullRowRow() {

Review Comment:
   Maybe remove?



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