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

Function DoMain

cpp/src/arrow/ipc/generate_fuzz_corpus.cc:121–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121Status DoMain(bool is_stream_format, const std::string& out_dir) {
122 ARROW_ASSIGN_OR_RAISE(auto dir_fn, PlatformFilename::FromString(out_dir));
123 RETURN_NOT_OK(CreateDir(dir_fn));
124
125 int sample_num = 1;
126 auto sample_name = [&]() -> std::string {
127 return "batch-" + std::to_string(sample_num++);
128 };
129
130 // codec 0 is uncompressed
131 std::vector<std::shared_ptr<util::Codec>> codecs(3, nullptr);
132 ARROW_ASSIGN_OR_RAISE(codecs[1], util::Codec::Create(Compression::LZ4_FRAME));
133 ARROW_ASSIGN_OR_RAISE(codecs[2], util::Codec::Create(Compression::ZSTD));
134
135 ARROW_ASSIGN_OR_RAISE(auto batches, Batches());
136
137 // Emit a separate file for each (batch, codec) pair
138 for (const auto& batch : batches) {
139 RETURN_NOT_OK(batch->ValidateFull());
140 for (const auto& codec : codecs) {
141 IpcWriteOptions options = IpcWriteOptions::Defaults();
142 options.codec = codec;
143 ARROW_ASSIGN_OR_RAISE(auto buf,
144 SerializeRecordBatch(batch, options, is_stream_format));
145 ARROW_ASSIGN_OR_RAISE(auto sample_fn, dir_fn.Join(sample_name()));
146 std::cerr << sample_fn.ToString() << std::endl;
147 ARROW_ASSIGN_OR_RAISE(auto file, io::FileOutputStream::Open(sample_fn.ToString()));
148 RETURN_NOT_OK(file->Write(buf));
149 RETURN_NOT_OK(file->Close());
150 }
151 }
152 return Status::OK();
153}
154
155ARROW_NORETURN void Usage() {
156 std::cerr << "Usage: arrow-ipc-generate-fuzz-corpus "

Callers 1

MainFunction · 0.70

Calls 9

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

Tested by

no test coverage detected