|
|
@ -267,7 +267,8 @@ Status ReadBlockContents(RandomAccessFile* file, const Footer& footer, |
|
|
|
char* used_buf = nullptr; |
|
|
|
char* used_buf = nullptr; |
|
|
|
rocksdb::CompressionType compression_type; |
|
|
|
rocksdb::CompressionType compression_type; |
|
|
|
|
|
|
|
|
|
|
|
if (decompression_requested && n + kBlockTrailerSize < DefaultStackBufferSize) { |
|
|
|
if (decompression_requested && |
|
|
|
|
|
|
|
n + kBlockTrailerSize < DefaultStackBufferSize) { |
|
|
|
// If we've got a small enough hunk of data, read it in to the
|
|
|
|
// If we've got a small enough hunk of data, read it in to the
|
|
|
|
// trivially allocated stack buffer instead of needing a full malloc()
|
|
|
|
// trivially allocated stack buffer instead of needing a full malloc()
|
|
|
|
used_buf = &stack_buf[0]; |
|
|
|
used_buf = &stack_buf[0]; |
|
|
@ -331,40 +332,48 @@ Status UncompressBlockContents(const char* data, size_t n, |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case kZlibCompression: |
|
|
|
case kZlibCompression: |
|
|
|
ubuf = std::unique_ptr<char[]>(port::Zlib_Uncompress(data, n, &decompress_size)); |
|
|
|
ubuf = std::unique_ptr<char[]>( |
|
|
|
|
|
|
|
port::Zlib_Uncompress(data, n, &decompress_size)); |
|
|
|
static char zlib_corrupt_msg[] = |
|
|
|
static char zlib_corrupt_msg[] = |
|
|
|
"Zlib not supported or corrupted Zlib compressed block contents"; |
|
|
|
"Zlib not supported or corrupted Zlib compressed block contents"; |
|
|
|
if (!ubuf) { |
|
|
|
if (!ubuf) { |
|
|
|
return Status::Corruption(zlib_corrupt_msg); |
|
|
|
return Status::Corruption(zlib_corrupt_msg); |
|
|
|
} |
|
|
|
} |
|
|
|
*contents = BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); |
|
|
|
*contents = |
|
|
|
|
|
|
|
BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case kBZip2Compression: |
|
|
|
case kBZip2Compression: |
|
|
|
ubuf = std::unique_ptr<char[]>(port::BZip2_Uncompress(data, n, &decompress_size)); |
|
|
|
ubuf = std::unique_ptr<char[]>( |
|
|
|
|
|
|
|
port::BZip2_Uncompress(data, n, &decompress_size)); |
|
|
|
static char bzip2_corrupt_msg[] = |
|
|
|
static char bzip2_corrupt_msg[] = |
|
|
|
"Bzip2 not supported or corrupted Bzip2 compressed block contents"; |
|
|
|
"Bzip2 not supported or corrupted Bzip2 compressed block contents"; |
|
|
|
if (!ubuf) { |
|
|
|
if (!ubuf) { |
|
|
|
return Status::Corruption(bzip2_corrupt_msg); |
|
|
|
return Status::Corruption(bzip2_corrupt_msg); |
|
|
|
} |
|
|
|
} |
|
|
|
*contents = BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); |
|
|
|
*contents = |
|
|
|
|
|
|
|
BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case kLZ4Compression: |
|
|
|
case kLZ4Compression: |
|
|
|
ubuf = std::unique_ptr<char[]>(port::LZ4_Uncompress(data, n, &decompress_size)); |
|
|
|
ubuf = std::unique_ptr<char[]>( |
|
|
|
|
|
|
|
port::LZ4_Uncompress(data, n, &decompress_size)); |
|
|
|
static char lz4_corrupt_msg[] = |
|
|
|
static char lz4_corrupt_msg[] = |
|
|
|
"LZ4 not supported or corrupted LZ4 compressed block contents"; |
|
|
|
"LZ4 not supported or corrupted LZ4 compressed block contents"; |
|
|
|
if (!ubuf) { |
|
|
|
if (!ubuf) { |
|
|
|
return Status::Corruption(lz4_corrupt_msg); |
|
|
|
return Status::Corruption(lz4_corrupt_msg); |
|
|
|
} |
|
|
|
} |
|
|
|
*contents = BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); |
|
|
|
*contents = |
|
|
|
|
|
|
|
BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case kLZ4HCCompression: |
|
|
|
case kLZ4HCCompression: |
|
|
|
ubuf = std::unique_ptr<char[]>(port::LZ4_Uncompress(data, n, &decompress_size)); |
|
|
|
ubuf = std::unique_ptr<char[]>( |
|
|
|
|
|
|
|
port::LZ4_Uncompress(data, n, &decompress_size)); |
|
|
|
static char lz4hc_corrupt_msg[] = |
|
|
|
static char lz4hc_corrupt_msg[] = |
|
|
|
"LZ4HC not supported or corrupted LZ4HC compressed block contents"; |
|
|
|
"LZ4HC not supported or corrupted LZ4HC compressed block contents"; |
|
|
|
if (!ubuf) { |
|
|
|
if (!ubuf) { |
|
|
|
return Status::Corruption(lz4hc_corrupt_msg); |
|
|
|
return Status::Corruption(lz4hc_corrupt_msg); |
|
|
|
} |
|
|
|
} |
|
|
|
*contents = BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); |
|
|
|
*contents = |
|
|
|
|
|
|
|
BlockContents(std::move(ubuf), decompress_size, true, kNoCompression); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
return Status::Corruption("bad block type"); |
|
|
|
return Status::Corruption("bad block type"); |
|
|
|