org.apache.cassandra.io.sstable.metadata

## Class MetadataCollector

- java.lang.Object
- - org.apache.cassandra.io.sstable.metadata.MetadataCollector

All Implemented Interfaces:
  PartitionStatisticsCollector

    public class MetadataCollector
    extends java.lang.Object
    implements PartitionStatisticsCollector

### Nested Class Summary

Nested Classes
`static class` `MetadataCollector.MinMaxIntTracker`
`static class` `MetadataCollector.MinMaxLongTracker`

### Field Summary

Fields
`protected com.clearspring.analytics.stream.cardinality.ICardinality` `cardinality` Default cardinality estimation method is to use HyperLogLog++.
`protected IntervalSet<CommitLogPosition>` `commitLogIntervals`
`protected double` `compressionRatio`
`protected EstimatedHistogram` `estimatedCellPerPartitionCount`
`protected EstimatedHistogram` `estimatedPartitionSize`
`protected StreamingHistogram.StreamingHistogramBuilder` `estimatedTombstoneDropTime`
`protected boolean` `hasLegacyCounterShards`
`protected MetadataCollector.MinMaxIntTracker` `localDeletionTimeTracker`
`protected java.nio.ByteBuffer[]` `maxClusteringValues`
`protected java.nio.ByteBuffer[]` `minClusteringValues`
`static double` `NO_COMPRESSION_RATIO`
`protected int` `sstableLevel`
`protected MetadataCollector.MinMaxLongTracker` `timestampTracker`
`protected long` `totalColumnsSet`
`protected long` `totalRows`
`protected MetadataCollector.MinMaxIntTracker` `ttlTracker`

### Constructor Summary

Constructors
Constructor and Description
`MetadataCollector(ClusteringComparator comparator)`
`MetadataCollector(java.lang.Iterable<SSTableReader> sstables, ClusteringComparator comparator, int level)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`MetadataCollector` `addCellPerPartitionCount(long cellCount)`
`MetadataCollector` `addCompressionRatio(long compressed, long uncompressed)` Ratio is compressed/uncompressed and it is if you have 1.x then compression isn't helping
`MetadataCollector` `addKey(java.nio.ByteBuffer key)`
`MetadataCollector` `addPartitionSizeInBytes(long partitionSize)`
`MetadataCollector` `commitLogIntervals(IntervalSet<CommitLogPosition> commitLogIntervals)`
`static StatsMetadata` `defaultStatsMetadata()`
`java.util.Map<MetadataType,MetadataComponent>` `finalizeMetadata(java.lang.String partitioner, double bloomFilterFPChance, long repairedAt, SerializationHeader header)`
`MetadataCollector` `mergeTombstoneHistogram(StreamingHistogram histogram)`
`MetadataCollector` `sstableLevel(int sstableLevel)`
`void` `update(Cell cell)`
`void` `update(DeletionTime dt)`
`void` `update(LivenessInfo newInfo)`
`MetadataCollector` `updateClusteringValues(ClusteringPrefix clustering)`
`void` `updateColumnSetPerRow(long columnSetInRow)`
`void` `updateHasLegacyCounterShards(boolean hasLegacyCounterShards)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### NO_COMPRESSION_RATIO

    public static final double NO_COMPRESSION_RATIO

See Also:
  Constant Field Values

#### estimatedPartitionSize

    protected EstimatedHistogram estimatedPartitionSize

#### estimatedCellPerPartitionCount

    protected EstimatedHistogram estimatedCellPerPartitionCount

#### commitLogIntervals

    protected IntervalSet<CommitLogPosition> commitLogIntervals

#### timestampTracker

    protected final MetadataCollector.MinMaxLongTracker timestampTracker

#### localDeletionTimeTracker

    protected final MetadataCollector.MinMaxIntTracker localDeletionTimeTracker

#### ttlTracker

    protected final MetadataCollector.MinMaxIntTracker ttlTracker

#### compressionRatio

    protected double compressionRatio

#### estimatedTombstoneDropTime

    protected StreamingHistogram.StreamingHistogramBuilder estimatedTombstoneDropTime

#### sstableLevel

    protected int sstableLevel

#### minClusteringValues

    protected java.nio.ByteBuffer[] minClusteringValues

#### maxClusteringValues

    protected java.nio.ByteBuffer[] maxClusteringValues

#### hasLegacyCounterShards

    protected boolean hasLegacyCounterShards

#### totalColumnsSet

    protected long totalColumnsSet

#### totalRows

    protected long totalRows

#### cardinality

    protected com.clearspring.analytics.stream.cardinality.ICardinality cardinality

Default cardinality estimation method is to use HyperLogLog++. Parameter here(p=13, sp=25) should give reasonable estimation while lowering bytes required to hold information. See CASSANDRA-5906 for detail.

### Constructor Detail

#### MetadataCollector

    public MetadataCollector(ClusteringComparator comparator)

#### MetadataCollector

    public MetadataCollector(java.lang.Iterable<SSTableReader> sstables,
                             ClusteringComparator comparator,
                             int level)

### Method Detail

#### defaultStatsMetadata

    public static StatsMetadata defaultStatsMetadata()

#### addKey

    public MetadataCollector addKey(java.nio.ByteBuffer key)

#### addPartitionSizeInBytes

    public MetadataCollector addPartitionSizeInBytes(long partitionSize)

#### addCellPerPartitionCount

    public MetadataCollector addCellPerPartitionCount(long cellCount)

#### mergeTombstoneHistogram

    public MetadataCollector mergeTombstoneHistogram(StreamingHistogram histogram)

#### addCompressionRatio

    public MetadataCollector addCompressionRatio(long compressed,
                                                 long uncompressed)

Ratio is compressed/uncompressed and it is if you have 1.x then compression isn't helping

#### update

    public void update(LivenessInfo newInfo)

Specified by:
  `update` in interface `PartitionStatisticsCollector`

#### update

    public void update(Cell cell)

Specified by:
  `update` in interface `PartitionStatisticsCollector`

#### update

    public void update(DeletionTime dt)

Specified by:
  `update` in interface `PartitionStatisticsCollector`

#### updateColumnSetPerRow

    public void updateColumnSetPerRow(long columnSetInRow)

Specified by:
  `updateColumnSetPerRow` in interface `PartitionStatisticsCollector`

#### commitLogIntervals

    public MetadataCollector commitLogIntervals(IntervalSet<CommitLogPosition> commitLogIntervals)

#### sstableLevel

    public MetadataCollector sstableLevel(int sstableLevel)

#### updateClusteringValues

    public MetadataCollector updateClusteringValues(ClusteringPrefix clustering)

#### updateHasLegacyCounterShards

    public void updateHasLegacyCounterShards(boolean hasLegacyCounterShards)

Specified by:
  `updateHasLegacyCounterShards` in interface `PartitionStatisticsCollector`

#### finalizeMetadata

    public java.util.Map<MetadataType,MetadataComponent> finalizeMetadata(java.lang.String partitioner,
                                                                          double bloomFilterFPChance,
                                                                          long repairedAt,
                                                                          SerializationHeader header)