summaryrefslogtreecommitdiff
path: root/port
diff options
context:
space:
mode:
authoramayank <amayank@fb.com>2012-11-01 10:50:08 -0700
committeramayank <amayank@fb.com>2012-11-02 11:26:39 -0700
commit854c66b089bef5d27f79750884f70f6e2c8c69da (patch)
treec6e03c17593c1ce627de8c89b3c345fb6bbf97ed /port
parent3096fa75342f39b642eb1b212504af1bd205cb72 (diff)
Make compression options configurable. These include window-bits, level and strategy for ZlibCompression
Summary: Leveldb currently uses windowBits=-14 while using zlib compression.(It was earlier 15). This makes the setting configurable. Related changes here: https://reviews.facebook.net/D6105 Test Plan: make all check Reviewers: dhruba, MarkCallaghan, sheki, heyongqiang Differential Revision: https://reviews.facebook.net/D6393
Diffstat (limited to 'port')
-rw-r--r--port/port_posix.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/port/port_posix.h b/port/port_posix.h
index db4e0b8ca..e2540a426 100644
--- a/port/port_posix.h
+++ b/port/port_posix.h
@@ -44,6 +44,7 @@
#include <stdint.h>
#include <string>
#include <string.h>
+#include "leveldb/options.h"
#include "port/atomic_pointer.h"
#ifndef PLATFORM_IS_LITTLE_ENDIAN
@@ -131,8 +132,8 @@ typedef pthread_once_t OnceType;
#define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT
extern void InitOnce(OnceType* once, void (*initializer)());
-inline bool Snappy_Compress(const char* input, size_t length,
- ::std::string* output) {
+inline bool Snappy_Compress(const CompressionOptions& opts, const char* input,
+ size_t length, ::std::string* output) {
#ifdef SNAPPY
output->resize(snappy::MaxCompressedLength(length));
size_t outlen;
@@ -162,9 +163,8 @@ inline bool Snappy_Uncompress(const char* input, size_t length,
#endif
}
-inline bool Zlib_Compress(const char* input, size_t length,
- ::std::string* output, int windowBits = -14, int level = -1,
- int strategy = 0) {
+inline bool Zlib_Compress(const CompressionOptions& opts, const char* input,
+ size_t length, ::std::string* output) {
#ifdef ZLIB
// The memLevel parameter specifies how much memory should be allocated for
// the internal compression state.
@@ -174,8 +174,8 @@ inline bool Zlib_Compress(const char* input, size_t length,
static const int memLevel = 8;
z_stream _stream;
memset(&_stream, 0, sizeof(z_stream));
- int st = deflateInit2(&_stream, level, Z_DEFLATED, windowBits,
- memLevel, strategy);
+ int st = deflateInit2(&_stream, opts.level, Z_DEFLATED, opts.window_bits,
+ memLevel, opts.strategy);
if (st != Z_OK) {
return false;
}
@@ -284,8 +284,8 @@ inline char* Zlib_Uncompress(const char* input_data, size_t input_length,
return NULL;
}
-inline bool BZip2_Compress(const char* input, size_t length,
- ::std::string* output) {
+inline bool BZip2_Compress(const CompressionOptions& opts, const char* input,
+ size_t length, ::std::string* output) {
#ifdef BZIP2
bz_stream _stream;
memset(&_stream, 0, sizeof(bz_stream));