From b6838706442879e4e4e8ee98ced66d5b30cff8de Mon Sep 17 00:00:00 2001 From: Piotr Jastrzebski Date: Thu, 29 Mar 2018 16:18:00 +0200 Subject: [PATCH] Add support for 3_x stats metadata Signed-off-by: Piotr Jastrzebski --- sstables/sstables.cc | 11 +++++++ sstables/types.hh | 75 +++++++++++++++++++++++++++++++++----------- 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 66bb170955..2c7604f485 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -890,6 +890,17 @@ inline void write(sstable_version_types v, file_writer& out, const utils::stream write(v, out, max_bin_size, a); } +future<> parse(sstable_version_types v, random_access_reader& in, commitlog_interval& ci) { + return parse(v, in, ci.start).then([&ci, v, &in] { + return parse(v, in, ci.end); + }); +} + +inline void write(sstable_version_types v, file_writer& out, const commitlog_interval& ci) { + write(v, out, ci.start); + write(v, out, ci.end); +} + future<> parse(sstable_version_types v, random_access_reader& in, compression& c) { auto data_len_ptr = make_lw_shared(0); auto chunk_len_ptr = make_lw_shared(0); diff --git a/sstables/types.hh b/sstables/types.hh index eb10a09e69..ba9bd21119 100644 --- a/sstables/types.hh +++ b/sstables/types.hh @@ -46,6 +46,11 @@ static inline bytes_view to_bytes_view(const temporary_buffer& b) { namespace sstables { +struct commitlog_interval { + db::replay_position start; + db::replay_position end; +}; + struct deletion_time { int32_t local_deletion_time; int64_t marked_for_delete_at; @@ -296,13 +301,16 @@ struct compaction_metadata : public metadata_base { auto describe_type(sstable_version_types v, Describer f) { return f(ancestors, cardinality); } }; -struct ka_stats_metadata : public metadata_base { +struct stats_metadata : public metadata_base { utils::estimated_histogram estimated_row_size; utils::estimated_histogram estimated_column_count; db::replay_position position; int64_t min_timestamp; int64_t max_timestamp; + int32_t min_local_deletion_time; // 3_x only int32_t max_local_deletion_time; + int32_t min_ttl; // 3_x only + int32_t max_ttl; // 3_x only double compression_ratio; utils::streaming_histogram estimated_tombstone_drop_time; uint32_t sstable_level; @@ -310,29 +318,60 @@ struct ka_stats_metadata : public metadata_base { disk_array> min_column_names; disk_array> max_column_names; bool has_legacy_counter_shards; + int64_t columns_count; // 3_x only + int64_t rows_count; // 3_x only + db::replay_position commitlog_lower_bound; // 3_x only + disk_array commitlog_intervals; // 3_x only template auto describe_type(sstable_version_types v, Describer f) { - return f( - estimated_row_size, - estimated_column_count, - position, - min_timestamp, - max_timestamp, - max_local_deletion_time, - compression_ratio, - estimated_tombstone_drop_time, - sstable_level, - repaired_at, - min_column_names, - max_column_names, - has_legacy_counter_shards - ); + switch (v) { + case sstable_version_types::mc: + return f( + estimated_row_size, + estimated_column_count, + position, + min_timestamp, + max_timestamp, + min_ttl, + max_ttl, + min_local_deletion_time, + max_local_deletion_time, + compression_ratio, + estimated_tombstone_drop_time, + sstable_level, + repaired_at, + min_column_names, + max_column_names, + has_legacy_counter_shards, + columns_count, + rows_count, + commitlog_lower_bound, + commitlog_intervals + ); + case sstable_version_types::ka: + case sstable_version_types::la: + return f( + estimated_row_size, + estimated_column_count, + position, + min_timestamp, + max_timestamp, + max_local_deletion_time, + compression_ratio, + estimated_tombstone_drop_time, + sstable_level, + repaired_at, + min_column_names, + max_column_names, + has_legacy_counter_shards + ); + } + // Should never reach here - compiler will complain if switch above does not cover all sstable versions + abort(); } }; -using stats_metadata = ka_stats_metadata; - struct disk_token_bound { uint8_t exclusive; // really a boolean disk_string token;