diff options
author | dinmukhammed <dinmukhammed@yandex-team.ru> | 2022-02-21 23:56:09 +0300 |
---|---|---|
committer | dinmukhammed <dinmukhammed@yandex-team.ru> | 2022-02-21 23:56:09 +0300 |
commit | 373e00550f38138adbb0a26791fbbd4406434952 (patch) | |
tree | 44566e500e98b2a27e5dd0e151109eda6d1b8010 | |
parent | dbd0284ce8fa6dbab04240681dc8030b27c925a5 (diff) | |
download | ydb-373e00550f38138adbb0a26791fbbd4406434952.tar.gz |
YQ-895 UrlBuilder for S3 listing queries
added UrlBuilder for s3 io discovery
ref:f84856c5602392f63b018cd4cdc4f2e19e15072f
-rw-r--r-- | ydb/library/yql/providers/s3/provider/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ydb/library/yql/providers/s3/provider/ya.make | 1 | ||||
-rw-r--r-- | ydb/library/yql/providers/s3/provider/yql_s3_io_discovery.cpp | 14 | ||||
-rw-r--r-- | ydb/library/yql/utils/url_builder.cpp | 2 | ||||
-rw-r--r-- | ydb/library/yql/utils/url_builder_ut.cpp | 4 |
5 files changed, 17 insertions, 5 deletions
diff --git a/ydb/library/yql/providers/s3/provider/CMakeLists.txt b/ydb/library/yql/providers/s3/provider/CMakeLists.txt index 013f4ed3ad..3fc5161c93 100644 --- a/ydb/library/yql/providers/s3/provider/CMakeLists.txt +++ b/ydb/library/yql/providers/s3/provider/CMakeLists.txt @@ -35,6 +35,7 @@ target_link_libraries(providers-s3-provider PUBLIC providers-result-expr_nodes providers-s3-expr_nodes providers-s3-proto + library-yql-utils ) target_sources(providers-s3-provider PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/yql/providers/s3/provider/yql_s3_datasink.cpp diff --git a/ydb/library/yql/providers/s3/provider/ya.make b/ydb/library/yql/providers/s3/provider/ya.make index 54f3cd0706..4e116529a9 100644 --- a/ydb/library/yql/providers/s3/provider/ya.make +++ b/ydb/library/yql/providers/s3/provider/ya.make @@ -52,6 +52,7 @@ PEERDIR( ydb/library/yql/providers/result/expr_nodes ydb/library/yql/providers/s3/expr_nodes ydb/library/yql/providers/s3/proto + ydb/library/yql/utils ) YQL_LAST_ABI_VERSION() diff --git a/ydb/library/yql/providers/s3/provider/yql_s3_io_discovery.cpp b/ydb/library/yql/providers/s3/provider/yql_s3_io_discovery.cpp index 0b519984c7..4518bb2469 100644 --- a/ydb/library/yql/providers/s3/provider/yql_s3_io_discovery.cpp +++ b/ydb/library/yql/providers/s3/provider/yql_s3_io_discovery.cpp @@ -3,6 +3,7 @@ #include <ydb/library/yql/providers/s3/expr_nodes/yql_s3_expr_nodes.h> #include <ydb/library/yql/core/yql_expr_optimize.h> #include <ydb/library/yql/utils/log/log.h> +#include <ydb/library/yql/utils/url_builder.h> #include <util/generic/size_literals.h> @@ -85,8 +86,14 @@ void OnDiscovery( IHTTPGateway::THeaders headers; if (const auto& token = std::get<2U>(keys); !token.empty()) headers.emplace_back(token); + + TUrlBuilder urlBuilder(std::get<0U>(keys)); + urlBuilder.AddUrlParam("list-type", "2"); + urlBuilder.AddUrlParam("prefix", prefix); + urlBuilder.AddUrlParam("continuation-token", next); + urlBuilder.AddUrlParam("max-keys", maxKeys); return g->Download( - std::get<0U>(keys) + "?list-type=2&prefix=" + prefix + "&continuation-token=" + next + "&max-keys=" + maxKeys, + urlBuilder.Build(), std::move(headers), 0U, std::bind(&OnDiscovery, gateway, pos, std::placeholders::_1, std::cref(keys), std::ref(output), std::move(promise), pendingBucketsWPtr, promiseInd, retryPolicy), @@ -215,8 +222,11 @@ public: if (const auto& token = std::get<2U>(bucket.first); !token.empty()) headers.emplace_back(token); std::weak_ptr<TPendingBuckets> pendingBucketsWPtr = PendingBuckets_; + TUrlBuilder urlBuilder(std::get<0U>(bucket.first)); + urlBuilder.AddUrlParam("list-type", "2"); + urlBuilder.AddUrlParam("prefix", prefix); Gateway_->Download( - std::get<0U>(bucket.first) + "?list-type=2&prefix=" + prefix, + urlBuilder.Build(), headers, 0U, std::bind(&OnDiscovery, diff --git a/ydb/library/yql/utils/url_builder.cpp b/ydb/library/yql/utils/url_builder.cpp index 9ed5e6f0c3..733c616dab 100644 --- a/ydb/library/yql/utils/url_builder.cpp +++ b/ydb/library/yql/utils/url_builder.cpp @@ -13,7 +13,7 @@ void TUrlBuilder::AddUrlParam(const TString& name, const TString& value) { } TString TUrlBuilder::Build() const { - TString res = MainUri; + TString res = MainUri + "?"; for (size_t i = 0; i < Params.size(); ++i) { res += TStringBuilder() << (i > 0 ? "&" : "") << Params[i].Name << "=" << CGIEscapeRet(Params[i].Value); } diff --git a/ydb/library/yql/utils/url_builder_ut.cpp b/ydb/library/yql/utils/url_builder_ut.cpp index 5cb3316b3d..22a15e85e6 100644 --- a/ydb/library/yql/utils/url_builder_ut.cpp +++ b/ydb/library/yql/utils/url_builder_ut.cpp @@ -6,7 +6,7 @@ using namespace NYql; Y_UNIT_TEST_SUITE(TUrlBuilder) { Y_UNIT_TEST(Basic) { - TUrlBuilder builder("https://localhost/abc?"); + TUrlBuilder builder("https://localhost/abc"); builder.AddUrlParam("param1", "val1"); builder.AddUrlParam("param2", "val2"); @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TUrlBuilder) { } Y_UNIT_TEST(Test1) { - TUrlBuilder builder("https://localhost/abc?"); + TUrlBuilder builder("https://localhost/abc"); builder.AddUrlParam("param1", "=!@#$%^&*(){}[]\" "); builder.AddUrlParam("param2", "val2"); |