retryful_writer_v2.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <library/cpp/threading/future/core/future.h>
  3. #include <yt/cpp/mapreduce/client/transaction.h>
  4. #include <yt/cpp/mapreduce/common/fwd.h>
  5. #include <yt/cpp/mapreduce/http/context.h>
  6. #include <yt/cpp/mapreduce/interface/io.h>
  7. #include <util/generic/size_literals.h>
  8. namespace NYT::NPrivate {
  9. ////////////////////////////////////////////////////////////////////////////////
  10. class TRetryfulWriterV2
  11. : public TRawTableWriter
  12. {
  13. public:
  14. TRetryfulWriterV2(
  15. IClientRetryPolicyPtr clientRetryPolicy,
  16. ITransactionPingerPtr transactionPinger,
  17. const TClientContext& context,
  18. const TTransactionId& parentId,
  19. const TString& command,
  20. const TMaybe<TFormat>& format,
  21. const TRichYPath& path,
  22. const TNode& serializedWriterOptions,
  23. ssize_t bufferSize,
  24. bool createTranasaction);
  25. void NotifyRowEnd() override;
  26. void Abort() override;
  27. size_t GetBufferMemoryUsage() const override;
  28. protected:
  29. void DoWrite(const void* buf, size_t len) override;
  30. void DoFinish() override;
  31. void DoStartBatch();
  32. private:
  33. class TSentBuffer;
  34. class TSender;
  35. struct TSendTask;
  36. const ssize_t BufferSize_;
  37. const ssize_t SendStep_ = 64_KB;
  38. ssize_t NextSizeToSend_;
  39. THolder<TSender> Sender_;
  40. THolder<TPingableTransaction> WriteTransaction_;
  41. THolder<TSendTask> Current_;
  42. THolder<TSendTask> Previous_;
  43. };
  44. ////////////////////////////////////////////////////////////////////////////////
  45. } // namespace NYT::NPrivate