mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-21 17:10:35 +00:00
sstables: add fmt::formatter for large_data_type
Add a fmt::formatter specialization for sstables::large_data_type and use it in scylla-sstable.cc instead of the local to_string() overload, which is removed.
This commit is contained in:
@@ -898,3 +898,24 @@ struct fmt::formatter<sstables::deletion_time> {
|
||||
dt.marked_for_delete_at, dt.local_deletion_time);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<sstables::large_data_type> : fmt::formatter<string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(sstables::large_data_type type, FormatContext& ctx) const {
|
||||
using enum sstables::large_data_type;
|
||||
switch (type) {
|
||||
case partition_size:
|
||||
return formatter<string_view>::format("partition_size", ctx);
|
||||
case row_size:
|
||||
return formatter<string_view>::format("row_size", ctx);
|
||||
case cell_size:
|
||||
return formatter<string_view>::format("cell_size", ctx);
|
||||
case rows_in_partition:
|
||||
return formatter<string_view>::format("rows_in_partition", ctx);
|
||||
case elements_in_collection:
|
||||
return formatter<string_view>::format("elements_in_collection", ctx);
|
||||
}
|
||||
return formatter<string_view>::format("unknown", ctx);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1342,17 +1342,6 @@ const char* to_string(sstables::scylla_metadata_type t) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
const char* to_string(sstables::large_data_type t) {
|
||||
switch (t) {
|
||||
case sstables::large_data_type::partition_size: return "partition_size";
|
||||
case sstables::large_data_type::row_size: return "row_size";
|
||||
case sstables::large_data_type::cell_size: return "cell_size";
|
||||
case sstables::large_data_type::rows_in_partition: return "rows_in_partition";
|
||||
case sstables::large_data_type::elements_in_collection: return "elements_in_collection";
|
||||
}
|
||||
std::abort();
|
||||
}
|
||||
|
||||
const char* to_string(sstables::ext_timestamp_stats_type t) {
|
||||
switch (t) {
|
||||
case sstables::ext_timestamp_stats_type::min_live_timestamp: return "min_live_timestamp";
|
||||
@@ -1440,7 +1429,7 @@ public:
|
||||
void operator()(const sstables::scylla_metadata::large_data_stats& val) const {
|
||||
_writer.StartObject();
|
||||
for (const auto& [k, v] : val.map) {
|
||||
_writer.Key(to_string(k));
|
||||
_writer.Key(fmt::format("{}", k));
|
||||
_writer.StartObject();
|
||||
_writer.Key("max_value");
|
||||
_writer.Uint64(v.max_value);
|
||||
|
||||
Reference in New Issue
Block a user