MCPcopy Create free account
hub / github.com/apache/orc / writeCustomOrcFile

Function writeCustomOrcFile

c++/test/CreateTestFiles.cc:31–59  ·  view source on GitHub ↗

* Write an empty custom ORC file with a lot of control over format. * We use this to create files to test the reader rather than anything * that users would want to do. */

Source from the content-addressed store, hash-verified

29 * that users would want to do.
30 */
31void writeCustomOrcFile(const std::string& filename, const orc::proto::Metadata& metadata,
32 const orc::proto::Footer& footer, const std::vector<std::uint32_t>& version,
33 std::uint32_t writerVersion) {
34 std::fstream output(filename.c_str(), std::ios::out | std::ios::trunc | std::ios::binary);
35 output << "ORC";
36 if (!metadata.SerializeToOstream(&output)) {
37 std::cerr << "Failed to write metadata for " << filename << "\n";
38 exit(1);
39 }
40 if (!footer.SerializeToOstream(&output)) {
41 std::cerr << "Failed to write footer for " << filename << "\n";
42 exit(1);
43 }
44 orc::proto::PostScript ps;
45 ps.set_footer_length(static_cast<uint64_t>(footer.ByteSizeLong()));
46 ps.set_compression(orc::proto::NONE);
47 ps.set_compression_block_size(64 * 1024);
48 for (size_t i = 0; i < version.size(); ++i) {
49 ps.add_version(version[i]);
50 }
51 ps.set_metadata_length(static_cast<uint64_t>(metadata.ByteSizeLong()));
52 ps.set_writer_version(writerVersion);
53 ps.set_magic("ORC");
54 if (!ps.SerializeToOstream(&output)) {
55 std::cerr << "Failed to write postscript for " << filename << "\n";
56 exit(1);
57 }
58 output.put(static_cast<char>(ps.ByteSizeLong()));
59}
60
61/**
62 * Create a file from a future version 19.99.

Callers 1

writeVersion1999Function · 0.85

Calls 2

putMethod · 0.80
sizeMethod · 0.65

Tested by

no test coverage detected