raw_requests.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include "raw_batch_request.h"
  3. #include <yt/cpp/mapreduce/common/fwd.h>
  4. #include <yt/cpp/mapreduce/http/context.h>
  5. #include <yt/cpp/mapreduce/interface/client.h>
  6. #include <yt/cpp/mapreduce/interface/client_method_options.h>
  7. #include <yt/cpp/mapreduce/interface/operation.h>
  8. #include <yt/cpp/mapreduce/interface/raw_client.h>
  9. namespace NYT {
  10. ////////////////////////////////////////////////////////////////////////////////
  11. class IRequestRetryPolicy;
  12. struct TClientContext;
  13. struct TExecuteBatchOptions;
  14. ////////////////////////////////////////////////////////////////////////////////
  15. namespace NDetail::NRawClient {
  16. ////////////////////////////////////////////////////////////////////////////////
  17. TOperationAttributes ParseOperationAttributes(const TNode& node);
  18. TJobAttributes ParseJobAttributes(const TNode& node);
  19. TCheckPermissionResponse ParseCheckPermissionResponse(const TNode& node);
  20. ////////////////////////////////////////////////////////////////////////////////
  21. TRichYPath CanonizeYPath(
  22. const IRawClientPtr& rawClient,
  23. const TRichYPath& path);
  24. TVector<TRichYPath> CanonizeYPaths(
  25. const IRawClientPtr& rawClient,
  26. const TVector<TRichYPath>& paths);
  27. NHttpClient::IHttpResponsePtr SkyShareTable(
  28. const TClientContext& context,
  29. const std::vector<TYPath>& tablePaths,
  30. const TSkyShareTableOptions& options);
  31. TAuthorizationInfo WhoAmI(const TClientContext& context);
  32. ////////////////////////////////////////////////////////////////////////////////
  33. template<typename TSrc, typename TBatchAdder>
  34. auto BatchTransform(
  35. const IRawClientPtr& rawClient,
  36. const TSrc& src,
  37. TBatchAdder batchAdder,
  38. const TExecuteBatchOptions& executeBatchOptions = {})
  39. {
  40. auto batch = rawClient->CreateRawBatchRequest();
  41. using TFuture = decltype(batchAdder(batch, *std::begin(src)));
  42. TVector<TFuture> futures;
  43. for (const auto& el : src) {
  44. futures.push_back(batchAdder(batch, el));
  45. }
  46. batch->ExecuteBatch(executeBatchOptions);
  47. using TDst = decltype(futures[0].ExtractValueSync());
  48. TVector<TDst> result;
  49. result.reserve(std::size(src));
  50. for (auto& future : futures) {
  51. result.push_back(future.ExtractValueSync());
  52. }
  53. return result;
  54. }
  55. ////////////////////////////////////////////////////////////////////////////////
  56. } // namespace NDetail::NRawClient
  57. } // namespace NYT