blob: fe31eb55431b9f926d02e80c97967d08040adc6d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include "yamr_table_writer.h"
#include <yt/cpp/mapreduce/interface/io.h>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
TYaMRTableWriter::TYaMRTableWriter(THolder<IProxyOutput> output)
: Output_(std::move(output))
{ }
TYaMRTableWriter::~TYaMRTableWriter()
{ }
size_t TYaMRTableWriter::GetBufferMemoryUsage() const
{
return Output_->GetBufferMemoryUsage();
}
size_t TYaMRTableWriter::GetTableCount() const
{
return Output_->GetStreamCount();
}
void TYaMRTableWriter::FinishTable(size_t tableIndex) {
Output_->GetStream(tableIndex)->Finish();
}
void TYaMRTableWriter::AddRow(const TYaMRRow& row, size_t tableIndex)
{
auto* stream = Output_->GetStream(tableIndex);
auto writeField = [&stream] (const TStringBuf& field) {
i32 length = static_cast<i32>(field.length());
stream->Write(&length, sizeof(length));
stream->Write(field.data(), field.length());
};
writeField(row.Key);
writeField(row.SubKey);
writeField(row.Value);
Output_->OnRowFinished(tableIndex);
}
void TYaMRTableWriter::AddRow(TYaMRRow&& row, size_t tableIndex) {
TYaMRTableWriter::AddRow(row, tableIndex);
}
void TYaMRTableWriter::Abort()
{
Output_->Abort();
}
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
|