SammyVimes commented on code in PR #2019:
URL: https://github.com/apache/ignite-3/pull/2019#discussion_r1185454420


##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/RocksDbKeyValueStorage.java:
##########
@@ -975,30 +1034,59 @@ private boolean addToBatchForRemoval(WriteBatch batch, 
byte[] key, long curRev,
     }
 
     /**
-     * Compacts all entries by the given key, removing all previous revisions 
and deleting the last entry if it is a tombstone.
+     * Compacts all entries by the given key, removing all previous revisions 
lesser or equal to the revision watermark and
+     * deleting the last entry if it is a tombstone.
      *
      * @param batch Write batch.
      * @param key   Target key.
      * @param revs  Revisions.
+     * @param revisionWatermark Maximum revision that can be removed.
      * @throws RocksDBException If failed.
      */
-    private void compactForKey(WriteBatch batch, byte[] key, long[] revs) 
throws RocksDBException {
+    private void compactForKey(WriteBatch batch, byte[] key, long[] revs, long 
revisionWatermark) throws RocksDBException {
         long lastRev = lastRevision(revs);
 
+        int idxToKeepFrom = 0;
+
         for (int i = 0; i < revs.length - 1; i++) {
-            data.delete(batch, keyToRocksKey(revs[i], key));
+            long rev = revs[i];
+
+            if (rev > revisionWatermark) {
+                break;
+            }
+
+            // This revision is not needed anymore, remove data.
+            data.delete(batch, keyToRocksKey(rev, key));
+
+            idxToKeepFrom++;
         }
 
-        byte[] rocksKey = keyToRocksKey(lastRev, key);
+        // Whether we only have last revision (even if it's lesser or equal to 
watermark).

Review Comment:
   Documented it, but I don't see how the code can be changed



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