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

Function DoMain

cpp/src/arrow/csv/generate_fuzz_corpus.cc:155–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155Status DoMain(const std::string& out_dir) {
156 ARROW_ASSIGN_OR_RAISE(auto dir_fn, PlatformFilename::FromString(out_dir));
157 RETURN_NOT_OK(CreateDir(dir_fn));
158
159 int sample_num = 1;
160 auto sample_name = [&]() -> std::string {
161 return "csv-file-" + std::to_string(sample_num++);
162 };
163
164 ARROW_ASSIGN_OR_RAISE(auto batches, Batches());
165
166 auto options = WriteOptions::Defaults();
167 RETURN_NOT_OK(options.Validate());
168
169 for (const auto& batch : batches) {
170 RETURN_NOT_OK(batch->ValidateFull());
171 ARROW_ASSIGN_OR_RAISE(auto buffer, WriteRecordBatch(batch, options));
172
173 ARROW_ASSIGN_OR_RAISE(auto sample_fn, dir_fn.Join(sample_name()));
174 std::cerr << sample_fn.ToString() << std::endl;
175 ARROW_ASSIGN_OR_RAISE(auto file, io::FileOutputStream::Open(sample_fn.ToString()));
176 RETURN_NOT_OK(file->Write(buffer));
177 RETURN_NOT_OK(file->Close());
178 }
179 return Status::OK();
180}
181
182ARROW_NORETURN void Usage() {
183 std::cerr << "Usage: arrow-csv-generate-fuzz-corpus "

Callers 1

MainFunction · 0.70

Calls 9

to_stringFunction · 0.85
CreateDirFunction · 0.50
DefaultsFunction · 0.50
OKFunction · 0.50
ValidateMethod · 0.45
ValidateFullMethod · 0.45
ToStringMethod · 0.45
WriteMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected