jacek-lewandowski commented on code in PR #2081:
URL: https://github.com/apache/cassandra/pull/2081#discussion_r1069386615
##########
test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java:
##########
@@ -686,4 +689,77 @@ private static void copyFile(File cfDir, File file) throws
IOException
}
}
}
+
+ /**
+ * Finds the first point at which the HashSet inserts a generation before
a previous
+ * generation in the set. This is used in testing to verfy the sequence of
tables where
+ * the generation order is significant.
+ * @param legacyVersion the legacy version to work with.
+ * @return the generation that causes of the inversion.
+ */
+ public static int findInversion(String legacyVersion) {
+ String ksname = "legacy_tables";
+ String cfname = String.format("legacy_%s_multiple", legacyVersion);;
+ SSTableFormat.Type formatType = SSTableFormat.Type.BIG;
+ int generation = 0;
+ SequenceBasedSSTableId id = new SequenceBasedSSTableId(generation);
+ File directory = new File( System.getProperty("java.io.tmpdir"));
+ Version version = formatType.info.getVersion(legacyVersion);
+ Descriptor descriptor = new Descriptor( version, directory, ksname,
cfname, id, formatType);
+ HashSet<Descriptor> set = new HashSet<>();
+ set.add( descriptor );
+ Object[] arry = set.toArray();
Review Comment:
I was thinking about something like this:
```java
static <T> T findFirstUnordered(java.util.function.Function<T, T>
provider)
{
HashSet<T> set = new HashSet<>(2);
T first = null;
while (true)
{
T second = provider.apply(first);
if (first != null)
{
set.add(first);
set.add(second);
if (set.iterator().next() != first)
return second;
}
first = second;
}
}
```
--
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]