-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Storages: disaggregated mode supports storage read thread. (#8272)
ref #6834
- Loading branch information
Showing
21 changed files
with
1,137 additions
and
629 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
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
48 changes: 48 additions & 0 deletions
48
dbms/src/Storages/DeltaMerge/Remote/DataStore/DataStoreMock.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,48 @@ | ||
// 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 <Storages/DeltaMerge/Remote/DataStore/DataStoreMock.h> | ||
|
||
namespace DB::DM::Remote | ||
{ | ||
|
||
IPreparedDMFileTokenPtr DataStoreMock::prepareDMFileByKey(const String & remote_key) | ||
{ | ||
return std::make_shared<MockPreparedDMFileToken>(file_provider, remote_key); | ||
} | ||
|
||
static std::tuple<String, UInt64> parseDMFilePath(const String & path) | ||
{ | ||
// Path likes /disk1/data/t_100/stable/dmf_2. | ||
auto pos = path.find_last_of('_'); | ||
RUNTIME_CHECK(pos != std::string::npos, path); | ||
auto file_id = stoul(path.substr(pos + 1)); | ||
|
||
pos = path.rfind("/dmf_"); | ||
RUNTIME_CHECK(pos != std::string::npos, path); | ||
auto parent_path = path.substr(0, pos); | ||
return std::tuple<String, UInt64>{parent_path, file_id}; | ||
} | ||
|
||
DMFilePtr MockPreparedDMFileToken::restore(DMFile::ReadMetaMode read_mode) | ||
{ | ||
auto [parent_path, file_id] = parseDMFilePath(path); | ||
return DMFile::restore( | ||
file_provider, | ||
file_id, | ||
/*page_id*/ 0, | ||
parent_path, | ||
read_mode); | ||
} | ||
} // namespace DB::DM::Remote |
78 changes: 78 additions & 0 deletions
78
dbms/src/Storages/DeltaMerge/Remote/DataStore/DataStoreMock.h
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,78 @@ | ||
// 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. | ||
|
||
#pragma once | ||
|
||
#include <Encryption/FileProvider.h> | ||
#include <Storages/DeltaMerge/Remote/DataStore/DataStore.h> | ||
|
||
namespace DB::DM::Remote | ||
{ | ||
class DataStoreMock final : public IDataStore | ||
{ | ||
public: | ||
explicit DataStoreMock(FileProviderPtr file_provider_) | ||
: file_provider(file_provider_) | ||
{} | ||
|
||
~DataStoreMock() override = default; | ||
|
||
void putDMFile(DMFilePtr, const S3::DMFileOID &, bool) override | ||
{ | ||
throw Exception("DataStoreMock::putDMFile unsupported"); | ||
} | ||
|
||
IPreparedDMFileTokenPtr prepareDMFile(const S3::DMFileOID &, UInt64) override | ||
{ | ||
throw Exception("DataStoreMock::prepareDMFile unsupported"); | ||
} | ||
|
||
IPreparedDMFileTokenPtr prepareDMFileByKey(const String & remote_key) override; | ||
|
||
bool putCheckpointFiles(const PS::V3::LocalCheckpointFiles &, StoreID, UInt64) override | ||
{ | ||
throw Exception("DataStoreMock::putCheckpointFiles unsupported"); | ||
} | ||
|
||
std::unordered_map<String, DataFileInfo> getDataFilesInfo(const std::unordered_set<String> &) override | ||
{ | ||
throw Exception("DataStoreMock::getDataFilesInfo unsupported"); | ||
} | ||
|
||
void setTaggingsForKeys(const std::vector<String> &, std::string_view) override | ||
{ | ||
throw Exception("DataStoreMock::setTaggingsForKeys unsupported"); | ||
} | ||
|
||
private: | ||
FileProviderPtr file_provider; | ||
}; | ||
|
||
class MockPreparedDMFileToken : public IPreparedDMFileToken | ||
{ | ||
public: | ||
MockPreparedDMFileToken(const FileProviderPtr & file_provider_, const String & path_) | ||
: IPreparedDMFileToken::IPreparedDMFileToken(file_provider_, {}, 0) | ||
, path(path_) | ||
{} | ||
|
||
~MockPreparedDMFileToken() override = default; | ||
|
||
DMFilePtr restore(DMFile::ReadMetaMode read_mode) override; | ||
|
||
private: | ||
String path; | ||
}; | ||
|
||
} // namespace DB::DM::Remote |
Oops, something went wrong.