diff options
author | Susan LoVerso <sue@wiredtiger.com> | 2015-05-04 11:07:38 -0400 |
---|---|---|
committer | Susan LoVerso <sue@wiredtiger.com> | 2015-05-04 11:07:38 -0400 |
commit | 9888eff27159a52d2990f865dabb506d07bee1e7 (patch) | |
tree | 4b8d232397f37d502553839c1fdac1605b13bb7b /ext | |
parent | a7a9ced7919c61b502f7dbd1d7c6dbb3d6b459ac (diff) | |
parent | 8e9b6736a0cee2c4ebdea8f3922da07aec95744f (diff) | |
download | mongo-9888eff27159a52d2990f865dabb506d07bee1e7.tar.gz |
Merge branch 'develop' into encryption-api
Conflicts:
src/docs/command-line.dox
Diffstat (limited to 'ext')
-rw-r--r-- | ext/compressors/lz4/lz4_compress.c | 37 | ||||
-rw-r--r-- | ext/compressors/zlib/zlib_compress.c | 79 |
2 files changed, 57 insertions, 59 deletions
diff --git a/ext/compressors/lz4/lz4_compress.c b/ext/compressors/lz4/lz4_compress.c index e6b8219aafb..9939a4f8a04 100644 --- a/ext/compressors/lz4/lz4_compress.c +++ b/ext/compressors/lz4/lz4_compress.c @@ -43,15 +43,16 @@ /* Local compressor structure. */ typedef struct { WT_COMPRESSOR compressor; /* Must come first */ + WT_EXTENSION_API *wt_api; /* Extension API */ } LZ4_COMPRESSOR; /* - * wt_lz4_error -- + * lz4_error -- * Output an error message, and return a standard error code. */ static int -wt_lz4_error( +lz4_error( WT_COMPRESSOR *compressor, WT_SESSION *session, const char *call, int zret) { WT_EXTENSION_API *wt_api; @@ -64,11 +65,11 @@ wt_lz4_error( } /* - * wt_lz4_compress -- + * lz4_compress -- * WiredTiger LZ4 compression. */ static int -wt_lz4_compress(WT_COMPRESSOR *compressor, WT_SESSION *session, +lz4_compress(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp, int *compression_failed) @@ -81,7 +82,7 @@ wt_lz4_compress(WT_COMPRESSOR *compressor, WT_SESSION *session, * call, but be paranoid and error if it isn't. */ if (dst_len < src_len + sizeof(size_t)) - return (wt_lz4_error(compressor, session, + return (lz4_error(compressor, session, "LZ4 compress buffer too small", 0)); /* Store the length of the compressed block in the first 8 bytes. */ @@ -110,11 +111,11 @@ wt_lz4_compress(WT_COMPRESSOR *compressor, WT_SESSION *session, } /* - * wt_lz4_decompress -- + * lz4_decompress -- * WiredTiger LZ4 decompression. */ static int -wt_lz4_decompress(WT_COMPRESSOR *compressor, WT_SESSION *session, +lz4_decompress(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp) @@ -131,7 +132,7 @@ wt_lz4_decompress(WT_COMPRESSOR *compressor, WT_SESSION *session, if (src_data_len + sizeof(size_t) > src_len) { (void)wt_api->err_printf(wt_api, session, - "wt_lz4_decompress: stored size exceeds buffer size"); + "lz4_decompress: stored size exceeds buffer size"); return (WT_ERROR); } @@ -148,7 +149,7 @@ wt_lz4_decompress(WT_COMPRESSOR *compressor, WT_SESSION *session, compressed_data, (char *)dst, (int)src_data_len, (int)dst_len); if (decoded < 0) - return (wt_lz4_error(compressor, session, + return (lz4_error(compressor, session, "LZ4 decompress error", decoded)); /* return the uncompressed data length */ @@ -158,11 +159,11 @@ wt_lz4_decompress(WT_COMPRESSOR *compressor, WT_SESSION *session, } /* - * wt_lz4_pre_size -- + * lz4_pre_size -- * WiredTiger LZ4 destination buffer sizing for compression. */ static int -wt_lz4_pre_size(WT_COMPRESSOR *compressor, WT_SESSION *session, +lz4_pre_size(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, size_t *result_lenp) { @@ -179,11 +180,11 @@ wt_lz4_pre_size(WT_COMPRESSOR *compressor, WT_SESSION *session, } /* - * wt_lz4_terminate -- + * lz4_terminate -- * WiredTiger LZ4 compression termination. */ static int -wt_lz4_terminate(WT_COMPRESSOR *compressor, WT_SESSION *session) +lz4_terminate(WT_COMPRESSOR *compressor, WT_SESSION *session) { (void)session; @@ -221,11 +222,11 @@ lz4_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) * the compressor is terminated. However, this approach is more general * purpose and supports multiple databases per application. */ - lz4_compressor->compressor.compress = wt_lz4_compress; + lz4_compressor->compressor.compress = lz4_compress; lz4_compressor->compressor.compress_raw = NULL; - lz4_compressor->compressor.decompress = wt_lz4_decompress; - lz4_compressor->compressor.pre_size = wt_lz4_pre_size; - lz4_compressor->compressor.terminate = wt_lz4_terminate; + lz4_compressor->compressor.decompress = lz4_decompress; + lz4_compressor->compressor.pre_size = lz4_pre_size; + lz4_compressor->compressor.terminate = lz4_terminate; lz4_compressor->wt_api = connection->get_extension_api(connection); @@ -246,6 +247,6 @@ lz4_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) int wiredtiger_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) { - return lz4_extension_init(connection, config); + return (lz4_extension_init(connection, config)); } #endif diff --git a/ext/compressors/zlib/zlib_compress.c b/ext/compressors/zlib/zlib_compress.c index 381bf0d5070..e5a313627a5 100644 --- a/ext/compressors/zlib/zlib_compress.c +++ b/ext/compressors/zlib/zlib_compress.c @@ -68,14 +68,14 @@ typedef struct { */ static int zlib_error( - WT_COMPRESSOR *compressor, WT_SESSION *session, const char *call, int zret) + WT_COMPRESSOR *compressor, WT_SESSION *session, const char *call, int error) { WT_EXTENSION_API *wt_api; wt_api = ((ZLIB_COMPRESSOR *)compressor)->wt_api; (void)wt_api->err_printf(wt_api, session, - "zlib error: %s: %s: %d", call, zError(zret), zret); + "zlib error: %s: %s: %d", call, zError(error), error); return (WT_ERROR); } @@ -154,32 +154,6 @@ zlib_compress(WT_COMPRESSOR *compressor, WT_SESSION *session, } /* - * zlib_find_slot -- - * Find the slot containing the target offset (binary search). - */ -static inline uint32_t -zlib_find_slot(uint64_t target, uint32_t *offsets, uint32_t slots) -{ - uint32_t base, indx, limit; - - indx = 1; - - /* Figure out which slot we got to: binary search */ - if (target >= offsets[slots]) - indx = slots; - else if (target > offsets[1]) - for (base = 2, limit = slots - base; limit != 0; limit >>= 1) { - indx = base + (limit >> 1); - if (target < offsets[indx]) - continue; - base = indx + 1; - --limit; - } - - return (indx); -} - -/* * zlib_decompress -- * WiredTiger zlib decompression. */ @@ -222,6 +196,32 @@ zlib_decompress(WT_COMPRESSOR *compressor, WT_SESSION *session, } /* + * zlib_find_slot -- + * Find the slot containing the target offset (binary search). + */ +static inline uint32_t +zlib_find_slot(uint64_t target, uint32_t *offsets, uint32_t slots) +{ + uint32_t base, indx, limit; + + indx = 1; + + /* Figure out which slot we got to: binary search */ + if (target >= offsets[slots]) + indx = slots; + else if (target > offsets[1]) + for (base = 2, limit = slots - base; limit != 0; limit >>= 1) { + indx = base + (limit >> 1); + if (target < offsets[indx]) + continue; + base = indx + 1; + --limit; + } + + return (indx); +} + +/* * zlib_compress_raw -- * Pack records into a specified on-disk page size. */ @@ -267,8 +267,7 @@ zlib_compress_raw(WT_COMPRESSOR *compressor, WT_SESSION *session, /* Save the stream state in case the chosen data doesn't fit. */ if ((ret = deflateCopy(&last_zs, &zs)) != Z_OK) - return (zlib_error( - compressor, session, "deflateCopy", ret)); + return (zlib_error(compressor, session, "deflateCopy", ret)); /* * Strategy: take the available output size and compress that much @@ -410,8 +409,8 @@ zlib_add_compressor(WT_CONNECTION *connection, int raw, const char *name) ZLIB_COMPRESSOR *zlib_compressor; /* - * There are two almost identical zlib compressors: one supporting raw - * compression, and one without. + * There are two almost identical zlib compressors: one using raw + * compression to target a specific block size, and one without. */ if ((zlib_compressor = calloc(1, sizeof(ZLIB_COMPRESSOR))) == NULL) return (errno); @@ -426,13 +425,13 @@ zlib_add_compressor(WT_CONNECTION *connection, int raw, const char *name) zlib_compressor->wt_api = connection->get_extension_api(connection); /* - * between 0-10: level: see zlib manual. + * Between 0-10: level: see zlib manual. */ zlib_compressor->zlib_level = Z_DEFAULT_COMPRESSION; - /* Load the standard compressor. */ + /* Load the compressor. */ return (connection->add_compressor( - connection, name, &zlib_compressor->compressor, NULL)); + connection, name, (WT_COMPRESSOR *)zlib_compressor, NULL)); } int zlib_extension_init(WT_CONNECTION *, WT_CONFIG_ARG *); @@ -440,12 +439,11 @@ int zlib_extension_init(WT_CONNECTION *, WT_CONFIG_ARG *); /* * zlib_extension_init -- * WiredTiger zlib compression extension - called directly when zlib - * support is built in, or via wiredtiger_extension_init when zlib - * support is included via extension loading. + * support is built in, or via wiredtiger_extension_init when zlib support + * is included via extension loading. */ int -zlib_extension_init( - WT_CONNECTION *connection, WT_CONFIG_ARG *config) +zlib_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) { int ret; @@ -468,8 +466,7 @@ zlib_extension_init( * WiredTiger zlib compression extension. */ int -wiredtiger_extension_init( - WT_CONNECTION *connection, WT_CONFIG_ARG *config) +wiredtiger_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) { return (zlib_extension_init(connection, config)); } |