MCPcopy Create free account
hub / github.com/ByConity/ByConity / mainEntryClickHouseCompressor

Function mainEntryClickHouseCompressor

programs/compressor/Compressor.cpp:64–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64int mainEntryClickHouseCompressor(int argc, char ** argv)
65{
66 using namespace DB;
67 namespace po = boost::program_options;
68
69 po::options_description desc = createOptionsDescription("Allowed options", getTerminalWidth());
70 desc.add_options()
71 ("help,h", "produce help message")
72 ("input", po::value<std::string>()->value_name("INPUT"), "input file")
73 ("output", po::value<std::string>()->value_name("OUTPUT"), "output file")
74 ("decompress,d", "decompress")
75 ("offset-in-compressed-file", po::value<size_t>()->default_value(0ULL), "offset to the compressed block (i.e. physical file offset)")
76 ("offset-in-decompressed-block", po::value<size_t>()->default_value(0ULL), "offset to the decompressed block (i.e. virtual offset)")
77 ("block-size,b", po::value<unsigned>()->default_value(DBMS_DEFAULT_BUFFER_SIZE), "compress in blocks of specified size")
78 ("hc", "use LZ4HC instead of LZ4")
79 ("zstd", "use ZSTD instead of LZ4")
80 ("codec", po::value<std::vector<std::string>>()->multitoken(), "use codecs combination instead of LZ4")
81 ("level", po::value<int>(), "compression level for codecs specified via flags")
82 ("none", "use no compression instead of LZ4")
83 ("stat", "print block statistics of compressed data")
84 ;
85
86 po::positional_options_description positional_desc;
87 positional_desc.add("input", 1);
88 positional_desc.add("output", 1);
89
90 po::variables_map options;
91 po::store(po::command_line_parser(argc, argv).options(desc).positional(positional_desc).run(), options);
92
93 if (options.count("help"))
94 {
95 std::cout << "Usage: " << argv[0] << " [options] < INPUT > OUTPUT" << std::endl;
96 std::cout << "Usage: " << argv[0] << " [options] INPUT OUTPUT" << std::endl;
97 std::cout << desc << std::endl;
98 return 0;
99 }
100
101 try
102 {
103 bool decompress = options.count("decompress");
104 bool use_lz4hc = options.count("hc");
105 bool use_zstd = options.count("zstd");
106 bool stat_mode = options.count("stat");
107 bool use_none = options.count("none");
108 unsigned block_size = options["block-size"].as<unsigned>();
109 std::vector<std::string> codecs;
110 if (options.count("codec"))
111 codecs = options["codec"].as<std::vector<std::string>>();
112
113 if ((use_lz4hc || use_zstd || use_none) && !codecs.empty())
114 throw Exception("Wrong options, codec flags like --zstd and --codec options are mutually exclusive", ErrorCodes::BAD_ARGUMENTS);
115
116 if (!codecs.empty() && options.count("level"))
117 throw Exception("Wrong options, --level is not compatible with --codec list", ErrorCodes::BAD_ARGUMENTS);
118
119 std::string method_family = "LZ4";
120
121 if (use_lz4hc)

Callers 1

mainFunction · 0.85

Calls 15

createOptionsDescriptionFunction · 0.85
getTerminalWidthFunction · 0.85
storeFunction · 0.85
parseQueryFunction · 0.85
checkAndWriteHeaderFunction · 0.85
getCurrentExceptionCodeFunction · 0.85
ExceptionClass · 0.50
joinFunction · 0.50
copyDataFunction · 0.50
addMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected