1 | #include <string> |
2 | |
3 | #include <iostream> |
4 | #include <fstream> |
5 | |
6 | #include <IO/ReadBufferFromFile.h> |
7 | #include <IO/WriteBufferFromFile.h> |
8 | |
9 | #include <DataTypes/DataTypesNumber.h> |
10 | #include <DataTypes/DataTypeString.h> |
11 | |
12 | #include <Processors/Formats/Impl/TabSeparatedRowInputFormat.h> |
13 | |
14 | #include <DataStreams/copyData.h> |
15 | #include <Processors/Formats/OutputStreamToOutputFormat.h> |
16 | #include <Processors/Formats/Impl/TabSeparatedRowOutputFormat.h> |
17 | #include <Processors/Formats/InputStreamFromInputFormat.h> |
18 | |
19 | |
20 | using namespace DB; |
21 | |
22 | int main(int, char **) |
23 | try |
24 | { |
25 | Block sample; |
26 | { |
27 | ColumnWithTypeAndName col; |
28 | col.type = std::make_shared<DataTypeUInt64>(); |
29 | sample.insert(std::move(col)); |
30 | } |
31 | { |
32 | ColumnWithTypeAndName col; |
33 | col.type = std::make_shared<DataTypeString>(); |
34 | sample.insert(std::move(col)); |
35 | } |
36 | |
37 | ReadBufferFromFile in_buf("test_in" ); |
38 | WriteBufferFromFile out_buf("test_out" ); |
39 | |
40 | FormatSettings format_settings; |
41 | |
42 | RowInputFormatParams params{DEFAULT_INSERT_BLOCK_SIZE, 0, 0, []{}}; |
43 | |
44 | InputFormatPtr input_format = std::make_shared<TabSeparatedRowInputFormat>(sample, in_buf, params, false, false, format_settings); |
45 | BlockInputStreamPtr block_input = std::make_shared<InputStreamFromInputFormat>(std::move(input_format)); |
46 | |
47 | BlockOutputStreamPtr block_output = std::make_shared<OutputStreamToOutputFormat>( |
48 | std::make_shared<TabSeparatedRowOutputFormat>(out_buf, sample, false, false, [] {}, format_settings)); |
49 | |
50 | copyData(*block_input, *block_output); |
51 | return 0; |
52 | } |
53 | catch (...) |
54 | { |
55 | std::cerr << getCurrentExceptionMessage(true) << '\n'; |
56 | return 1; |
57 | } |
58 | |