Claudenw commented on code in PR #2081:
URL: https://github.com/apache/cassandra/pull/2081#discussion_r1069371364
##########
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 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.
--
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]