[rocksdb][PR] compaction_style and compaction_pri should output their value as a st…

Summary:
…ring

Replace the numerical output for compaction_style and compaction_pri
with strings
Closes https://github.com/facebook/rocksdb/pull/1817

Differential Revision: D4482796

Pulled By: highker

fbshipit-source-id: 5785768
This commit is contained in:
James Sun 2017-02-07 10:35:15 -08:00 committed by Facebook Github Bot
parent 69d5262c81
commit 53bb01516d
2 changed files with 38 additions and 4 deletions

View File

@ -31,6 +31,7 @@
#include "table/block_based_table_factory.h" #include "table/block_based_table_factory.h"
#include "util/compression.h" #include "util/compression.h"
#include "util/db_options.h" #include "util/db_options.h"
#include "util/options_helper.h"
#include "util/statistics.h" #include "util/statistics.h"
#include "util/xfunc.h" #include "util/xfunc.h"
@ -285,10 +286,30 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
disable_auto_compactions); disable_auto_compactions);
Header(log, " Options.verify_checksums_in_compaction: %d", Header(log, " Options.verify_checksums_in_compaction: %d",
verify_checksums_in_compaction); verify_checksums_in_compaction);
Header(log, " Options.compaction_style: %d",
compaction_style); const auto& it_compaction_style =
Header(log, " Options.compaction_pri: %d", compaction_style_to_string.find(compaction_style);
compaction_pri); std::string str_compaction_style;
if (it_compaction_style == compaction_style_to_string.end()) {
assert(false);
str_compaction_style = "unknown_" + std::to_string(compaction_style);
} else {
str_compaction_style = it_compaction_style->second;
}
Header(log, " Options.compaction_style: %s",
str_compaction_style.c_str());
const auto& it_compaction_pri =
compaction_pri_to_string.find(compaction_pri);
std::string str_compaction_pri;
if (it_compaction_pri == compaction_pri_to_string.end()) {
assert(false);
str_compaction_pri = "unknown_" + std::to_string(compaction_pri);
} else {
str_compaction_pri = it_compaction_pri->second;
}
Header(log, " Options.compaction_pri: %s",
str_compaction_pri.c_str());
Header(log, " Options.compaction_options_universal.size_ratio: %u", Header(log, " Options.compaction_options_universal.size_ratio: %u",
compaction_options_universal.size_ratio); compaction_options_universal.size_ratio);
Header(log, "Options.compaction_options_universal.min_merge_width: %u", Header(log, "Options.compaction_options_universal.min_merge_width: %u",

View File

@ -5,6 +5,7 @@
#pragma once #pragma once
#include <map>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <vector> #include <vector>
@ -24,6 +25,18 @@ ColumnFamilyOptions BuildColumnFamilyOptions(
const ColumnFamilyOptions& ioptions, const ColumnFamilyOptions& ioptions,
const MutableCFOptions& mutable_cf_options); const MutableCFOptions& mutable_cf_options);
static std::map<CompactionStyle, std::string> compaction_style_to_string = {
{kCompactionStyleLevel, "kCompactionStyleLevel"},
{kCompactionStyleUniversal, "kCompactionStyleUniversal"},
{kCompactionStyleFIFO, "kCompactionStyleFIFO"},
{kCompactionStyleNone, "kCompactionStyleNone"}};
static std::map<CompactionPri, std::string> compaction_pri_to_string = {
{kByCompensatedSize, "kByCompensatedSize"},
{kOldestLargestSeqFirst, "kOldestLargestSeqFirst"},
{kOldestSmallestSeqFirst, "kOldestSmallestSeqFirst"},
{kMinOverlappingRatio, "kMinOverlappingRatio"}};
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
// Returns true if the input char "c" is considered as a special character // Returns true if the input char "c" is considered as a special character