summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS2
-rw-r--r--Judy-svn.patch155
-rw-r--r--LICENSE68
-rw-r--r--Makefile4
-rw-r--r--README210
-rw-r--r--php-pecl-judy.spec214
6 files changed, 653 insertions, 0 deletions
diff --git a/CREDITS b/CREDITS
new file mode 100644
index 0000000..dd9d6cb
--- /dev/null
+++ b/CREDITS
@@ -0,0 +1,2 @@
+judy
+Nicolas Brousse
diff --git a/Judy-svn.patch b/Judy-svn.patch
new file mode 100644
index 0000000..cc675a8
--- /dev/null
+++ b/Judy-svn.patch
@@ -0,0 +1,155 @@
+--- pecl/judy/trunk/php_judy.c 2013/10/09 14:43:09 331752
++++ pecl/judy/trunk/php_judy.c 2013/10/09 15:09:50 331753
+@@ -144,7 +144,7 @@
+ long index = 0;
+ Word_t j_index;
+ Pvoid_t *PValue = NULL;
+- zval *result;
++ zval *result = NULL;
+ zval string_key, *pstring_key = &string_key;
+ judy_object *intern = (judy_object *) zend_object_store_get_object(object TSRMLS_CC);
+
+@@ -603,7 +603,7 @@
+ } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == SUCCESS) {
+ JTYPE(jtype, type);
+ intern->counter = 0;
+- intern->type = type;
++ intern->type = jtype;
+ intern->array = (Pvoid_t) NULL;
+ }
+
+@@ -615,7 +615,7 @@
+ Free Judy array and any other references */
+ PHP_METHOD(judy, __destruct)
+ {
+- JUDY_METHOD_GET_OBJECT
++ zval *object = getThis();
+
+ /* calling the object's free() method */
+ zend_call_method_with_0_params(&object, NULL, NULL, "free", NULL);
+@@ -628,7 +628,7 @@
+ {
+ JUDY_METHOD_GET_OBJECT
+
+- Word_t Rc_word;
++ Word_t Rc_word = 0;
+ Word_t index;
+ uint8_t kindex[PHP_JUDY_MAX_LENGTH];
+ Word_t *PValue;
+@@ -1019,7 +1019,7 @@
+ PHP_METHOD(judy, firstEmpty)
+ {
+ Word_t index = 0;
+- int Rc_int;
++ int Rc_int = 0;
+
+ JUDY_METHOD_GET_OBJECT
+
+@@ -1051,7 +1051,7 @@
+ PHP_METHOD(judy, lastEmpty)
+ {
+ Word_t index = -1;
+- int Rc_int;
++ int Rc_int = 0;
+
+ JUDY_METHOD_GET_OBJECT
+
+@@ -1083,7 +1083,7 @@
+ PHP_METHOD(judy, nextEmpty)
+ {
+ Word_t index;
+- int Rc_int;
++ int Rc_int = 0;
+
+ JUDY_METHOD_GET_OBJECT
+
+@@ -1115,7 +1115,7 @@
+ PHP_METHOD(judy, prevEmpty)
+ {
+ Word_t index;
+- int Rc_int;
++ int Rc_int = 0;
+
+ JUDY_METHOD_GET_OBJECT
+
+--- pecl/judy/trunk/judy_iterator.c 2013/10/09 15:20:22 331754
++++ pecl/judy/trunk/judy_iterator.c 2013/10/09 17:14:16 331755
+@@ -151,6 +151,14 @@
+
+ /* {{{ judy_iterator_current_key
+ */
++#if ZEND_MODULE_API_NO >= 20121212
++void judy_iterator_current_key(zend_object_iterator *iterator, zval *key TSRMLS_DC)
++{
++ judy_iterator *it = (judy_iterator*) iterator;
++
++ ZVAL_ZVAL(key, it->key, 1, 0);
++
++#else
+ int judy_iterator_current_key(zend_object_iterator *iterator,
+ char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+ {
+@@ -171,6 +179,7 @@
+ *str_key_len = Z_STRLEN_P(it->key)+1;
+
+ return HASH_KEY_IS_STRING;
++#endif
+ }
+ /* }}} */
+
+--- pecl/judy/trunk/judy_iterator.h 2013/10/09 15:20:22 331754
++++ pecl/judy/trunk/judy_iterator.h 2013/10/09 17:14:16 331755
+@@ -43,8 +43,12 @@
+ void judy_iterator_dtor(zend_object_iterator *iterator TSRMLS_DC);
+ int judy_iterator_valid(zend_object_iterator *iterator TSRMLS_DC);
+ void judy_iterator_current_data(zend_object_iterator *iterator, zval ***data TSRMLS_DC);
++#if ZEND_MODULE_API_NO >= 20121212
++void judy_iterator_current_key(zend_object_iterator *iterator, zval *key TSRMLS_DC);
++#else
+ int judy_iterator_current_key(zend_object_iterator *iterator,
+ char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
++#endif
+ void judy_iterator_move_forward(zend_object_iterator *iterator TSRMLS_DC);
+ void judy_iterator_rewind(zend_object_iterator *iterator TSRMLS_DC);
+ /* }}} */
+--- pecl/judy/trunk/php_judy.c 2013/10/09 19:10:22 331757
++++ pecl/judy/trunk/php_judy.c 2013/10/10 02:24:32 331758
+@@ -94,7 +94,7 @@
+ }
+ /* }}} */
+
+-PHPAPI zend_class_entry *php_judy_ce(void)
++PHP_JUDY_API zend_class_entry *php_judy_ce(void)
+ {
+ return judy_ce;
+ }
+--- pecl/judy/trunk/php_judy.h 2013/10/10 02:24:40 331759
++++ pecl/judy/trunk/php_judy.h 2013/10/10 04:38:41 331760
+@@ -19,7 +19,7 @@
+ #ifndef PHP_JUDY_H
+ #define PHP_JUDY_H
+
+-#define PHP_JUDY_VERSION "0.1.6"
++#define PHP_JUDY_VERSION "1.0.0"
+ #define PHP_JUDY_EXTNAME "judy"
+
+ #include <Judy.h>
+--- pecl/judy/trunk/tests/001.phpt 2013/10/10 02:24:40 331759
++++ pecl/judy/trunk/tests/001.phpt 2013/10/10 04:38:41 331760
+@@ -20,4 +20,4 @@
+ ?>
+ --EXPECT--
+ judy extension is available
+-PHP Judy Version: 0.1.6
++PHP Judy Version: 1.0.0
+--- pecl/judy/trunk/tests/github_issue2_003.phpt 2013/10/10 04:38:41 331760
++++ pecl/judy/trunk/tests/github_issue2_003.phpt 2013/10/10 04:43:24 331761
+@@ -2,6 +2,8 @@
+ Check for Judy ITERATOR using foreach() and INT_TO_MIXED
+ --SKIPIF--
+ <?php if (!extension_loaded("judy")) print "skip"; ?>
++--INI--
++date.timezone=UTC
+ --FILE--
+ <?php
+ /*
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..3cc8b77
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,68 @@
+--------------------------------------------------------------------
+ The PHP License, version 3.01
+Copyright (c) 1999 - 2010 The PHP Group. All rights reserved.
+--------------------------------------------------------------------
+
+Redistribution and use in source and binary forms, with or without
+modification, is permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ 3. The name "PHP" must not be used to endorse or promote products
+ derived from this software without prior written permission. For
+ written permission, please contact group@php.net.
+
+ 4. Products derived from this software may not be called "PHP", nor
+ may "PHP" appear in their name, without prior written permission
+ from group@php.net. You may indicate that your software works in
+ conjunction with PHP by saying "Foo for PHP" instead of calling
+ it "PHP Foo" or "phpfoo"
+
+ 5. The PHP Group may publish revised and/or new versions of the
+ license from time to time. Each version will be given a
+ distinguishing version number.
+ Once covered code has been published under a particular version
+ of the license, you may always continue to use it under the terms
+ of that version. You may also choose to use such covered code
+ under the terms of any subsequent version of the license
+ published by the PHP Group. No one other than the PHP Group has
+ the right to modify the terms applicable to covered code created
+ under this License.
+
+ 6. Redistributions of any form whatsoever must retain the following
+ acknowledgment:
+ "This product includes PHP software, freely available from
+ <http://www.php.net/software/>".
+
+THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
+ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
+DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--------------------------------------------------------------------
+
+This software consists of voluntary contributions made by many
+individuals on behalf of the PHP Group.
+
+The PHP Group can be contacted via Email at group@php.net.
+
+For more information on the PHP Group and the PHP project,
+please see <http://www.php.net>.
+
+PHP includes the Zend Engine, freely available at
+<http://www.zend.com>.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..13af741
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+SRCDIR := $(shell pwd)
+NAME := $(shell basename $(SRCDIR))
+include ../../../common/Makefile
+
diff --git a/README b/README
new file mode 100644
index 0000000..99b0f82
--- /dev/null
+++ b/README
@@ -0,0 +1,210 @@
+ PHP Judy - extension creating and accessing dynamic arrays
+ ================================================================
+
+Content
+---------
+ 1. Introduction
+ 2. Directory Contents
+ 3. How to install
+ 4. Usage (Examples)
+ 5. Reporting Bugs
+ 6. Todo
+
+
+1. INTRODUCTION
+-----------------
+
+php-judy is an extension by Nicolas Brousse for the Judy C library.
+ -> http://pecl.php.net/package/Judy
+ -> http://github.com/orieg/php-judy
+
+(see Section 4 of this document for PHP examples)
+
+A Judy array is a complex but very fast associative array data structure for
+storing and looking up values using integer or string keys. Unlike normal
+arrays, Judy arrays may be sparse; that is, they may have large ranges of
+unassigned indices.
+
+ -> http://en.wikipedia.org/wiki/Judy_array
+
+The PHP extension is base on the Judy C library that implements a dynamic array.
+A Judy array consumes memory only when populated yet can grow to take advantage
+of all available memory. Judy's key benefits are: scalability, performance,
+memory efficiency, and ease of use. Judy arrays are designed to grow without
+tuning into the peta-element range, scaling near O(log-base-256) -- 1 more RAM
+access at 256 X population.
+
+ -> http://judy.sourceforge.net
+
+2. PHP JUDY TOP DIRECTORY CONTENTS:
+------------------------------------
+
+README This file.
+LICENSE The PHP License used by this project.
+EXPERIMENTAL Note about the status of this package.
+
+lib/ Header and source libraries used by the package.
+libjudy/ Bundled libJudy.
+tests/ Unit tests.
+*.c, *.h Header and source files used to build the package.
+*.php PHP test/examples scripts.
+
+
+3. HOW TO INSTALL
+------------------
+
+ A. Linux
+
+ From the PHP Judy sources :
+
+ phpize
+ ./configure --with-judy[=DIR]
+ make
+ make test
+ make install
+
+ If you are using Ubuntu or Debian, you can install libJudy with apt :
+
+ apt-get install libjudydebian1 libjudy-dev
+ phpize
+ ./configure --with-judy=/usr
+ make
+ make test
+ make install
+
+ B. Windows
+
+ On Windows, you will need to build LibJudy yourself.
+
+ Download the sources at
+
+ http://sourceforge.net/projects/judy/
+
+ Extract the sources, and open the Visual Studio command prompt and navigate to
+ the source directory. Then execute:
+
+ build
+
+ This creates "Judy.lib", copy this into the php-sdk library folder and name it
+
+ libJudy.lib
+
+ Then copy the include file "judy.h" into the php-sdk includes folder. Now its
+ time to build pecl/judy, extract the pecl/judy into your build folder where
+ the build scripts will be able to pick it up, e.g.:
+
+ C:\php\pecl\judy\
+
+ If your source of PHP is located in:
+
+ C:\php\src\
+
+ The rest of the steps is pretty straight forward, like any other external
+ extension:
+
+ buildconf
+ configure --with-judy=shared
+ nmake
+
+ C. Mac OS X
+
+ You will need to install the libJudy first. Download the sources at
+
+ http://sourceforge.net/projects/judy/
+
+ Extract the sources, then cd into the source directory and execute :
+
+ ./configure
+ make
+ make install
+
+ Use pecl to install the PHP Judy extension :
+
+ sudo pecl -d preferred_state=beta install Judy
+
+
+4. USAGE (EXAMPLES)
+------------------
+
+Judy's array can be used like usual PHP arrays. The difference will be in the
+type of key/values that you can use. Judy arrays are optimised for memory usage
+but it force to some limitation in the PHP API.
+
+There is currently 5 type of PHP Judy Arrays :
+ - BITSET (using Judy1)
+ - INT_TO_INT (using JudyL)
+ - INT_TO_MIXED (using JudyL)
+ - STRING_TO_INT (using JudySL)
+ - STRING_TO_MIXED (using JudySL)
+
+You can use foreach() and the PHP array notation on all PHP Judy arrays.
+
+ A. BITSET
+
+ Bitset implementation is quite basic for now. It allow you to set a bunch of index
+ setting the value to false will be the same than using unset().
+
+ $bitset = new Judy(Judy::BITSET);
+ $bitset[124] = true;
+ ...
+
+ print $bitset[124]; // will print 1
+
+ $bitset[124] = false; // is the same as unset($bitset[124])
+
+ B. INT_TO_INT
+
+ This type let you create an array with key and value of integer, and integer only.
+
+ $int2int = new Judy(Judy::INT_TO_INT);
+ $int2int[125] = 17;
+ ...
+
+ print $int2int[125]; // will print 17
+
+ C. INT_TO_MIXED
+
+ This type let you create an array with key as integer and value of any type, including
+ other judy array or any object.
+
+ $int2mixed = new Judy(Judy::INT_TO_MIXED);
+ $int2mixed[1] = "one";
+ $int2mixed[2] = array('a', 'b', 'c');
+ $int2mixed[3] = new Judy(Judy::BITSET);
+
+ D. STRING_TO_INT
+
+ This type let you create an array with key as string (currently limited to 65536 char.)
+ and an integer as the value.
+
+ $string2int = new Judy(Judy::STRING_TO_INT);
+ $string2int["one"] = 1;
+ $string2int["two"] = 2;
+
+ print $string2int["one"]; // will print 1
+
+ E. STRING_TO_MIXED
+
+ This type let you create an array with key as string and values of any type, including
+ other judy array or any objects.
+
+ $string2mixed = new Judy(Judy::STRING_TO_MIXED);
+ $string2mixed["string"] = "hello world!";
+ $string2mixed["array"] = array('a', 'b', 'c');
+ $string2mixed["integer"] = 632;
+ $string2mixed["bitset"] = new Judy(Judy::BITSET);
+
+
+5. REPORTING BUGS
+------------------
+
+If you encounter a bug, please submit it via the bug tracker on Git Hub:
+
+ https://github.com/orieg/php-judy/issues
+
+
+6. TODO
+--------
+
+ * Implements comparator and cast handler
+ * Add bitset comparator (cf. Judy1Op sample)
diff --git a/php-pecl-judy.spec b/php-pecl-judy.spec
new file mode 100644
index 0000000..2eeb496
--- /dev/null
+++ b/php-pecl-judy.spec
@@ -0,0 +1,214 @@
+# spec file for php-pecl-xrange
+#
+# Copyright (c) 2013 Remi Collet
+# License: CC-BY-SA
+# http://creativecommons.org/licenses/by-sa/3.0/
+#
+# Please, preserve the changelog entries
+#
+%{!?php_inidir: %{expand: %%global php_inidir %{_sysconfdir}/php.d}}
+%{!?__pecl: %{expand: %%global __pecl %{_bindir}/pecl}}
+
+%global with_zts 0%{?__ztsphp:1}
+%global pecl_name Judy
+%global ext_name judy
+
+Summary: PHP Judy implements sparse dynamic arrays
+Name: php-pecl-%{pecl_name}
+Version: 1.0.0
+Release: 2%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}
+License: PHP
+Group: Development/Languages
+URL: http://pecl.php.net/package/%{pecl_name}
+Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
+
+# Retrieved from http://svn.php.net/viewvc/pecl/judy/trunk/
+Source1: LICENSE
+Source2: README
+Source3: CREDITS
+
+# http://svn.php.net/viewvc?view=revision&revision=331753
+# http://svn.php.net/viewvc?view=revision&revision=331755
+# http://svn.php.net/viewvc?view=revision&revision=331758
+# http://svn.php.net/viewvc?view=revision&revision=331760
+# http://svn.php.net/viewvc?view=revision&revision=331761
+Patch0: %{pecl_name}-svn.patch
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: php-devel
+BuildRequires: php-pear
+BuildRequires: Judy-devel
+
+Requires(post): %{__pecl}
+Requires(postun): %{__pecl}
+Requires: php(zend-abi) = %{php_zend_api}
+Requires: php(api) = %{php_core_api}
+Requires: php-spl%{?_isa}
+
+Provides: php-%{ext_name} = %{version}
+Provides: php-%{ext_name}%{?_isa} = %{version}
+Provides: php-pecl(%{pecl_name}) = %{version}
+Provides: php-pecl(%{pecl_name})%{?_isa} = %{version}
+
+# Filter shared private
+%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$}
+%{?filter_setup}
+
+
+%description
+PHP Judy implements sparse dynamic arrays (aka Judy Arrays).
+This extension is based on the Judy C library. A Judy array
+consumes memory only when it is populated, yet can grow to
+take advantage of all available memory if desired. Judy's key
+benefits are scalability, high performance, and memory efficiency.
+
+
+%package devel
+Summary: %{name} developer files (header)
+Group: Development/Libraries
+Requires: %{name}%{?_isa} = %{version}-%{release}
+Requires: php-devel%{?_isa}
+
+%description devel
+These are the files needed to compile programs using %{name}.
+
+
+%prep
+%setup -q -c
+mv %{pecl_name}-%{version} NTS
+
+cd NTS
+%patch0 -p3
+
+cp %{SOURCE1} %{SOURCE2} %{SOURCE3} .
+
+# Sanity check, really often broken
+extver=$(sed -n '/#define PHP_JUDY_VERSION/{s/.* "//;s/".*$//;p}' php_judy.h)
+if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then
+ : Error: Upstream extension version is ${extver}, expecting %{version}%{?prever:-%{prever}}.
+ exit 1
+fi
+cd ..
+
+%if %{with_zts}
+# Duplicate source tree for NTS / ZTS build
+cp -pr NTS ZTS
+%endif
+
+# Create configuration file
+cat > %{pecl_name}.ini << 'EOF'
+; Enable %{pecl_name} extension module
+extension=%{ext_name}.so
+EOF
+
+
+%build
+cd NTS
+%{_bindir}/phpize
+%configure \
+ --with-libdir=%{_lib} \
+ --with-php-config=%{_bindir}/php-config
+
+make %{?_smp_mflags}
+
+%if %{with_zts}
+cd ../ZTS
+%{_bindir}/zts-phpize
+%configure \
+ --with-libdir=%{_lib} \
+ --with-php-config=%{_bindir}/zts-php-config
+
+make %{?_smp_mflags}
+%endif
+
+
+%install
+rm -rf %{buildroot}
+
+make -C NTS install INSTALL_ROOT=%{buildroot}
+
+# install config file
+install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_inidir}/%{ext_name}.ini
+
+# Install XML package description
+install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml
+
+%if %{with_zts}
+make -C ZTS install INSTALL_ROOT=%{buildroot}
+
+install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_ztsinidir}/%{ext_name}.ini
+%endif
+
+
+%post
+%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
+
+
+%postun
+if [ $1 -eq 0 ] ; then
+ %{pecl_uninstall} %{pecl_name} >/dev/null || :
+fi
+
+
+%check
+: Minimal load test for NTS extension
+cd NTS
+%{_bindir}/php --no-php-ini \
+ --define extension=modules/%{ext_name}.so \
+ --modules | grep %{ext_name}
+
+: Upstream test suite for NTS extension
+TEST_PHP_EXECUTABLE=%{_bindir}/php \
+TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{ext_name}.so" \
+NO_INTERACTION=1 \
+REPORT_EXIT_STATUS=1 \
+%{_bindir}/php -n run-tests.php
+
+
+%if %{with_zts}
+: Minimal load test for ZTS extension
+cd ../ZTS
+%{__ztsphp} --no-php-ini \
+ --define extension=modules/%{ext_name}.so \
+ --modules | grep %{ext_name}
+
+: Upstream test suite for ZTS extension
+TEST_PHP_EXECUTABLE=%{__ztsphp} \
+TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{ext_name}.so" \
+NO_INTERACTION=1 \
+REPORT_EXIT_STATUS=1 \
+%{__ztsphp} -n run-tests.php
+%endif
+
+
+%clean
+rm -rf %{buildroot}
+
+
+%files
+%defattr(-,root,root,-)
+%doc NTS/{LICENSE,CREDITS}
+%{pecl_xmldir}/%{name}.xml
+%config(noreplace) %{php_inidir}/%{ext_name}.ini
+%{php_extdir}/%{ext_name}.so
+
+%if %{with_zts}
+%config(noreplace) %{php_ztsinidir}/%{ext_name}.ini
+%{php_ztsextdir}/%{ext_name}.so
+%endif
+
+%files devel
+%defattr(-,root,root,-)
+%{php_incldir}/ext/%{ext_name}
+
+%if %{with_zts}
+%{php_ztsincldir}/ext/%{ext_name}
+%endif
+
+
+%changelog
+* Thu Oct 10 2013 Remi Collet <remi@fedoraproject.org> - 1.0.0-2
+- fix extension name in configuration file
+
+* Wed Oct 9 2013 Remi Collet <remi@fedoraproject.org> - 1.0.0-1
+- initial package, version 1.0.0 (stable)