blambov commented on code in PR #2423:
URL: https://github.com/apache/cassandra/pull/2423#discussion_r1244919074


##########
src/java/org/apache/cassandra/db/compaction/CompactionManager.java:
##########
@@ -680,12 +680,28 @@ public AllSSTableOpStatus performGarbageCollection(final 
ColumnFamilyStore cfSto
             @Override
             public Iterable<SSTableReader> filterSSTables(LifecycleTransaction 
transaction)
             {
-                Iterable<SSTableReader> originals = transaction.originals();
+                List<SSTableReader> sstables = 
Lists.newArrayList(transaction.originals());
+                Iterator<SSTableReader> iter = sstables.iterator();
                 if 
(cfStore.getCompactionStrategyManager().onlyPurgeRepairedTombstones())
-                    originals = Iterables.filter(originals, 
SSTableReader::isRepaired);
-                List<SSTableReader> sortedSSTables = 
Lists.newArrayList(originals);
-                Collections.sort(sortedSSTables, 
SSTableReader.maxTimestampAscending);
-                return sortedSSTables;
+                {
+                    while (iter.hasNext())
+                    {
+                        SSTableReader sstable = iter.next();
+                        if (!sstable.isRepaired())
+                        {
+                            try
+                            {
+                                transaction.cancel(sstable);
+                            }
+                            finally
+                            {
+                                iter.remove();

Review Comment:
   Removal in the interior of the array list makes this an O(n^2) operation, 
which can be a problem when the number of sstables can grow proportionally with 
data size (e.g. with LCS and UCS).
   I'd turn this into an iteration over the source, deciding to add to an 
initially empty array or cancel.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to