| 73 | |
| 74 | int mainEntryClickHouseCompressor(int argc, char ** argv); |
| 75 | int mainEntryClickHouseCompressor(int argc, char ** argv) |
| 76 | { |
| 77 | using namespace DB; |
| 78 | namespace po = boost::program_options; |
| 79 | |
| 80 | bool print_stacktrace = false; |
| 81 | |
| 82 | /// Join global-pool threads before the statics they may have accessed are destroyed. |
| 83 | /// That way, accesses happen-before destruction. |
| 84 | SCOPE_EXIT_SAFE({ |
| 85 | DB::StaticThreadPool::shutdownAll(); |
| 86 | GlobalThreadPool::shutdown(); |
| 87 | }); |
| 88 | |
| 89 | try |
| 90 | { |
| 91 | po::options_description desc = createOptionsDescription("Allowed options", getTerminalWidth()); |
| 92 | desc.add_options() |
| 93 | ("help,h", "produce help message") |
| 94 | ("input", po::value<std::string>()->value_name("INPUT"), "input file") |
| 95 | ("output", po::value<std::string>()->value_name("OUTPUT"), "output file") |
| 96 | ("decompress,d", "decompress") |
| 97 | ("offset-in-compressed-file", po::value<size_t>()->default_value(0ULL), "offset to the compressed block (i.e. physical file offset)") |
| 98 | ("offset-in-decompressed-block", po::value<size_t>()->default_value(0ULL), "offset to the decompressed block (i.e. virtual offset)") |
| 99 | ("block-size,b", po::value<size_t>()->default_value(DBMS_DEFAULT_BUFFER_SIZE), "compress in blocks of specified size") |
| 100 | ("hc", "use LZ4HC instead of LZ4") |
| 101 | ("zstd", "use ZSTD instead of LZ4") |
| 102 | ("codec", po::value<std::vector<std::string>>()->multitoken(), "use codecs combination instead of LZ4") |
| 103 | ("level", po::value<int>(), "compression level for codecs specified via flags") |
| 104 | ("threads", po::value<size_t>()->default_value(1), "number of threads for parallel compression") |
| 105 | ("none", "use no compression instead of LZ4") |
| 106 | ("no-checksum-validation", "disable checksum validation") |
| 107 | ("stat", "print block statistics of compressed data") |
| 108 | ("stacktrace", "print stacktrace of exception") |
| 109 | ; |
| 110 | |
| 111 | po::positional_options_description positional_desc; |
| 112 | positional_desc.add("input", 1); |
| 113 | positional_desc.add("output", 1); |
| 114 | |
| 115 | po::variables_map options; |
| 116 | po::store(po::command_line_parser(argc, argv).options(desc).positional(positional_desc).run(), options); |
| 117 | |
| 118 | if (options.contains("help")) |
| 119 | { |
| 120 | std::cout << "Usage: clickhouse compressor [options] < INPUT > OUTPUT" << std::endl; |
| 121 | std::cout << "Alternative usage: clickhouse compressor [options] INPUT OUTPUT" << std::endl; |
| 122 | std::cout << desc << std::endl; |
| 123 | std::cout << "\nSee also: https://clickhouse.com/docs/en/operations/utilities/clickhouse-compressor/\n"; |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | bool decompress = options.contains("decompress"); |
| 128 | bool use_lz4hc = options.contains("hc"); |
| 129 | bool use_zstd = options.contains("zstd"); |
| 130 | bool stat_mode = options.contains("stat"); |
| 131 | bool use_none = options.contains("none"); |
| 132 | print_stacktrace = options.contains("stacktrace"); |
nothing calls this directly
no test coverage detected