-
Notifications
You must be signed in to change notification settings - Fork 568
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
YQ-3697 Add partition count to dqrun #9837
base: main
Are you sure you want to change the base?
Changes from 1 commit
c48c2c3
bf1a24a
a613212
f26fd4a
0a2434d
27e6452
4e32bec
cc6719f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
#include <library/cpp/threading/blocking_queue/blocking_queue.h> | ||
#include <library/cpp/threading/future/async.h> | ||
|
||
#include <util/folder/path.h> | ||
#include <util/system/file.h> | ||
|
||
namespace NYql { | ||
|
@@ -214,18 +215,26 @@ struct TDummyPartitionSession: public NYdb::NTopic::TPartitionSession { | |
std::shared_ptr<NYdb::NTopic::IReadSession> TFileTopicClient::CreateReadSession(const NYdb::NTopic::TReadSessionSettings& settings) { | ||
Y_ENSURE(!settings.Topics_.empty()); | ||
TString topicPath = settings.Topics_.front().Path_; | ||
|
||
Y_ENSURE(settings.Topics_.front().PartitionIds_.size() == 1); | ||
ui64 partitionId = settings.Topics_.front().PartitionIds_.front(); | ||
auto topicsIt = Topics_.find(make_pair("pq", topicPath)); | ||
Y_ENSURE(topicsIt != Topics_.end()); | ||
auto filePath = topicsIt->second.FilePath; | ||
Y_ENSURE(filePath); | ||
|
||
// TODO | ||
ui64 sessionId = 0; | ||
ui64 partitionId = 0; | ||
Y_ENSURE(topicsIt->second.Path); | ||
|
||
TString filePath; | ||
if (TFsPath(*topicsIt->second.Path).IsDirectory()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. предлагаю положить TFsPath(*topicsIt->second.Path) в отдельную переменную, у тебя этот объект строится в двух местах There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. рекомендую *topicsIt->second.Path положить в отдельную переменную, это выражение много где встречается |
||
filePath = TString(*topicsIt->second.Path) + "/" + ToString(partitionId); | ||
} else { | ||
if (TFsPath(*topicsIt->second.Path).Exists() && topicsIt->second.PartitionsCount == 1) { | ||
filePath = *topicsIt->second.Path; | ||
} else { | ||
filePath = TString(*topicsIt->second.Path) + "_" + ToString(partitionId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тут подошел бы TStringBuilder |
||
} | ||
} | ||
|
||
ui64 sessionId = 0; | ||
return std::make_shared<TFileTopicReadSession>( | ||
TFile(*filePath, EOpenMode::TEnum::RdOnly), | ||
TFile(filePath, EOpenMode::TEnum::RdOnly), | ||
MakeIntrusive<TDummyPartitionSession>(sessionId, topicPath, partitionId) | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -985,13 +985,16 @@ int RunMain(int argc, const char* argv[]) | |
auto fileGateway = MakeIntrusive<TDummyPqGateway>(); | ||
|
||
for (auto& s : pqFileList) { | ||
TStringBuf topicName, filePath; | ||
TStringBuf(s).Split('@', topicName, filePath); | ||
if (topicName.empty() || filePath.empty()) { | ||
Cerr << "Incorrect table mapping, expected form topic@file" << Endl; | ||
TStringBuf topicName, others; | ||
TStringBuf(s).Split('@', topicName, others); | ||
TStringBuf path, partitionCountStr; | ||
TStringBuf(others).Split(':', path, partitionCountStr); | ||
if (topicName.empty() || path.empty()) { | ||
Cerr << "Incorrect table mapping, expected form topic@path[:partitions_count]" << Endl; | ||
return 1; | ||
} | ||
fileGateway->AddDummyTopic(TDummyTopic("pq", TString(topicName), TString(filePath))); | ||
size_t partitionCount = !partitionCountStr.empty() ? partitionCount = FromString<size_t>(partitionCountStr) : 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. перемудрил |
||
fileGateway->AddDummyTopic(TDummyTopic("pq", TString(topicName), TString(path), partitionCount)); | ||
} | ||
pqGateway = std::move(fileGateway); | ||
} else { | ||
|
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.
чтобы уменьшить копипасту положи settings.Topics_.front() в переменную