MCPcopy Create free account
hub / github.com/apache/arrow / ConvertToFile

Function ConvertToFile

cpp/src/arrow/ipc/stream_to_file.cc:34–50  ·  view source on GitHub ↗

Converts a stream from stdin to a file written to standard out. A typical usage would be: $ | stream-to-file > file.arrow

Source from the content-addressed store, hash-verified

32// A typical usage would be:
33// $ <program that produces streaming output> | stream-to-file > file.arrow
34Status ConvertToFile() {
35 io::StdinStream input;
36 io::StdoutStream sink;
37
38 IpcWriteOptions write_options;
39 write_options.emit_dictionary_deltas = true;
40 ARROW_ASSIGN_OR_RAISE(auto reader, RecordBatchStreamReader::Open(&input));
41 ARROW_ASSIGN_OR_RAISE(auto writer,
42 MakeFileWriter(&sink, reader->schema(), write_options));
43 std::shared_ptr<RecordBatch> batch;
44 while (true) {
45 ARROW_ASSIGN_OR_RAISE(batch, reader->Next());
46 if (batch == nullptr) break;
47 RETURN_NOT_OK(writer->WriteRecordBatch(*batch));
48 }
49 return writer->Close();
50}
51
52} // namespace ipc
53} // namespace arrow

Callers 1

mainFunction · 0.85

Calls 4

ARROW_ASSIGN_OR_RAISEFunction · 0.70
NextMethod · 0.45
WriteRecordBatchMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected