Permalink
Browse files

Bundle fastlz

Change-Id: I1b803430130d0a7357bb6a177067a93fb9b1f85d
Reviewed-on: http://review.couchbase.org/22340
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Mordechai Nunberg <mnunberg@haskalah.org>
  • Loading branch information...
1 parent 62059a4 commit 2dd2f18d29685d492704aadbac0f9a378b55b203 @mnunberg mnunberg committed with mnunberg Nov 7, 2012
Showing with 679 additions and 35 deletions.
  1. +0 −2 compress.c
  2. +1 −2 config.m4
  3. +1 −0 config.w32
  4. +0 −28 couchbase.c
  5. +24 −0 fastlz/LICENSE
  6. +551 −0 fastlz/fastlz.c
  7. +100 −0 fastlz/fastlz.h
  8. +2 −3 internal.h
View
@@ -201,7 +201,6 @@ int php_couchbase_decompress_zlib(php_couchbase_decomp *info)
}
#endif /* HAVE_COMPRESSION_ZLIB */
-#ifdef HAVE_COMPRESSION_FASTLZ
PHP_COUCHBASE_LOCAL
int php_couchbase_compress_fastlz(const smart_str *input,
php_couchbase_comp *output)
@@ -231,4 +230,3 @@ int php_couchbase_decompress_fastlz(php_couchbase_decomp *info)
return info->expanded_len;
}
-#endif
View
@@ -161,7 +161,6 @@ if test "$PHP_COUCHBASE" != "no"; then
if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, COUCHBASE_SHARED_LIBADD)
PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
- AC_DEFINE(HAVE_COMPRESSION,1,[Whether has a compresser])
AC_DEFINE(HAVE_COMPRESSION_ZLIB,1,[Whether zlib lib is available])
else
AC_MSG_ERROR([couchbase support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located])
@@ -171,5 +170,5 @@ if test "$PHP_COUCHBASE" != "no"; then
dnl PHP_ADD_LIBRARY(stdc++, 1, COUCHBASE_SHARED_LIBADD)
dnl PHP_ADD_LIBRARY(event, 1, COUCHBASE_SHARED_LIBADD)
PHP_SUBST(COUCHBASE_SHARED_LIBADD)
- PHP_NEW_EXTENSION(couchbase, compress.c couchbase.c views.c observe.c ht.c resmgr.c misc.c, $ext_shared)
+ PHP_NEW_EXTENSION(couchbase, compress.c couchbase.c views.c observe.c ht.c resmgr.c misc.c fastlz/fastlz.c, $ext_shared)
fi
View
@@ -8,5 +8,6 @@ if (PHP_COUCHBASE != "no") {
CHECK_HEADER_ADD_INCLUDE("couchbase.h", "CFLAGS_COUCHBASE", PHP_COUCHBASE+ ";" + PHP_PHP_BUILD + "\\include\\libcouchbase")) {
EXTENSION("couchbase", "couchbase.c", PHP_COUCHBASE_SHARED, "");
ADD_SOURCES(configure_module_dirname, "views.c observe.c ht.c resmgr.c misc.c gettimeofday_win32.c compress.c", "couchbase");
+ ADD_SOURCES(configure_module_dirname + "\\fastlz", "fastlz.c", "couchbase");
}
}
View
@@ -633,10 +633,8 @@ static PHP_INI_MH(OnUpdateCompressor)
{
if (!new_value || !strcmp(new_value, "none")) {
COUCHBASE_G(compressor_real) = COUCHBASE_COMPRESSION_NONE;
-#ifdef HAVE_COMPRESSION_FASTLZ
} else if (!strcmp(new_value, "fastlz")) {
COUCHBASE_G(compressor_real) = COUCHBASE_COMPRESSION_FASTLZ;
-#endif
#ifdef HAVE_COMPRESSION_ZLIB
} else if (!strcmp(new_value, "zlib")) {
COUCHBASE_G(compressor_real) = COUCHBASE_COMPRESSION_ZLIB;
@@ -754,7 +752,6 @@ static char *php_couchbase_zval_to_payload(zval *value, size_t *payload_len, uns
break;
}
-#ifdef HAVE_COMPRESSION
if ((COUCHBASE_GET_COMPRESSION(*flags)) && buf.len < COUCHBASE_G(compression_threshold)) {
COUCHBASE_SET_COMPRESSION(*flags, COUCHBASE_COMPRESSION_NONE);
}
@@ -766,12 +763,7 @@ static char *php_couchbase_zval_to_payload(zval *value, size_t *payload_len, uns
/* Additional 5% for the data (LZ) */
switch (compressor) {
case COUCHBASE_COMPRESSION_FASTLZ:
-#ifdef HAVE_COMPRESSION_FASTLZ
compress_status = php_couchbase_compress_fastlz(&buf, &cmpbuf);
-#else
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not compress value, no fastlz support");
- return NULL;
-#endif
break;
case COUCHBASE_COMPRESSION_ZLIB:
#ifdef HAVE_COMPRESSION_ZLIB
@@ -814,11 +806,6 @@ static char *php_couchbase_zval_to_payload(zval *value, size_t *payload_len, uns
*payload_len = buf.len;
payload = estrndup(buf.c, buf.len);
}
-#else
- COUCHBASE_SET_COMPRESSION(*flags, COUCHBASE_COMPRESSION_NONE);
- *payload_len = buf.len;
- payload = estrndup(buf.c, buf.len);
-#endif
smart_str_free(&buf);
return payload;
@@ -849,7 +836,6 @@ static int php_couchbase_zval_from_payload(zval *value, char *payload, size_t pa
}
if ((compressor = COUCHBASE_GET_COMPRESSION(flags))) {
-#ifdef HAVE_COMPRESSION
php_couchbase_decomp dcmp = { NULL };
zend_bool decompress_status = 0;
@@ -858,12 +844,7 @@ static int php_couchbase_zval_from_payload(zval *value, char *payload, size_t pa
switch (compressor) {
case COUCHBASE_COMPRESSION_FASTLZ:
-#ifdef HAVE_COMPRESSION_FASTLZ
decompress_status = php_couchbase_decompress_fastlz(&dcmp);
-#else
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not decompress value, no fastlz support");
- return 0;
-#endif
break;
case COUCHBASE_COMPRESSION_ZLIB:
#ifdef HAVE_COMPRESSION_ZLIB
@@ -884,11 +865,6 @@ static int php_couchbase_zval_from_payload(zval *value, char *payload, size_t pa
payload = dcmp.expanded;
payload_len = dcmp.expanded_len;
payload_emalloc = 1;
-
-#else
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not decompress value, no decompressor found");
- return 0;
-#endif
}
switch (COUCHBASE_VAL_GET_TYPE(flags)) {
@@ -4174,11 +4150,7 @@ PHP_MINFO_FUNCTION(couchbase)
#else
php_info_print_table_row(2, "json support", "no");
#endif
-#ifdef HAVE_COMPRESSION_FASTLZ
php_info_print_table_row(2, "fastlz support", "yes");
-#else
- php_info_print_table_row(2, "fastlz support", "no");
-#endif
#ifdef HAVE_COMPRESSION_ZLIB
php_info_print_table_row(2, "zlib support", "yes");
View
@@ -0,0 +1,24 @@
+FastLZ - lightning-fast lossless compression library
+
+Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
+Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
+Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
Oops, something went wrong.

0 comments on commit 2dd2f18

Please sign in to comment.