summaryrefslogtreecommitdiff
path: root/table
diff options
context:
space:
mode:
authorgabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529>2011-07-21 02:40:18 +0000
committergabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529>2011-07-21 02:40:18 +0000
commit60bd8015f21fdb63d5409b1191f8ea9d8f1a1b87 (patch)
treedab21fd0d1309be4e6851f690e1c011e79ddbf6b /table
parent6872ace90110799f87402cbc594c4cbf1bc474c7 (diff)
downloadleveldb-60bd8015f21fdb63d5409b1191f8ea9d8f1a1b87.tar.gz
Speed up Snappy uncompression, new Logger interface.
- Removed one copy of an uncompressed block contents changing the signature of Snappy_Uncompress() so it uncompresses into a flat array instead of a std::string. Speeds up readrandom ~10%. - Instead of a combination of Env/WritableFile, we now have a Logger interface that can be easily overridden applications that want to supply their own logging. - Separated out the gcc and Sun Studio parts of atomic_pointer.h so we can use 'asm', 'volatile' keywords for Sun Studio. git-svn-id: https://leveldb.googlecode.com/svn/trunk@39 62dab493-f737-651d-591e-8d6aee1b9529
Diffstat (limited to 'table')
-rw-r--r--table/format.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/table/format.cc b/table/format.cc
index 63971db..ba7838c 100644
--- a/table/format.cc
+++ b/table/format.cc
@@ -107,16 +107,20 @@ Status ReadBlock(RandomAccessFile* file,
// Ok
break;
case kSnappyCompression: {
- std::string decompressed;
- if (!port::Snappy_Uncompress(data, n, &decompressed)) {
+ size_t ulength = 0;
+ if (!port::Snappy_GetUncompressedLength(data, n, &ulength)) {
delete[] buf;
- s = Status::Corruption("corrupted compressed block contents");
- return s;
+ return Status::Corruption("corrupted compressed block contents");
}
- delete[] buf; // Done with uncompressed data
- buf = new char[decompressed.size()];
- memcpy(buf, decompressed.data(), decompressed.size());
- n = decompressed.size();
+ char* ubuf = new char[ulength];
+ if (!port::Snappy_Uncompress(data, n, ubuf)) {
+ delete[] buf;
+ delete[] ubuf;
+ return Status::Corruption("corrupted compressed block contents");
+ }
+ delete[] buf;
+ buf = ubuf;
+ n = ulength;
break;
}
default: