// if it is, load them to estimate key count
if (cardinalityAvailable)
{
boolean failed = false;
ICardinality cardinality = null;
for (SSTableReader sstable : sstables)
{
try
{
CompactionMetadata metadata = (CompactionMetadata) sstable.descriptor.getMetadataSerializer().deserialize(sstable.descriptor, MetadataType.COMPACTION);
assert metadata != null : sstable.getFilename();
if (cardinality == null)
cardinality = metadata.cardinalityEstimator;
else
cardinality = cardinality.merge(metadata.cardinalityEstimator);
}
catch (IOException e)
{
logger.warn("Reading cardinality from Statistics.db failed.", e);
failed = true;
break;
}
catch (CardinalityMergeException e)
{
logger.warn("Cardinality merge failed.", e);
failed = true;
break;
}
}
if (cardinality != null && !failed)
count = cardinality.cardinality();
}
// if something went wrong above or cardinality is not available, calculate using index summary
if (count < 0)
{