-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Fixes ordering in StandaloneUpgrader #2081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Fixes ordering in StandaloneUpgrader #2081
Conversation
Fixed issue where sstables were not updated in order by sorting on SSTableId patch by Claude Warren; reviewed by <Reviewers> for CASSANDRA--18143
test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
Outdated
Show resolved
Hide resolved
| Descriptor descriptor = new Descriptor( version, directory, ksname, cfname, id, formatType); | ||
| HashSet<Descriptor> set = new HashSet<>(); | ||
| set.add( descriptor ); | ||
| Object[] arry = set.toArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it should be a generic method somewhere in the utility class. Something which take a function, for example <T> T generateUntilUnordered(Collection<T> collection, Function<T, T> generator) where generator accepts previously generated value, and initially null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work here. The issue is that the HashSet wraps the values of the hash long before Hash collides. The method literally has to insert into the Hash table and then verify that the last item in the Hash table was the one inserted. I have simplified the code so that it only retains two Descriptors at a time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about something like this:
static <T> T findFirstUnordered(java.util.function.Function<T, T> provider)
{
HashSet<T> set = new HashSet<>(2);
T first = null;
while (true)
{
set.clear();
T second = provider.apply(first);
if (first != null)
{
set.add(first);
set.add(second);
if (set.iterator().next() != first)
return second;
}
first = second;
}
}
test/unit/org/apache/cassandra/tools/StandaloneUpgraderOnSStablesTest.java
Outdated
Show resolved
Hide resolved
df3eb40 to
54e39a9
Compare
Fixed issue where sstables were not updated in order by sorting on SSTableId
patch by Claude Warren; reviewed by for CASSANDRA-18143