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
main
Levi Tamasi 4 years ago committed by Facebook GitHub Bot
parent afb6bb1df2
commit ee8c79d40d
  1. 33
      utilities/blob_db/blob_db_impl.cc

@ -1148,25 +1148,26 @@ Slice BlobDBImpl::GetCompressedSlice(const Slice& raw,
Status BlobDBImpl::DecompressSlice(const Slice& compressed_value, Status BlobDBImpl::DecompressSlice(const Slice& compressed_value,
CompressionType compression_type, CompressionType compression_type,
PinnableSlice* value_output) const { PinnableSlice* value_output) const {
if (compression_type != kNoCompression) { assert(compression_type != kNoCompression);
BlockContents contents;
auto cfh = static_cast<ColumnFamilyHandleImpl*>(DefaultColumnFamily());
{ BlockContents contents;
StopWatch decompression_sw(env_, statistics_, auto cfh = static_cast<ColumnFamilyHandleImpl*>(DefaultColumnFamily());
BLOB_DB_DECOMPRESSION_MICROS);
UncompressionContext context(compression_type); {
UncompressionInfo info(context, UncompressionDict::GetEmptyDict(), StopWatch decompression_sw(env_, statistics_, BLOB_DB_DECOMPRESSION_MICROS);
compression_type); UncompressionContext context(compression_type);
Status s = UncompressBlockContentsForCompressionType( UncompressionInfo info(context, UncompressionDict::GetEmptyDict(),
info, compressed_value.data(), compressed_value.size(), &contents, compression_type);
kBlockBasedTableVersionFormat, *(cfh->cfd()->ioptions())); Status s = UncompressBlockContentsForCompressionType(
if (!s.ok()) { info, compressed_value.data(), compressed_value.size(), &contents,
return Status::Corruption("Unable to decompress blob."); 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(); return Status::OK();
} }

Loading…
Cancel
Save