From ee8c79d40d8bcbd13ce6e479fe36851da97947ac Mon Sep 17 00:00:00 2001 From: Levi Tamasi Date: Wed, 15 Jul 2020 13:17:48 -0700 Subject: [PATCH] Turn the compression_type check in BlobDBImpl::DecompressSlice into an assertion (#7127) Summary: In both cases where `BlobDBImpl::DecompressSlice` is called, `compression_type` is already checked at the call site; thus, the check inside the method is redundant and can be turned into an assertion. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7127 Test Plan: `make check` Reviewed By: zhichao-cao Differential Revision: D22533454 Pulled By: ltamasi fbshipit-source-id: ae524443fc6abe0a5fb12327a3fe761a9cd2c831 --- utilities/blob_db/blob_db_impl.cc | 33 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/utilities/blob_db/blob_db_impl.cc b/utilities/blob_db/blob_db_impl.cc index 45a9ef6a8..79c034db7 100644 --- a/utilities/blob_db/blob_db_impl.cc +++ b/utilities/blob_db/blob_db_impl.cc @@ -1148,25 +1148,26 @@ Slice BlobDBImpl::GetCompressedSlice(const Slice& raw, Status BlobDBImpl::DecompressSlice(const Slice& compressed_value, CompressionType compression_type, PinnableSlice* value_output) const { - if (compression_type != kNoCompression) { - BlockContents contents; - auto cfh = static_cast(DefaultColumnFamily()); + assert(compression_type != kNoCompression); - { - StopWatch decompression_sw(env_, statistics_, - BLOB_DB_DECOMPRESSION_MICROS); - UncompressionContext context(compression_type); - UncompressionInfo info(context, UncompressionDict::GetEmptyDict(), - compression_type); - Status s = UncompressBlockContentsForCompressionType( - info, compressed_value.data(), compressed_value.size(), &contents, - kBlockBasedTableVersionFormat, *(cfh->cfd()->ioptions())); - if (!s.ok()) { - return Status::Corruption("Unable to decompress blob."); - } + BlockContents contents; + auto cfh = static_cast(DefaultColumnFamily()); + + { + StopWatch decompression_sw(env_, statistics_, BLOB_DB_DECOMPRESSION_MICROS); + UncompressionContext context(compression_type); + UncompressionInfo info(context, UncompressionDict::GetEmptyDict(), + compression_type); + Status s = UncompressBlockContentsForCompressionType( + info, compressed_value.data(), compressed_value.size(), &contents, + kBlockBasedTableVersionFormat, *(cfh->cfd()->ioptions())); + if (!s.ok()) { + return Status::Corruption("Unable to decompress blob."); } - value_output->PinSelf(contents.data); } + + value_output->PinSelf(contents.data); + return Status::OK(); }