From cba752d5880d13b8142bb6ab27f999d85a31893a Mon Sep 17 00:00:00 2001 From: Patrick Chan Date: Wed, 4 May 2016 00:46:24 +0900 Subject: [PATCH] sst_dump won't print size for unsupported compression type --- tools/sst_dump_tool.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/sst_dump_tool.cc b/tools/sst_dump_tool.cc index 7b4eb888c..f330af4b1 100644 --- a/tools/sst_dump_tool.cc +++ b/tools/sst_dump_tool.cc @@ -34,6 +34,7 @@ #include "table/plain_table_factory.h" #include "tools/ldb_cmd.h" #include "util/random.h" +#include "util/compression.h" #include "port/port.h" @@ -194,15 +195,19 @@ int SstFileReader::ShowAllCompressionSizes(size_t block_size) { }; for (auto& i : compressions) { - CompressionOptions compress_opt; - std::string column_family_name; - TableBuilderOptions tb_opts(imoptions, ikc, &block_based_table_factories, - i.first, compress_opt, - nullptr /* compression_dict */, - false /* skip_filters */, column_family_name); - uint64_t file_size = CalculateCompressedTableSize(tb_opts, block_size); - fprintf(stdout, "Compression: %s", i.second); - fprintf(stdout, " Size: %" PRIu64 "\n", file_size); + if (CompressionTypeSupported(i.first)) { + CompressionOptions compress_opt; + std::string column_family_name; + TableBuilderOptions tb_opts(imoptions, ikc, &block_based_table_factories, + i.first, compress_opt, + nullptr /* compression_dict */, + false /* skip_filters */, column_family_name); + uint64_t file_size = CalculateCompressedTableSize(tb_opts, block_size); + fprintf(stdout, "Compression: %s", i.second); + fprintf(stdout, " Size: %" PRIu64 "\n", file_size); + } else { + fprintf(stdout, "Unsupported compression type: %s.\n", i.second); + } } return 0; }