Pull from upstream.

git-svn-id: https://leveldb.googlecode.com/svn/trunk@14 62dab493-f737-651d-591e-8d6aee1b9529
This commit is contained in:
jorlow@chromium.org
2011-03-22 23:24:02 +00:00
parent 6d243ebf79
commit 8303bb1b33
21 changed files with 118 additions and 113 deletions

View File

@@ -138,11 +138,14 @@ void TableBuilder::WriteBlock(BlockBuilder* block, BlockHandle* handle) {
block_contents = raw;
break;
case kLightweightCompression: {
port::Lightweight_Compress(raw.data(), raw.size(), &r->compressed_output);
block_contents = r->compressed_output;
if (block_contents.size() >= raw.size() - (raw.size() / 8u)) {
// Compressed less than 12.5%, so just store uncompressed form
case kSnappyCompression: {
std::string* compressed = &r->compressed_output;
if (port::Snappy_Compress(raw.data(), raw.size(), compressed) &&
compressed->size() < raw.size() - (raw.size() / 8u)) {
block_contents = *compressed;
} else {
// Snappy not supported, or compressed less than 12.5%, so just
// store uncompressed form
block_contents = raw;
type = kNoCompression;
}