client_reader.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include <yt/cpp/mapreduce/common/fwd.h>
  3. #include <yt/cpp/mapreduce/interface/io.h>
  4. #include <yt/cpp/mapreduce/http/context.h>
  5. #include <yt/cpp/mapreduce/http/requests.h>
  6. #include <yt/cpp/mapreduce/http/http.h>
  7. #include <yt/cpp/mapreduce/http/http_client.h>
  8. namespace NYT {
  9. class TPingableTransaction;
  10. ////////////////////////////////////////////////////////////////////////////////
  11. class TClientReader
  12. : public TRawTableReader
  13. {
  14. public:
  15. TClientReader(
  16. const TRichYPath& path,
  17. IClientRetryPolicyPtr clientRetryPolicy,
  18. ITransactionPingerPtr transactionPinger,
  19. const TClientContext& context,
  20. const TTransactionId& transactionId,
  21. const TFormat& format,
  22. const TTableReaderOptions& options,
  23. bool useFormatFromTableAttributes);
  24. bool Retry(
  25. const TMaybe<ui32>& rangeIndex,
  26. const TMaybe<ui64>& rowIndex,
  27. const std::exception_ptr& error) override;
  28. void ResetRetries() override;
  29. bool HasRangeIndices() const override { return true; }
  30. protected:
  31. size_t DoRead(void* buf, size_t len) override;
  32. private:
  33. TRichYPath Path_;
  34. const IClientRetryPolicyPtr ClientRetryPolicy_;
  35. const TClientContext Context_;
  36. TTransactionId ParentTransactionId_;
  37. TMaybe<TFormat> Format_;
  38. TTableReaderOptions Options_;
  39. THolder<TPingableTransaction> ReadTransaction_;
  40. NHttpClient::IHttpResponsePtr Response_;
  41. IInputStream* Input_;
  42. IRequestRetryPolicyPtr CurrentRequestRetryPolicy_;
  43. private:
  44. void TransformYPath();
  45. void CreateRequest(const TMaybe<ui32>& rangeIndex = Nothing(), const TMaybe<ui64>& rowIndex = Nothing());
  46. };
  47. ////////////////////////////////////////////////////////////////////////////////
  48. } // namespace NYT