diff --git a/dbms/src/Storages/DeltaMerge/Decode/SSTFilesToBlockInputStream.h b/dbms/src/Storages/DeltaMerge/Decode/SSTFilesToBlockInputStream.h index fa210dcc2ae..3c76a9136c0 100644 --- a/dbms/src/Storages/DeltaMerge/Decode/SSTFilesToBlockInputStream.h +++ b/dbms/src/Storages/DeltaMerge/Decode/SSTFilesToBlockInputStream.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -42,52 +43,6 @@ using SSTFilesToBlockInputStreamPtr = std::shared_ptr; -struct SSTScanSoftLimit -{ - constexpr static size_t HEAD_OR_ONLY_SPLIT = SIZE_MAX; - size_t split_id; - TiKVKey raw_start; - TiKVKey raw_end; - DecodedTiKVKey decoded_start; - DecodedTiKVKey decoded_end; - std::optional start_limit; - std::optional end_limit; - - SSTScanSoftLimit(size_t split_id_, TiKVKey && raw_start_, TiKVKey && raw_end_) - : split_id(split_id_) - , raw_start(std::move(raw_start_)) - , raw_end(std::move(raw_end_)) - { - if (!raw_start.empty()) - { - decoded_start = RecordKVFormat::decodeTiKVKey(raw_start); - } - if (!raw_end.empty()) - { - decoded_end = RecordKVFormat::decodeTiKVKey(raw_end); - } - if (!decoded_start.empty()) - { - start_limit = RecordKVFormat::getRawTiDBPK(decoded_start); - } - if (!decoded_end.empty()) - { - end_limit = RecordKVFormat::getRawTiDBPK(decoded_end); - } - } - - SSTScanSoftLimit clone() const { return SSTScanSoftLimit(split_id, raw_start.toString(), raw_end.toString()); } - - const std::optional & getStartLimit() const { return start_limit; } - - const std::optional & getEndLimit() const { return end_limit; } - - std::string toDebugString() const - { - return fmt::format("{}:{}", raw_start.toDebugString(), raw_end.toDebugString()); - } -}; - struct SSTFilesToBlockInputStreamOpts { std::string log_prefix; diff --git a/dbms/src/Storages/DeltaMerge/Decode/SSTScanSoftLimit.h b/dbms/src/Storages/DeltaMerge/Decode/SSTScanSoftLimit.h new file mode 100644 index 00000000000..7c98abdbbf4 --- /dev/null +++ b/dbms/src/Storages/DeltaMerge/Decode/SSTScanSoftLimit.h @@ -0,0 +1,71 @@ +// Copyright 2024 PingCAP, Inc. +// +// 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. + +#include +#include +#include +#include +#include +#include + +namespace DB::DM +{ + +struct SSTScanSoftLimit +{ + constexpr static size_t HEAD_OR_ONLY_SPLIT = SIZE_MAX; + size_t split_id; + TiKVKey raw_start; + TiKVKey raw_end; + DecodedTiKVKey decoded_start; + DecodedTiKVKey decoded_end; + std::optional start_limit; + std::optional end_limit; + + SSTScanSoftLimit(size_t split_id_, TiKVKey && raw_start_, TiKVKey && raw_end_) + : split_id(split_id_) + , raw_start(std::move(raw_start_)) + , raw_end(std::move(raw_end_)) + { + if (!raw_start.empty()) + { + decoded_start = RecordKVFormat::decodeTiKVKey(raw_start); + } + if (!raw_end.empty()) + { + decoded_end = RecordKVFormat::decodeTiKVKey(raw_end); + } + if (!decoded_start.empty()) + { + start_limit = RecordKVFormat::getRawTiDBPK(decoded_start); + } + if (!decoded_end.empty()) + { + end_limit = RecordKVFormat::getRawTiDBPK(decoded_end); + } + } + + SSTScanSoftLimit clone() const { return SSTScanSoftLimit(split_id, raw_start.toString(), raw_end.toString()); } + + const std::optional & getStartLimit() const { return start_limit; } + + const std::optional & getEndLimit() const { return end_limit; } + + std::string toDebugString() const + { + return fmt::format("{}:{}", raw_start.toDebugString(), raw_end.toDebugString()); + } +}; + +} // namespace DB::DM