client_reader.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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) override;
  27. void ResetRetries() override;
  28. bool HasRangeIndices() const override { return true; }
  29. protected:
  30. size_t DoRead(void* buf, size_t len) override;
  31. private:
  32. TRichYPath Path_;
  33. const IClientRetryPolicyPtr ClientRetryPolicy_;
  34. const TClientContext Context_;
  35. TTransactionId ParentTransactionId_;
  36. TMaybe<TFormat> Format_;
  37. TTableReaderOptions Options_;
  38. THolder<TPingableTransaction> ReadTransaction_;
  39. NHttpClient::IHttpResponsePtr Response_;
  40. IInputStream* Input_;
  41. IRequestRetryPolicyPtr CurrentRequestRetryPolicy_;
  42. private:
  43. void TransformYPath();
  44. void CreateRequest(const TMaybe<ui32>& rangeIndex = Nothing(), const TMaybe<ui64>& rowIndex = Nothing());
  45. };
  46. ////////////////////////////////////////////////////////////////////////////////
  47. } // namespace NYT