org.apache.cassandra.io.sstable

## Class IndexSummaryBuilder

- java.lang.Object
- - org.apache.cassandra.io.sstable.IndexSummaryBuilder

All Implemented Interfaces:
  java.lang.AutoCloseable

    public class IndexSummaryBuilder
    extends java.lang.Object
    implements java.lang.AutoCloseable

### Nested Class Summary

Nested Classes
`static class` `IndexSummaryBuilder.ReadableBoundary` Represents a boundary that is guaranteed fully readable in the summary, index file and data file.

### Constructor Summary

Constructors
Constructor and Description
`IndexSummaryBuilder(long expectedKeys, int minIndexInterval, int samplingLevel)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`IndexSummary` `build(IPartitioner partitioner)`
`IndexSummary` `build(IPartitioner partitioner, IndexSummaryBuilder.ReadableBoundary boundary)`
`static int` `calculateSamplingLevel(int currentSamplingLevel, int currentNumEntries, long targetNumEntries, int minIndexInterval, int maxIndexInterval)`
`void` `close()`
`java.lang.Throwable` `close(java.lang.Throwable accumulate)`
`static IndexSummary` `downsample(IndexSummary existing, int newSamplingLevel, int minIndexInterval, IPartitioner partitioner)` Downsamples an existing index summary to a new sampling level.
`static int` `entriesAtSamplingLevel(int samplingLevel, int maxSummarySize)`
`IndexSummaryBuilder.ReadableBoundary` `getLastReadableBoundary()`
`void` `markDataSynced(long upToPosition)`
`void` `markIndexSynced(long upToPosition)`
`IndexSummaryBuilder` `maybeAddEntry(DecoratedKey decoratedKey, long indexStart)`
`IndexSummaryBuilder` `maybeAddEntry(DecoratedKey decoratedKey, long indexStart, long indexEnd, long dataEnd)`
`void` `prepareToCommit()`

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

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

### Constructor Detail

#### IndexSummaryBuilder

    public IndexSummaryBuilder(long expectedKeys,
                               int minIndexInterval,
                               int samplingLevel)

### Method Detail

#### markIndexSynced

    public void markIndexSynced(long upToPosition)

#### markDataSynced

    public void markDataSynced(long upToPosition)

#### getLastReadableBoundary

    public IndexSummaryBuilder.ReadableBoundary getLastReadableBoundary()

#### maybeAddEntry

    public IndexSummaryBuilder maybeAddEntry(DecoratedKey decoratedKey,
                                             long indexStart)
                                      throws java.io.IOException

Throws:
  `java.io.IOException`

#### maybeAddEntry

    public IndexSummaryBuilder maybeAddEntry(DecoratedKey decoratedKey,
                                             long indexStart,
                                             long indexEnd,
                                             long dataEnd)
                                      throws java.io.IOException

Parameters:
  `decoratedKey` - the key for this record
  `indexStart` - the position in the index file this record begins
  `indexEnd` - the position in the index file we need to be able to read to (exclusive) to read this record
  `dataEnd` - the position in the data file we need to be able to read to (exclusive) to read this record a value of 0 indicates we are not tracking readable boundaries
Throws:
  `java.io.IOException`

#### prepareToCommit

    public void prepareToCommit()

#### build

    public IndexSummary build(IPartitioner partitioner)

#### build

    public IndexSummary build(IPartitioner partitioner,
                              IndexSummaryBuilder.ReadableBoundary boundary)

#### close

    public void close()

Specified by:
  `close` in interface `java.lang.AutoCloseable`

#### close

    public java.lang.Throwable close(java.lang.Throwable accumulate)

#### entriesAtSamplingLevel

    public static int entriesAtSamplingLevel(int samplingLevel,
                                             int maxSummarySize)

#### calculateSamplingLevel

    public static int calculateSamplingLevel(int currentSamplingLevel,
                                             int currentNumEntries,
                                             long targetNumEntries,
                                             int minIndexInterval,
                                             int maxIndexInterval)

#### downsample

    public static IndexSummary downsample(IndexSummary existing,
                                          int newSamplingLevel,
                                          int minIndexInterval,
                                          IPartitioner partitioner)

Downsamples an existing index summary to a new sampling level.

Parameters:
  `existing` - an existing IndexSummary
  `newSamplingLevel` - the target level for the new IndexSummary. This must be less than the current sampling level for `existing`.
  `partitioner` - the partitioner used for the index summary
Returns:
  a new IndexSummary