-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: JaySon-Huang <[email protected]>
- Loading branch information
1 parent
8033e12
commit 4f27f51
Showing
9 changed files
with
182 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2023 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <Storages/Page/PageConstants.h> | ||
#include <fmt/format.h> | ||
|
||
#include <magic_enum.hpp> | ||
|
||
namespace DB::PS::V3 | ||
{ | ||
|
||
struct CPDataWriteStats | ||
{ | ||
bool has_new_data = false; | ||
|
||
size_t incremental_data_bytes = 0; | ||
size_t compact_data_bytes = 0; | ||
|
||
std::array<size_t, static_cast<size_t>(StorageType::_MAX_STORAGE_TYPE_)> num_keys{}; | ||
std::array<size_t, static_cast<size_t>(StorageType::_MAX_STORAGE_TYPE_)> num_bytes{}; | ||
|
||
// Total number of records in this checkpoint | ||
size_t num_records = 0; | ||
// Number of Pages that already uploaded to S3 | ||
// and is not changed in this checkpoint | ||
size_t num_pages_unchanged = 0; | ||
// Number of Pages that already uploaded to S3 | ||
// but picked by compaction in this checkpoint | ||
size_t num_pages_compact = 0; | ||
// Number of incremental Pages since last checkpoint | ||
size_t num_pages_incremental = 0; | ||
// Number of ExternalPages | ||
size_t num_ext_pages = 0; | ||
// Number of other records other than Pages/ExternalPages | ||
size_t num_other_records = 0; | ||
}; | ||
|
||
} // namespace DB::PS::V3 | ||
|
||
template <> | ||
struct fmt::formatter<DB::PS::V3::CPDataWriteStats> | ||
{ | ||
static constexpr auto parse(format_parse_context & ctx) { return ctx.begin(); } | ||
|
||
template <typename FormatContext> | ||
auto format(const DB::PS::V3::CPDataWriteStats & value, FormatContext & ctx) const -> decltype(ctx.out()) | ||
{ | ||
auto it = format_to( | ||
ctx.out(), | ||
"CPDataWriteStats{{" | ||
"incremental_data_bytes={} compact_data_bytes={}" | ||
" n_records{{total={} pages_unchanged={} pages_compact={} pages_incremental={} ext_pages={} other={}}}", | ||
value.incremental_data_bytes, | ||
value.compact_data_bytes, | ||
value.num_records, | ||
value.num_pages_unchanged, | ||
value.num_pages_compact, | ||
value.num_pages_incremental, | ||
value.num_ext_pages, | ||
value.num_other_records); | ||
it = format_to(it, " types["); | ||
for (size_t i = 0; i < static_cast<size_t>(DB::StorageType::_MAX_STORAGE_TYPE_); ++i) | ||
{ | ||
if (i != 0) | ||
it = format_to(it, " "); | ||
it = format_to( | ||
it, | ||
"{{type={} keys={} bytes={}}}", | ||
magic_enum::enum_name(static_cast<DB::StorageType>(i)), | ||
value.num_keys[i], | ||
value.num_bytes[i]); | ||
} | ||
return format_to( | ||
it, | ||
"]" // end of "keys" | ||
"}}" // end of "CPDataWriteStats" | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters