• Optimize for read heavy workloads by compacting to lowest level after ingesting a large amount of data
    • Force the data to go through the compaction filter in order to consolidate it

    Or

    1. CompactionOptions options;
    2. std::vector<std::string> input_file_names;
    3. int output_level;
    4. Status s = db->CompactFiles(options, input_file_names, output_level);

    If more than one thread calls manual compaction, only one will actually schedule it while the other threads will simply wait for the scheduled manual compaction to complete. If CompactRangeOptions::exclusive_manual_compaction is set to true, the call will disable scheduling of automatic compaction jobs and wait for existing automatic compaction jobs to finish.

    • CompactRangeOptions::exclusive_manual_compaction When set to true, no other compaction will run when this manual compaction is running. Default value is true
    • ,CompactRangeOptions::target_level Together, these options control the level where the compacted files will be placed. If target_level is -1, the compacted files will be moved to the minimum level whose computed max_bytes is still large enough to hold the files. Intermediate levels must be empty. For example, if the files were initially compacted to L5 and L2 is the minimum level large enough to hold the files, they will be placed in L2 if L3 and L4 are empty or in L4 if L3 is non-empty. If target_level is positive, the compacted files will be placed in that level provided intermediate levels are empty. If any any of the intermediate levels are not empty, the compacted files will be left where they are.
    • CompactRangeOptions::bottommost_level_compaction When set to BottommostLevelCompaction::kSkip, or when set to BottommostLevelCompaction::kIfHaveCompactionFilter and a compaction filter is defined for the column family, the bottommost level files are not compacted.

    CompactFiles

    This API compacts all the input files into a set of output files in the output_level. The number of output files is determined by the size of the data and the setting of . This API is not supported in ROCKSDB_LITE.