-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract common parts of ApplySnapshot #8110
Merged
ti-chi-bot
merged 16 commits into
pingcap:master
from
CalvinNeo:refactor-applysnapshot2
Sep 19, 2023
+259
−164
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
221946e
initial
CalvinNeo 8afaad7
initial2
CalvinNeo 1b756cd
f
CalvinNeo e4538c0
comment
CalvinNeo 74ce8bd
tidy
CalvinNeo 91a1c5c
f
CalvinNeo 9b4ab89
Update dbms/src/Storages/DeltaMerge/SSTFilesToBlockInputStream.h
CalvinNeo a3e68f8
Update dbms/src/Storages/DeltaMerge/SSTFilesToBlockInputStream.h
CalvinNeo 87199c8
Update dbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp
CalvinNeo b10f374
Update dbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp
CalvinNeo 5f39d71
addr
CalvinNeo da87b21
Merge branch 'refactor-applysnapshot2' of github.com:CalvinNeo/tics i…
CalvinNeo 0e54c6b
Update dbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp
CalvinNeo b776b25
z
CalvinNeo 487a9b9
Merge branch 'refactor-applysnapshot2' of github.com:CalvinNeo/tics i…
CalvinNeo 49f5847
Merge branch 'master' into refactor-applysnapshot2
ti-chi-bot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
dbms/src/Storages/DeltaMerge/BoundedSSTFilesToBlockInputStream.cpp
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,95 @@ | ||
// Copyright 2023 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 <Interpreters/Context.h> | ||
#include <Poco/File.h> | ||
#include <RaftStoreProxyFFI/ColumnFamily.h> | ||
#include <Storages/DeltaMerge/DMVersionFilterBlockInputStream.h> | ||
#include <Storages/DeltaMerge/DeltaMergeStore.h> | ||
#include <Storages/DeltaMerge/File/DMFile.h> | ||
#include <Storages/DeltaMerge/File/DMFileBlockOutputStream.h> | ||
#include <Storages/DeltaMerge/PKSquashingBlockInputStream.h> | ||
#include <Storages/DeltaMerge/SSTFilesToBlockInputStream.h> | ||
#include <Storages/KVStore/Decode/PartitionStreams.h> | ||
#include <Storages/KVStore/FFI/ProxyFFI.h> | ||
#include <Storages/KVStore/FFI/SSTReader.h> | ||
#include <Storages/KVStore/Region.h> | ||
#include <Storages/KVStore/TMTContext.h> | ||
#include <Storages/StorageDeltaMerge.h> | ||
#include <common/logger_useful.h> | ||
|
||
namespace DB | ||
{ | ||
namespace DM | ||
{ | ||
BoundedSSTFilesToBlockInputStream::BoundedSSTFilesToBlockInputStream( // | ||
SSTFilesToBlockInputStreamPtr child, | ||
const ColId pk_column_id_, | ||
const DecodingStorageSchemaSnapshotConstPtr & schema_snap) | ||
: pk_column_id(pk_column_id_) | ||
, _raw_child(std::move(child)) | ||
{ | ||
const bool is_common_handle = schema_snap->is_common_handle; | ||
// Initlize `mvcc_compact_stream` | ||
// First refine the boundary of blocks. Note that the rows decoded from SSTFiles are sorted by primary key asc, timestamp desc | ||
// (https://github.com/tikv/tikv/blob/v5.0.1/components/txn_types/src/types.rs#L103-L108). | ||
// While DMVersionFilter require rows sorted by primary key asc, timestamp asc, so we need an extra sort in PKSquashing. | ||
auto stream = std::make_shared<PKSquashingBlockInputStream</*need_extra_sort=*/true>>( | ||
_raw_child, | ||
pk_column_id, | ||
is_common_handle); | ||
mvcc_compact_stream = std::make_unique<DMVersionFilterBlockInputStream<DM_VERSION_FILTER_MODE_COMPACT>>( | ||
stream, | ||
*(schema_snap->column_defines), | ||
_raw_child->opts.gc_safepoint, | ||
is_common_handle); | ||
} | ||
|
||
void BoundedSSTFilesToBlockInputStream::readPrefix() | ||
{ | ||
mvcc_compact_stream->readPrefix(); | ||
} | ||
|
||
void BoundedSSTFilesToBlockInputStream::readSuffix() | ||
{ | ||
mvcc_compact_stream->readSuffix(); | ||
} | ||
|
||
Block BoundedSSTFilesToBlockInputStream::read() | ||
{ | ||
return mvcc_compact_stream->read(); | ||
} | ||
|
||
SSTFilesToBlockInputStream::ProcessKeys BoundedSSTFilesToBlockInputStream::getProcessKeys() const | ||
{ | ||
return _raw_child->process_keys; | ||
} | ||
|
||
RegionPtr BoundedSSTFilesToBlockInputStream::getRegion() const | ||
{ | ||
return _raw_child->region; | ||
} | ||
|
||
std::tuple<size_t, size_t, size_t, UInt64> // | ||
BoundedSSTFilesToBlockInputStream::getMvccStatistics() const | ||
{ | ||
return std::make_tuple( | ||
mvcc_compact_stream->getEffectiveNumRows(), | ||
mvcc_compact_stream->getNotCleanRows(), | ||
mvcc_compact_stream->getDeletedRows(), | ||
mvcc_compact_stream->getGCHintVersion()); | ||
} | ||
|
||
} // namespace DM | ||
} // namespace DB |
JaySon-Huang marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved out from SSTFilesToBlockInputStream, with some header files excluded.