diff --git a/src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java b/src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java index 831901439c..c97519b28f 100644 --- a/src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java +++ b/src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java @@ -20,8 +20,12 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.util.Collections; import java.util.EnumSet; +import java.util.HashMap; import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; import org.apache.cassandra.io.sstable.Descriptor; import org.apache.cassandra.io.sstable.metadata.*; @@ -45,6 +49,8 @@ public static void main(String[] args) throws IOException Util.initDatabaseDescriptor(); + Map> generationToAncestors = new HashMap<>(); + for (String fname : args) { if (new File(fname).exists()) @@ -83,7 +89,11 @@ public static void main(String[] args) throws IOException { out.printf("Ancestors: %s%n", compaction.ancestors.toString()); out.printf("Estimated cardinality: %s%n", compaction.cardinalityEstimator.cardinality()); - + generationToAncestors.put(descriptor.generation, compaction.ancestors); + } + else + { + generationToAncestors.put(descriptor.generation, Collections.emptySet()); } } else @@ -91,6 +101,19 @@ public static void main(String[] args) throws IOException out.println("No such file: " + fname); } } + + out.println(); + out.println("SSTables listing other SSTables as ancestors (should be empty unless mid-compaction):"); + for (Map.Entry> entry : generationToAncestors.entrySet()) + { + out.print(entry.getKey()); + out.print(": "); + out.println(entry + .getValue() + .stream() + .filter(generationToAncestors::containsKey) + .collect(Collectors.toSet())); + } } private static void printHistograms(StatsMetadata metadata, PrintStream out)