mirror of https://github.com/facebook/rocksdb.git
Trace analyzer: replace number with enumeration type (#10827)
Summary: Currently, some numbers in the `tracer_analyzer_tool` may be a little confusing and unfriendly for people who want to add new query types. It may be better to replace them with the existing enumeration type to improve readability. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10827 Reviewed By: ajkr Differential Revision: D40576023 Pulled By: hx235 fbshipit-source-id: 0eb16820a15f365d53e848a3a8efd92928420429
This commit is contained in:
parent
4fefe1fed9
commit
f799c73d28
|
@ -170,18 +170,26 @@ namespace ROCKSDB_NAMESPACE {
|
|||
const size_t kShadowValueSize = 10;
|
||||
|
||||
std::map<std::string, int> taOptToIndex = {
|
||||
{"get", 0}, {"put", 1},
|
||||
{"delete", 2}, {"single_delete", 3},
|
||||
{"range_delete", 4}, {"merge", 5},
|
||||
{"iterator_Seek", 6}, {"iterator_SeekForPrev", 7},
|
||||
{"multiget", 8}};
|
||||
{"get", kGet},
|
||||
{"put", kPut},
|
||||
{"delete", kDelete},
|
||||
{"single_delete", kSingleDelete},
|
||||
{"range_delete", kRangeDelete},
|
||||
{"merge", kMerge},
|
||||
{"iterator_Seek", kIteratorSeek},
|
||||
{"iterator_SeekForPrev", kIteratorSeekForPrev},
|
||||
{"multiget", kMultiGet}};
|
||||
|
||||
std::map<int, std::string> taIndexToOpt = {
|
||||
{0, "get"}, {1, "put"},
|
||||
{2, "delete"}, {3, "single_delete"},
|
||||
{4, "range_delete"}, {5, "merge"},
|
||||
{6, "iterator_Seek"}, {7, "iterator_SeekForPrev"},
|
||||
{8, "multiget"}};
|
||||
{kGet, "get"},
|
||||
{kPut, "put"},
|
||||
{kDelete, "delete"},
|
||||
{kSingleDelete, "single_delete"},
|
||||
{kRangeDelete, "range_delete"},
|
||||
{kMerge, "merge"},
|
||||
{kIteratorSeek, "iterator_Seek"},
|
||||
{kIteratorSeekForPrev, "iterator_SeekForPrev"},
|
||||
{kMultiGet, "multiget"}};
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -293,59 +301,59 @@ TraceAnalyzer::TraceAnalyzer(std::string& trace_path, std::string& output_path,
|
|||
}
|
||||
|
||||
ta_.resize(kTaTypeNum);
|
||||
ta_[0].type_name = "get";
|
||||
ta_[kGet].type_name = "get";
|
||||
if (FLAGS_analyze_get) {
|
||||
ta_[0].enabled = true;
|
||||
ta_[kGet].enabled = true;
|
||||
} else {
|
||||
ta_[0].enabled = false;
|
||||
ta_[kGet].enabled = false;
|
||||
}
|
||||
ta_[1].type_name = "put";
|
||||
ta_[kPut].type_name = "put";
|
||||
if (FLAGS_analyze_put) {
|
||||
ta_[1].enabled = true;
|
||||
ta_[kPut].enabled = true;
|
||||
} else {
|
||||
ta_[1].enabled = false;
|
||||
ta_[kPut].enabled = false;
|
||||
}
|
||||
ta_[2].type_name = "delete";
|
||||
ta_[kDelete].type_name = "delete";
|
||||
if (FLAGS_analyze_delete) {
|
||||
ta_[2].enabled = true;
|
||||
ta_[kDelete].enabled = true;
|
||||
} else {
|
||||
ta_[2].enabled = false;
|
||||
ta_[kDelete].enabled = false;
|
||||
}
|
||||
ta_[3].type_name = "single_delete";
|
||||
ta_[kSingleDelete].type_name = "single_delete";
|
||||
if (FLAGS_analyze_single_delete) {
|
||||
ta_[3].enabled = true;
|
||||
ta_[kSingleDelete].enabled = true;
|
||||
} else {
|
||||
ta_[3].enabled = false;
|
||||
ta_[kSingleDelete].enabled = false;
|
||||
}
|
||||
ta_[4].type_name = "range_delete";
|
||||
ta_[kRangeDelete].type_name = "range_delete";
|
||||
if (FLAGS_analyze_range_delete) {
|
||||
ta_[4].enabled = true;
|
||||
ta_[kRangeDelete].enabled = true;
|
||||
} else {
|
||||
ta_[4].enabled = false;
|
||||
ta_[kRangeDelete].enabled = false;
|
||||
}
|
||||
ta_[5].type_name = "merge";
|
||||
ta_[kMerge].type_name = "merge";
|
||||
if (FLAGS_analyze_merge) {
|
||||
ta_[5].enabled = true;
|
||||
ta_[kMerge].enabled = true;
|
||||
} else {
|
||||
ta_[5].enabled = false;
|
||||
ta_[kMerge].enabled = false;
|
||||
}
|
||||
ta_[6].type_name = "iterator_Seek";
|
||||
ta_[kIteratorSeek].type_name = "iterator_Seek";
|
||||
if (FLAGS_analyze_iterator) {
|
||||
ta_[6].enabled = true;
|
||||
ta_[kIteratorSeek].enabled = true;
|
||||
} else {
|
||||
ta_[6].enabled = false;
|
||||
ta_[kIteratorSeek].enabled = false;
|
||||
}
|
||||
ta_[7].type_name = "iterator_SeekForPrev";
|
||||
ta_[kIteratorSeekForPrev].type_name = "iterator_SeekForPrev";
|
||||
if (FLAGS_analyze_iterator) {
|
||||
ta_[7].enabled = true;
|
||||
ta_[kIteratorSeekForPrev].enabled = true;
|
||||
} else {
|
||||
ta_[7].enabled = false;
|
||||
ta_[kIteratorSeekForPrev].enabled = false;
|
||||
}
|
||||
ta_[8].type_name = "multiget";
|
||||
ta_[kMultiGet].type_name = "multiget";
|
||||
if (FLAGS_analyze_multiget) {
|
||||
ta_[8].enabled = true;
|
||||
ta_[kMultiGet].enabled = true;
|
||||
} else {
|
||||
ta_[8].enabled = false;
|
||||
ta_[kMultiGet].enabled = false;
|
||||
}
|
||||
for (int i = 0; i < kTaTypeNum; i++) {
|
||||
ta_[i].sample_count = 0;
|
||||
|
|
|
@ -56,7 +56,7 @@ struct Trace {
|
|||
// example, if bit at position 0 is set in write payload, then the write batch
|
||||
// will be addedd.
|
||||
uint64_t payload_map = 0;
|
||||
// Each trace type has its own payload_struct, which will be serilized in the
|
||||
// Each trace type has its own payload_struct, which will be serialized in the
|
||||
// payload.
|
||||
std::string payload;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ enum CacheDumpUnitType : unsigned char {
|
|||
kBlockTypeMax,
|
||||
};
|
||||
|
||||
// The metadata of a dump unit. After it is serilized, its size is fixed 16
|
||||
// The metadata of a dump unit. After it is serialized, its size is fixed 16
|
||||
// bytes.
|
||||
struct DumpUnitMeta {
|
||||
// sequence number is a monotonically increasing number to indicate the order
|
||||
|
@ -48,7 +48,7 @@ struct DumpUnitMeta {
|
|||
uint32_t sequence_num;
|
||||
// The Crc32c checksum of its dump unit.
|
||||
uint32_t dump_unit_checksum;
|
||||
// The dump unit size after the dump unit is serilized to a string.
|
||||
// The dump unit size after the dump unit is serialized to a string.
|
||||
uint64_t dump_unit_size;
|
||||
|
||||
void reset() {
|
||||
|
|
Loading…
Reference in New Issue