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

Function RunMain

cpp/examples/minimal_build/example.cc:35–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33namespace {
34
35Status RunMain(int argc, char** argv) {
36 const char* csv_filename = "test.csv";
37 const char* arrow_filename = "test.arrow";
38
39 std::cerr << "* Reading CSV file '" << csv_filename << "' into table" << std::endl;
40 ARROW_ASSIGN_OR_RAISE(auto input_file, arrow::io::ReadableFile::Open(csv_filename));
41 ARROW_ASSIGN_OR_RAISE(auto csv_reader, arrow::csv::TableReader::Make(
42 arrow::io::default_io_context(), input_file,
43 arrow::csv::ReadOptions::Defaults(),
44 arrow::csv::ParseOptions::Defaults(),
45 arrow::csv::ConvertOptions::Defaults()));
46 ARROW_ASSIGN_OR_RAISE(auto table, csv_reader->Read());
47
48 std::cerr << "* Read table:" << std::endl;
49 ARROW_RETURN_NOT_OK(arrow::PrettyPrint(*table, {}, &std::cerr));
50
51 std::cerr << "* Writing table into Arrow IPC file '" << arrow_filename << "'"
52 << std::endl;
53 ARROW_ASSIGN_OR_RAISE(auto output_file,
54 arrow::io::FileOutputStream::Open(arrow_filename));
55 ARROW_ASSIGN_OR_RAISE(auto batch_writer,
56 arrow::ipc::MakeFileWriter(output_file, table->schema()));
57 ARROW_RETURN_NOT_OK(batch_writer->WriteTable(*table));
58 ARROW_RETURN_NOT_OK(batch_writer->Close());
59
60#ifdef ARROW_EXAMPLE_S3_STATIC_CHECK
61 std::cerr << "* Verify S3 initializes and finalizes" << std::endl;
62 ARROW_RETURN_NOT_OK(arrow::fs::EnsureS3Initialized());
63 ARROW_RETURN_NOT_OK(arrow::fs::EnsureS3Finalized());
64#endif
65
66 return Status::OK();
67}
68
69} // namespace
70

Callers 1

mainFunction · 0.70

Calls 6

EnsureS3InitializedFunction · 0.85
EnsureS3FinalizedFunction · 0.85
PrettyPrintFunction · 0.50
OKFunction · 0.50
WriteTableMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected