Yukei7 commented on code in PR #3754:
URL: https://github.com/apache/cassandra/pull/3754#discussion_r1947116459
##########
src/java/org/apache/cassandra/db/lifecycle/View.java:
##########
@@ -372,8 +372,45 @@ private static int getSSTablesHash(Iterable<SSTableReader>
readers) {
return hashSum;
}
- private static boolean isRangesUnchanged(final Set<SSTableReader> remove,
final Iterable<SSTableReader> add)
+ // 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)
{
- return getSSTablesHash(remove) == getSSTablesHash(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)
+ Comparator<SSTableReader> comp = (o1, o2) -> {
+ if (o1.first.compareTo(o2.first) == 0)
+ if (o1.last.compareTo(o2.last) == 0)
+ return Integer.compare(o1.descriptor.hashCode(),
o2.descriptor.hashCode());
Review Comment:
oh I see.. I was under impression that `equals` method for `descriptor` was
with `hashCode`.
I update it to use the `idComparator` to sort by descriptor.id. These are
within the same cfs so id will be unique
--
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]