aweisberg commented on code in PR #3754:
URL: https://github.com/apache/cassandra/pull/3754#discussion_r1984159806


##########
src/java/org/apache/cassandra/db/lifecycle/View.java:
##########
@@ -353,4 +361,40 @@ public boolean apply(T t)
             }
         };
     }
+
+    // Match the SSTableReaders from the existing ones to the new one to be 
added (with same ranges)
+    // Returns the map of toRemove <-> toAdd. Return empty map if such 1-1 
replacement doesn't exist
+    private static Map<SSTableReader, SSTableReader> getReplacementMap(final 
Set<SSTableReader> remove, final Iterable<SSTableReader> add)
+    {
+        List<SSTableReader> toAdds = new ArrayList<>();
+        for (SSTableReader s : add)
+            toAdds.add(s);
+
+        if (remove.size() != toAdds.size())
+            return Collections.emptyMap();
+
+        List<SSTableReader> toRemoves = new ArrayList<>(remove);
+        // sort the SSTableReader list by (first, last, descriptor.id). The 
view is per cfs so id will be unique
+        Comparator<SSTableReader> comp = Comparator.comparing((SSTableReader 
s) -> s.first)

Review Comment:
   This does replacement via the `first` and `last` so it won't help with early 
open` which is replacing an sstable with a different `first` and `last`.
   
   The only thing we can really properly replace by is the ID which can be 
found in the tree somewhere between the `first` and `last` of the replacement. 
I think in practice the replacement should always share the same `first` since 
the `first` can't change beyond going from `null` to not `null`.
   
   Incidentally does this fail `scrub_test.py`? It turns out offline tools load 
`sstables` without initializing the first and last key. At least they do in 
older versions.



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