Table of Contents

Class UniversalCompactionOptions

Namespace
RocksDbNet
Assembly
RocksDb.Net.dll

Tuning for universal compaction. Maps to rocksdb_universal_compaction_options_t.

public sealed class UniversalCompactionOptions : RocksDbHandle, IDisposable
Inheritance
UniversalCompactionOptions
Implements
Inherited Members

Remarks

Only used when CompactionStyle is Universal. Universal compaction exists to trade space amplification against write amplification, and these are the settings that make that trade, so selecting the style without setting them leaves the interesting decisions at their defaults.

Attach with UniversalCompactionOptions. RocksDb copies the values, so this object may be disposed immediately afterwards.

Constructors

UniversalCompactionOptions()

Creates options with RocksDb's defaults.

public UniversalCompactionOptions()

Properties

AllowTrivialMove

Whether a file may be moved between levels instead of rewritten when nothing needs merging.

public bool AllowTrivialMove { get; set; }

Property Value

bool

Remarks

A trivial move is far cheaper than a rewrite, since it only updates metadata.

CompressionSizePercent

What percentage of the data is compressed, with the newest left uncompressed. Negative disables the behaviour and compresses everything.

public int CompressionSizePercent { get; set; }

Property Value

int

Incremental

Whether a full compaction is performed in pieces rather than all at once.

public bool Incremental { get; set; }

Property Value

bool

Remarks

Full universal compactions are large. Doing one incrementally keeps its peak space and time cost down, at the price of taking longer overall.

MaxMergeWidth

Most files that will be compacted together.

public int MaxMergeWidth { get; set; }

Property Value

int

MaxReadAmp

Most sorted runs a read may have to consult, or a non-positive value to let RocksDb derive it.

public int MaxReadAmp { get; set; }

Property Value

int

MaxSizeAmplificationPercent

How much larger than the live data the database may grow, as a percentage, before a full compaction is forced.

public int MaxSizeAmplificationPercent { get; set; }

Property Value

int

Remarks

The setting that bounds universal compaction's main cost. Lower values keep the database smaller and compact more often.

MinMergeWidth

Fewest files that will be compacted together.

public int MinMergeWidth { get; set; }

Property Value

int

ReduceFileLocking

Whether file locking is reduced during compaction.

public bool ReduceFileLocking { get; set; }

Property Value

bool

SizeRatio

How much file sizes may differ, as a percentage, and still be compacted together.

public int SizeRatio { get; set; }

Property Value

int

Remarks

A candidate within this percentage of the next file's size is merged with it. Larger values produce fewer, bigger compactions.

StopStyle

Where a compaction stops adding files.

public CompactionStopStyle StopStyle { get; set; }

Property Value

CompactionStopStyle

Methods

DisposeHandle()

Releases the native handle. Called during disposal.

protected override void DisposeHandle()

Remarks

Protected rather than public: it destroys the native object without marking this instance disposed or clearing the handle, so calling it from outside and then disposing normally would free the same pointer twice. It was the most Dispose-looking member on the type. Callers want Dispose().