client_writer.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "client_writer.h"
  2. #include "retryful_writer.h"
  3. #include "retryless_writer.h"
  4. #include <yt/cpp/mapreduce/interface/io.h>
  5. #include <yt/cpp/mapreduce/common/fwd.h>
  6. #include <yt/cpp/mapreduce/common/helpers.h>
  7. namespace NYT {
  8. ////////////////////////////////////////////////////////////////////////////////
  9. TClientWriter::TClientWriter(
  10. const TRichYPath& path,
  11. IClientRetryPolicyPtr clientRetryPolicy,
  12. ITransactionPingerPtr transactionPinger,
  13. const TClientContext& context,
  14. const TTransactionId& transactionId,
  15. const TMaybe<TFormat>& format,
  16. const TTableWriterOptions& options)
  17. : BufferSize_(options.BufferSize_)
  18. {
  19. if (options.SingleHttpRequest_) {
  20. RawWriter_.Reset(new TRetrylessWriter(
  21. context,
  22. transactionId,
  23. GetWriteTableCommand(context.Config->ApiVersion),
  24. format,
  25. path,
  26. BufferSize_,
  27. options));
  28. } else {
  29. RawWriter_.Reset(new TRetryfulWriter(
  30. std::move(clientRetryPolicy),
  31. std::move(transactionPinger),
  32. context,
  33. transactionId,
  34. GetWriteTableCommand(context.Config->ApiVersion),
  35. format,
  36. path,
  37. options));
  38. }
  39. }
  40. size_t TClientWriter::GetStreamCount() const
  41. {
  42. return 1;
  43. }
  44. IOutputStream* TClientWriter::GetStream(size_t tableIndex) const
  45. {
  46. Y_UNUSED(tableIndex);
  47. return RawWriter_.Get();
  48. }
  49. void TClientWriter::OnRowFinished(size_t)
  50. {
  51. RawWriter_->NotifyRowEnd();
  52. }
  53. void TClientWriter::Abort()
  54. {
  55. RawWriter_->Abort();
  56. }
  57. size_t TClientWriter::GetBufferMemoryUsage() const
  58. {
  59. return RawWriter_->GetBufferMemoryUsage();
  60. }
  61. ////////////////////////////////////////////////////////////////////////////////
  62. } // namespace NYT