Skip to content

Commit

Permalink
Merge 00816fc into 52d9c30
Browse files Browse the repository at this point in the history
  • Loading branch information
evanevanevanevannnn authored Aug 15, 2024
2 parents 52d9c30 + 00816fc commit 998e11e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 96 deletions.
2 changes: 1 addition & 1 deletion ydb/library/yql/providers/s3/actors/yql_s3_read_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ std::pair<NYql::NDq::IDqComputeActorAsyncInput*, IActor*> CreateS3ReadActor(
const IFunctionRegistry& functionRegistry = *holderFactory.GetFunctionRegistry();

TPathList paths;
ReadPathsList(params, taskParams, readRanges, paths);
ReadPathsList(taskParams, readRanges, paths);

const auto token = secureParams.Value(params.GetToken(), TString{});
const TS3Credentials credentials(credentialsFactory, token);
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/yql/providers/s3/proto/source.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message TPath {
message TSource {
string Url = 1;
string Token = 2;
repeated TPath DeprecatedPath = 3; // deprecated
reserved 3;
optional string RowType = 4;
optional string Format = 5;
map<string, string> Settings = 6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class TS3DqIntegration: public TDqIntegrationBase {
range.Save(&out);

paths.clear();
ReadPathsList(srcDesc, {}, serialized, paths);
ReadPathsList({}, serialized, paths);

const NDq::TS3ReadActorFactoryConfig& readActorConfig = State_->Configuration->S3ReadActorFactoryConfig;
ui64 fileSizeLimit = readActorConfig.FileSizeLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(S3FileTreeBuilderTest) {
b.Save(&range);

TPathList paths;
ReadPathsList({}, MakeParams(range), {}, paths);
ReadPathsList(MakeParams(range), {}, paths);

UNIT_ASSERT_VALUES_EQUAL(paths.size(), 1);
UNIT_ASSERT_VALUES_EQUAL(paths[0].Path, "name");
Expand All @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(S3FileTreeBuilderTest) {
b.Save(&range);

TPathList paths;
ReadPathsList({}, MakeParams(range), {}, paths);
ReadPathsList(MakeParams(range), {}, paths);

UNIT_ASSERT_VALUES_EQUAL(paths.size(), 1);
UNIT_ASSERT_VALUES_EQUAL(paths[0].Path, "a///b");
Expand All @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(S3FileTreeBuilderTest) {
b.Save(&range);

TPathList paths;
ReadPathsList({}, MakeParams(range), {}, paths);
ReadPathsList(MakeParams(range), {}, paths);

UNIT_ASSERT_VALUES_EQUAL(paths.size(), 2);
UNIT_ASSERT_VALUES_EQUAL(paths[0].Path, "root/name/");
Expand All @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(S3FileTreeBuilderTest) {
b.Save(&range);

TPathList paths;
ReadPathsList({}, MakeParams(range), {}, paths);
ReadPathsList(MakeParams(range), {}, paths);

UNIT_ASSERT_VALUES_EQUAL(paths.size(), 2);

Expand All @@ -190,7 +190,7 @@ Y_UNIT_TEST_SUITE(S3FileTreeBuilderTest) {
b.Save(&range);

TPathList paths;
ReadPathsList({}, MakeParams(range), {}, paths);
ReadPathsList(MakeParams(range), {}, paths);

UNIT_ASSERT_VALUES_EQUAL(paths.size(), 3);

Expand Down
28 changes: 4 additions & 24 deletions ydb/library/yql/providers/s3/range_helpers/path_list_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void BuildPathsFromTree(const google::protobuf::RepeatedPtrField<NYql::NS
BuildPathsFromTree(children, paths, currentPath, currentDepth, nextPathIndex);
}

void DecodeS3Range(const NS3::TSource& sourceDesc, const TString& data, TPathList& paths) {
void DecodeS3Range(const TString& data, TPathList& paths) {
NS3::TRange range;
TStringInput input(data);
range.Load(&input);
Expand All @@ -49,35 +49,15 @@ void DecodeS3Range(const NS3::TSource& sourceDesc, const TString& data, TPathLis
TString buf;
return BuildPathsFromTree(range.GetPaths(), paths, buf, 0, startPathIndex);
}

std::unordered_map<TString, size_t> map(sourceDesc.GetDeprecatedPath().size());
for (auto i = 0; i < sourceDesc.GetDeprecatedPath().size(); ++i) {
map.emplace(sourceDesc.GetDeprecatedPath().Get(i).GetPath(), sourceDesc.GetDeprecatedPath().Get(i).GetSize());
}

for (auto i = 0; i < range.GetDeprecatedPath().size(); ++i) {
const auto& path = range.GetDeprecatedPath().Get(i);
auto it = map.find(path);
YQL_ENSURE(it != map.end());
paths.emplace_back(TPath{path, it->second, false, i + startPathIndex});
}
}

void ReadPathsList(const NS3::TSource& sourceDesc, const THashMap<TString, TString>& taskParams, const TVector<TString>& readRanges, TPathList& paths) {
void ReadPathsList(const THashMap<TString, TString>& taskParams, const TVector<TString>& readRanges, TPathList& paths) {
if (!readRanges.empty()) {
for (auto readRange : readRanges) {
DecodeS3Range(sourceDesc, readRange, paths);
DecodeS3Range(readRange, paths);
}
} else if (const auto taskParamsIt = taskParams.find(S3ProviderName); taskParamsIt != taskParams.cend()) {
DecodeS3Range(sourceDesc, taskParamsIt->second, paths);
} else {
for (auto i = 0; i < sourceDesc.GetDeprecatedPath().size(); ++i) {
paths.emplace_back(TPath{
sourceDesc.GetDeprecatedPath().Get(i).GetPath(),
sourceDesc.GetDeprecatedPath().Get(i).GetSize(),
false,
static_cast<ui64>(i)});
}
DecodeS3Range(taskParamsIt->second, paths);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct TPath {
};
using TPathList = std::vector<TPath>;

void ReadPathsList(const NS3::TSource& sourceDesc, const THashMap<TString, TString>& taskParams, const TVector<TString>& readRanges, TPathList& paths);
void ReadPathsList(const THashMap<TString, TString>& taskParams, const TVector<TString>& readRanges, TPathList& paths);

void PackPathsList(const TPathList& paths, TString& packed, bool& isTextEncoded);
void UnpackPathsList(TStringBuf packed, bool isTextEncoded, TPathList& paths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,6 @@ Y_UNIT_TEST_SUITE(PathListReaderTest) {
return map;
}

Y_UNIT_TEST(ReadsFilesListFromSourceSettings) {
NS3::TSource src;
{
auto* p = src.AddDeprecatedPath();
p->SetPath("my/path");
p->SetSize(100500);
}
{
auto* p = src.AddDeprecatedPath();
p->SetPath("other/path");
p->SetSize(1);
}

TPathList paths;
ReadPathsList(src, {}, {}, paths);

UNIT_ASSERT_VALUES_EQUAL(paths.size(), 2);

UNIT_ASSERT_VALUES_EQUAL(paths[0].Path, "my/path");
UNIT_ASSERT_VALUES_EQUAL(paths[0].Size, 100500);
UNIT_ASSERT_VALUES_EQUAL(paths[0].IsDirectory, false);
UNIT_ASSERT_VALUES_EQUAL(paths[0].PathIndex, 0);

UNIT_ASSERT_VALUES_EQUAL(paths[1].Path, "other/path");
UNIT_ASSERT_VALUES_EQUAL(paths[1].Size, 1);
UNIT_ASSERT_VALUES_EQUAL(paths[1].IsDirectory, false);
UNIT_ASSERT_VALUES_EQUAL(paths[1].PathIndex, 1);
}

Y_UNIT_TEST(ReadsFilesListFromParamsAndSourceSettings) {
NS3::TSource src;
{
auto* p = src.AddDeprecatedPath();
p->SetPath("my/path");
p->SetSize(100500);
}
{
auto* p = src.AddDeprecatedPath();
p->SetPath("other/path");
p->SetSize(1);
}

NS3::TRange range;
range.SetStartPathIndex(42);
range.AddDeprecatedPath("my/path");

TPathList paths;
ReadPathsList(src, MakeParams(range), {}, paths);

UNIT_ASSERT_VALUES_EQUAL(paths.size(), 1);

UNIT_ASSERT_VALUES_EQUAL(paths[0].Path, "my/path");
UNIT_ASSERT_VALUES_EQUAL(paths[0].Size, 100500);
UNIT_ASSERT_VALUES_EQUAL(paths[0].IsDirectory, false);
UNIT_ASSERT_VALUES_EQUAL(paths[0].PathIndex, 42);
}

NYql::NS3::TRange::TPath* SetPath(NYql::NS3::TRange::TPath* path, const TString& name = {}, ui64 size = 0, bool read = false) {
path->SetName(name);
path->SetSize(size);
Expand All @@ -84,11 +27,6 @@ Y_UNIT_TEST_SUITE(PathListReaderTest) {

Y_UNIT_TEST(ReadsFilesListFromTreeParams) {
NS3::TSource src;
{
auto* p = src.AddDeprecatedPath();
p->SetPath("my/path");
p->SetSize(100500);
}

NS3::TRange range;
range.SetStartPathIndex(42);
Expand All @@ -110,7 +48,7 @@ Y_UNIT_TEST_SUITE(PathListReaderTest) {
}

TPathList paths;
ReadPathsList(src, MakeParams(range), {}, paths);
ReadPathsList(MakeParams(range), {}, paths);

UNIT_ASSERT_VALUES_EQUAL(paths.size(), 5);

Expand Down

0 comments on commit 998e11e

Please sign in to comment.