1
1
#include " adapters.h"
2
+
2
3
#include " row_batch.h"
3
4
4
5
#include < yt/yt/client/api/table_writer.h>
@@ -15,6 +16,10 @@ using namespace NCrypto;
15
16
16
17
// //////////////////////////////////////////////////////////////////////////////
17
18
19
+ const NLogging::TLogger Logger (" TableClientAdapters" );
20
+
21
+ // //////////////////////////////////////////////////////////////////////////////
22
+
18
23
class TApiFromSchemalessWriterAdapter
19
24
: public NApi::ITableWriter
20
25
{
@@ -178,7 +183,7 @@ void PipeReaderToWriterByBatches(
178
183
const NFormats::ISchemalessFormatWriterPtr& writer,
179
184
const TRowBatchReadOptions& options,
180
185
TDuration pipeDelay)
181
- {
186
+ try {
182
187
TPeriodicYielder yielder (TDuration::Seconds (1 ));
183
188
184
189
while (auto batch = reader->Read (options)) {
@@ -202,6 +207,50 @@ void PipeReaderToWriterByBatches(
202
207
203
208
WaitFor (writer->Close ())
204
209
.ThrowOnError ();
210
+ } catch (const std::exception& ex) {
211
+ YT_LOG_ERROR (ex, " PipeReaderToWriterByBatches failed" );
212
+
213
+ THROW_ERROR_EXCEPTION (ex);
214
+ }
215
+
216
+ void PipeReaderToAdaptiveWriterByBatches (
217
+ const ITableReaderPtr& reader,
218
+ const NFormats::ISchemalessFormatWriterPtr& writer,
219
+ TRowBatchReadOptions options,
220
+ TCallback<void (TRowBatchReadOptions* mutableOptions, TDuration timeForBatch)> optionsUpdater,
221
+ TDuration pipeDelay)
222
+ try {
223
+ TPeriodicYielder yielder (TDuration::Seconds (1 ));
224
+
225
+ while (auto batch = reader->Read (options)) {
226
+ yielder.TryYield ();
227
+
228
+ if (batch->IsEmpty ()) {
229
+ WaitFor (reader->GetReadyEvent ())
230
+ .ThrowOnError ();
231
+ continue ;
232
+ }
233
+
234
+ if (!batch->IsEmpty () && pipeDelay != TDuration::Zero ()) {
235
+ TDelayedExecutor::WaitForDuration (pipeDelay);
236
+ }
237
+
238
+ NProfiling::TWallTimer timer;
239
+
240
+ if (!writer->WriteBatch (batch)) {
241
+ WaitFor (writer->GetReadyEvent ())
242
+ .ThrowOnError ();
243
+ }
244
+
245
+ optionsUpdater (&options, timer.GetElapsedTime ());
246
+ }
247
+
248
+ WaitFor (writer->Close ())
249
+ .ThrowOnError ();
250
+ } catch (const std::exception& ex) {
251
+ YT_LOG_ERROR (ex, " PipeReaderToAdaptiveWriterByBatches failed" );
252
+
253
+ THROW_ERROR_EXCEPTION (ex);
205
254
}
206
255
207
256
void PipeInputToOutput (
0 commit comments