├── .gitattributes ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CREDITS.md ├── LICENSE ├── README.md ├── config.m4 ├── config.w32 ├── debian ├── changelog ├── compat ├── control ├── copyright ├── php5-riak.dirs ├── riak.ini ├── rules └── watch ├── ht_utils.c ├── ht_utils.h ├── leak-test.sh ├── package.xml ├── php_riak.c ├── php_riak.files ├── php_riak.h ├── php_riak_internal.h ├── riak ├── bucket.c ├── bucket.h ├── bucket_properties.c ├── bucket_properties.h ├── connection.c ├── connection.h ├── crdt │ ├── counter.c │ ├── counter.h │ └── input │ │ ├── get_input.c │ │ ├── get_input.h │ │ ├── update_input.c │ │ └── update_input.h ├── exception │ ├── exception.c │ └── exception.h ├── input │ ├── delete_input.c │ ├── delete_input.h │ ├── get_input.c │ ├── get_input.h │ ├── get_resolver_input.c │ ├── get_resolver_input.h │ ├── index_input.c │ ├── index_input.h │ ├── input.c │ ├── input.h │ ├── put_input.c │ └── put_input.h ├── link.c ├── link.h ├── map_reduce │ ├── functions │ │ ├── base_function.c │ │ ├── base_function.h │ │ ├── erlang_function.c │ │ ├── erlang_function.h │ │ ├── javascript_function.c │ │ └── javascript_function.h │ ├── input │ │ ├── bucket_input.c │ │ ├── bucket_input.h │ │ ├── input.c │ │ ├── input.h │ │ ├── key_data_list_input.c │ │ ├── key_data_list_input.h │ │ ├── key_list_input.c │ │ └── key_list_input.h │ ├── mapreduce.c │ ├── mapreduce.h │ ├── output │ │ ├── output.c │ │ ├── output.h │ │ ├── stream_output.c │ │ └── stream_output.h │ └── phase │ │ ├── map_phase.c │ │ ├── map_phase.h │ │ ├── phase.c │ │ ├── phase.h │ │ ├── reduce_phase.c │ │ └── reduce_phase.h ├── object.c ├── object.h ├── object_list.c ├── object_list.h ├── output │ ├── conflict_resolver.c │ ├── conflict_resolver.h │ ├── get_output.c │ ├── get_output.h │ ├── index_output.c │ ├── index_output.h │ ├── index_result.c │ ├── index_result.h │ ├── index_result_list.c │ ├── index_result_list.h │ ├── key_stream_output.c │ ├── key_stream_output.h │ ├── output.c │ ├── output.h │ ├── put_output.c │ ├── put_output.h │ ├── youngest_sibling_resolver.c │ └── youngest_sibling_resolver.h ├── pool.c ├── pool.h ├── pool_info.c ├── pool_info.h ├── property │ ├── commit_hook.c │ ├── commit_hook.h │ ├── commit_hook_list.c │ ├── commit_hook_list.h │ ├── module_function.c │ ├── module_function.h │ └── replication_mode │ │ ├── replication_mode.c │ │ └── replication_mode.h ├── query │ ├── index_query.c │ └── index_query.h ├── search │ ├── input │ │ ├── parameter_bag.c │ │ └── parameter_bag.h │ ├── output │ │ ├── document_output.c │ │ ├── document_output.h │ │ ├── output.c │ │ └── output.h │ ├── search.c │ └── search.h ├── server_info.c └── server_info.h ├── riak_session.c ├── riak_session.h ├── script ├── build_module.sh └── configure-riak.php └── tests ├── .gitignore ├── bucket.phpt ├── bucket_props.phpt ├── bucket_props_ext.phpt ├── builtin_conflict_resolver_db_objs.phpt ├── builtin_conflict_resolvers.phpt ├── client_ctor.phpt ├── conflict_resolver_bucket.phpt ├── conflict_resolver_exception.phpt ├── conflict_resolver_key.phpt ├── conflict_resolver_precedence.phpt ├── connect.inc ├── connection.phpt ├── connection_lazy.phpt ├── crdt_counter.phpt ├── delete_badarguments.phpt ├── get1.phpt ├── index_output.phpt ├── index_perform.phpt ├── index_perform_arr.phpt ├── index_query.phpt ├── index_query_ext.phpt ├── key_not_found.phpt ├── links.phpt ├── list_keys.phpt ├── mapreduce.phpt ├── metadata.phpt ├── mrfunctions.phpt ├── mrinputs.phpt ├── mrkeyfilters.phpt ├── mrphase.phpt ├── numeric_key.phpt ├── object_list.phpt ├── ping.phpt ├── pool.phpt ├── pool_info.phpt ├── property_commit_hook.phpt ├── put1.phpt ├── reconnect.phpt ├── reset_object_properties.phpt ├── resolve_siblings.phpt ├── search.phpt ├── search_input.phpt ├── server_info.phpt ├── session.phpt ├── session_respects_options.phpt ├── stream_keys.phpt └── update_object.phpt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files we want to always be normalized and converted 5 | # to native line endings on checkout. 6 | 7 | *.c text 8 | *.md text 9 | *.txt text 10 | 11 | # Declare files that will always have CRLF line endings on checkout. 12 | *.cmd text eol=crlf 13 | 14 | # Binaries 15 | *.so binary 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | modules/ 2 | build/ 3 | include/ 4 | autom4te.cache/ 5 | 6 | *.iml 7 | .idea/ 8 | 9 | .anjuta_sym_db.db 10 | 11 | *.config 12 | *.creator 13 | *.includes 14 | *.user 15 | *.mem 16 | 17 | .libs/ 18 | .deps 19 | *.*~ 20 | *.in 21 | *.anjuta 22 | *.la 23 | *.lo 24 | libtool 25 | missing 26 | php-setup.sh 27 | run-tests.php 28 | config.* 29 | !config.m4 30 | !config.w32 31 | configure 32 | configure.* 33 | Makefile 34 | Makefile.* 35 | mkinstalldirs 36 | ltmain.sh 37 | install-sh 38 | aclocal.m4 39 | acinclude.m4 40 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "LibRiack"] 2 | path = LibRiack 3 | url = https://github.com/trifork/riack.git 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - "5.6" 4 | - "5.5" 5 | - "5.4" 6 | - "5.3" 7 | services: 8 | - riak 9 | before_install: 10 | - sudo apt-get update 11 | - sudo apt-get install -qq valgrind 12 | before_script: 13 | - git submodule update --init --recursive 14 | - ./script/build_module.sh 15 | script: 16 | - sudo search-cmd install testsearch 17 | - PHP=`which php` 18 | - PHP=~/.phpenv/versions/$(phpenv version-name)/bin/php 19 | - REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE=$PHP $PHP run-tests.php -q -m --show-diff 20 | - find . -name *.mem | xargs cat 21 | -------------------------------------------------------------------------------- /CREDITS.md: -------------------------------------------------------------------------------- 1 | #THANKS TO 2 | 3 | ##FabioBatSilva - https://github.com/FabioBatSilva 4 | - Conflict resolvers idea and code 5 | - Added vector clock on objects. 6 | 7 | ##guilhermeblanco - https://github.com/guilhermeblanco 8 | - Improving the names and API in general. 9 | 10 | ##chobie - https://github.com/chobie 11 | - PHP-5.3 compatability 12 | 13 | ##weltling - https://github.com/weltling 14 | - Windows compatibility 15 | -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | // vim:ft=javascript 3 | 4 | ARG_ENABLE("riak", "Riak php support", "no"); 5 | if (PHP_RIAK != "no") { 6 | if (CHECK_HEADER_ADD_INCLUDE("riack.h", "CFLAGS_RIAK", PHP_RIAK + ";" + configure_module_dirname + "/LibRiack/src")) 7 | { 8 | EXTENSION("riak", "php_riak.c riak_session.c ht_utils.c ", true, "/I" + configure_module_dirname + "/LibRiack/src"); 9 | ADD_SOURCES(configure_module_dirname + "/riak", "connection.c bucket.c object.c bucket_properties.c pool.c link.c pool_info.c object_list.c server_info.c", "riak"); 10 | ADD_SOURCES(configure_module_dirname + "/riak/map_reduce", "mapreduce.c", "riak"); 11 | ADD_SOURCES(configure_module_dirname + "/riak/map_reduce/input", "input.c bucket_input.c key_data_list_input.c key_list_input.c", "riak"); 12 | ADD_SOURCES(configure_module_dirname + "/riak/map_reduce/output", "output.c stream_output.c", "riak"); 13 | ADD_SOURCES(configure_module_dirname + "/riak/map_reduce/phase", "phase.c map_phase.c reduce_phase.c", "riak"); 14 | ADD_SOURCES(configure_module_dirname + "/riak/map_reduce/functions", "base_function.c erlang_function.c javascript_function.c", "riak"); 15 | ADD_SOURCES(configure_module_dirname + "/riak/output", "output.c get_output.c put_output.c key_stream_output.c index_result.c index_result_list.c index_output.c conflict_resolver.c youngest_sibling_resolver.c", "riak"); 16 | ADD_SOURCES(configure_module_dirname + "/riak/input", "input.c delete_input.c get_input.c put_input.c index_input.c get_resolver_input.c", "riak"); 17 | ADD_SOURCES(configure_module_dirname + "/riak/exception", "exception.c", "riak"); 18 | ADD_SOURCES(configure_module_dirname + "/riak/crdt", "counter.c", "riak"); 19 | ADD_SOURCES(configure_module_dirname + "/riak/crdt/input", "update_input.c get_input.c", "riak"); 20 | ADD_SOURCES(configure_module_dirname + "/riak/search", "search.c", "riak"); 21 | ADD_SOURCES(configure_module_dirname + "/riak/query", "index_query.c", "riak"); 22 | ADD_SOURCES(configure_module_dirname + "/riak/search/input", "parameter_bag.c", "riak"); 23 | ADD_SOURCES(configure_module_dirname + "/riak/search/output", "output.c document_output.c", "riak"); 24 | ADD_SOURCES(configure_module_dirname + "/riak/property", "module_function.c commit_hook.c commit_hook_list.c", "riak"); 25 | ADD_SOURCES(configure_module_dirname + "/riak/property/replication_mode", "replication_mode.c", "riak"); 26 | ADD_SOURCES(configure_module_dirname + "/LibRiack/src", "riack_sock.c riack.c riack_kv.c riack_search.c riack_msg.c riack_mem.c riack_helpers.c riack_2i.c riack_crdt.c riack_commands.c riack_mapreduce.c", "riak"); 27 | ADD_SOURCES(configure_module_dirname + "/LibRiack/src/protobuf-c", "protobuf-c.c", "riak"); 28 | ADD_SOURCES(configure_module_dirname + "/LibRiack/src/protocol", "riak_msg_codes.c riak_search.pb-c.c riak.pb-c.c riak_kv.pb-c.c riak_yokozuna.pb-c.c riak_dt.pb-c.c", "riak"); 29 | 30 | ADD_FLAG("CFLAGS_RIAK", "/I " + configure_module_dirname); 31 | ADD_FLAG("CFLAGS_RIAK", "/D riack_EXPORTS"); 32 | AC_DEFINE('HAVE_RIAK', 1); 33 | AC_DEFINE('PHP_RIAK_SESSION', 1); 34 | ADD_EXTENSION_DEP('riak', 'json'); 35 | ADD_EXTENSION_DEP('riak', 'spl'); 36 | ADD_EXTENSION_DEP('riak', 'session'); 37 | } else { 38 | WARNING("Riack header not found, did you remember to checkout the LibRiack submodule?"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | php-riak (0.5.0-2) unstable; urgency=low 2 | 3 | * Typofix: install riak.ini to the proper directory 4 | 5 | -- Andras Elso Thu, 29 Aug 2013 11:43:26 +0200 6 | 7 | php-riak (0.5.0-1) unstable; urgency=low 8 | 9 | * Initial Release. 10 | 11 | -- Andras Elso Mon, 05 Aug 2013 11:02:34 +0200 12 | 13 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: php-riak 2 | Section: web 3 | Priority: optional 4 | Maintainer: Kaspar Pedersen 5 | Build-Depends: debhelper (>= 7), po-debconf, php5-dev 6 | Standards-Version: 3.8.1 7 | 8 | Package: php5-riak 9 | Architecture: any 10 | Depends: ${shlibs:Depends}, ${php:Depends}, ${misc:Depends} 11 | Description: riak module for PHP 5 12 | Riak database PHP extension 13 | . 14 | Fast protocol buffers client for Riak database and session module. 15 | 16 | 17 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Andras Elso 2 | on Mon, 05 Aug 2013 11:02:34 +0200. 3 | 4 | It was downloaded from http://pecl.php.net/package/riak 5 | 6 | Upstream Author(s): 7 | 8 | Kaspar Bach Pedersen 9 | 10 | Copyright: 11 | 12 | Copyright (C) 2013 Kaspar Bach Pedersen 13 | 14 | License: 15 | 16 | Apache 2 17 | 18 | The Debian packaging is copyright 2009, Andras Elso and 19 | is licensed under the GPL, see `/usr/share/common-licenses/GPL'. 20 | 21 | -------------------------------------------------------------------------------- /debian/php5-riak.dirs: -------------------------------------------------------------------------------- 1 | usr/lib/php5 2 | -------------------------------------------------------------------------------- /debian/riak.ini: -------------------------------------------------------------------------------- 1 | extension=riak.so 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | export DH_VERBOSE=1 3 | 4 | DESTDIR=$(CURDIR)/debian/php5-riak 5 | 6 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 7 | 8 | CFLAGS += -O2 -Wall -fno-strict-aliasing 9 | 10 | # Enable IEEE-conformant floating point math on alphas (not the default) 11 | ifeq (alpha-linux-gnu,$(DEB_HOST_GNU_TYPE)) 12 | CFLAGS += -mieee 13 | endif 14 | 15 | ifeq ($(DEB_HOST_GNU_TYPE), $(findstring $(DEB_HOST_GNU_TYPE), ia64-linux-gnu powerpc64-linux-gnu)) 16 | CFLAGS += -g 17 | else 18 | CFLAGS += -gstabs 19 | endif 20 | 21 | configure: configure-stamp 22 | configure-stamp: 23 | phpize5 24 | ./configure --prefix=/usr --with-php-config=/usr/bin/php-config5 25 | touch $@ 26 | 27 | build-arch: 28 | build-indep: 29 | build: build-stamp 30 | 31 | build-stamp: configure 32 | $(MAKE) DESTDIR=$(DESTDIR) 33 | touch $@ 34 | 35 | clean: 36 | dh_testdir 37 | dh_testroot 38 | rm -rf configure-stamp build-stamp 39 | [ ! -f Makefile ] || $(MAKE) distclean 40 | phpize --clean 41 | dh_clean 42 | 43 | install: 44 | dh_testdir 45 | dh_testroot 46 | dh_prep 47 | $(MAKE) install INSTALL_ROOT=$(DESTDIR) 48 | install -D -m 644 debian/riak.ini \ 49 | debian/php5-riak/etc/php5/conf.d/riak.ini 50 | 51 | check: build 52 | $(MAKE) test 53 | 54 | binary-indep: install 55 | 56 | binary-arch: install 57 | dh_testdir 58 | dh_testroot 59 | dh_installdirs -a 60 | dh_installchangelogs -a 61 | dh_installdocs -a 62 | dh_installexamples -a 63 | dh_install -a 64 | dh_link -a 65 | dh_strip -a 66 | dh_compress -a 67 | dh_fixperms -a 68 | dh_installdeb -a 69 | dh_shlibdeps -a 70 | echo "php:Depends=phpapi-`php-config5 --phpapi`" >> debian/php5-riak.substvars 71 | dh_gencontrol -a 72 | dh_md5sums -a 73 | dh_builddeb -a 74 | 75 | binary: binary-indep binary-arch 76 | .PHONY: clean binary-indep binary-arch binary install 77 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | http://pecl.php.net/package/riak \ 3 | /get/riak-([\d\.]*).tgz debian uupdate 4 | -------------------------------------------------------------------------------- /ht_utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2012 Trifork A/S 3 | Author: Kaspar Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #include "ht_utils.h" 19 | 20 | void foreach_in_hashtable(void* callingObj, void* custom_ptr, HashTable *ht, ht_entry_callback cb TSRMLS_DC) 21 | { 22 | zval **data; 23 | HashPosition pointer; 24 | HashTable *hindex = ht; 25 | uint key_len, key_type; 26 | ulong index; 27 | int cnt = 0; 28 | char *key; 29 | for(zend_hash_internal_pointer_reset_ex(hindex, &pointer); 30 | zend_hash_get_current_data_ex(hindex, (void**)&data, &pointer) == SUCCESS; 31 | zend_hash_move_forward_ex(hindex, &pointer)) { 32 | key_type = zend_hash_get_current_key_ex(hindex, &key, &key_len, &index, 0, &pointer); 33 | if (key_type == HASH_KEY_IS_STRING) { 34 | (*cb)(callingObj, custom_ptr, key, key_len, 0, data, &cnt TSRMLS_CC); 35 | cnt++; 36 | } else if (key_type == HASH_KEY_IS_LONG) { 37 | (*cb)(callingObj, custom_ptr, NULL, 0, index, data, &cnt TSRMLS_CC); 38 | cnt++; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ht_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_HT__UTILS__H__ 19 | #define RIAK_HT__UTILS__H__ 20 | 21 | #include 22 | 23 | typedef void (*ht_entry_callback)(void* callingObj, void* custom_ptr, char* key, uint keylen, uint index, zval** data, int *cnt TSRMLS_DC); 24 | 25 | void foreach_in_hashtable(void* callingObj, void* custom_ptr, HashTable* ht, ht_entry_callback cb TSRMLS_DC); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /leak-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export PHP=`which php` 3 | export TEST_PHP_EXECUTABLE=$PHP 4 | 5 | $PHP run-tests.php -q -m --show-diff 6 | find . -name *.mem | xargs cat 7 | -------------------------------------------------------------------------------- /php_riak.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef PHP_RIAK__H__ 19 | #define PHP_RIAK__H__ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #define PHP_RIAK_EXTNAME "riak" 26 | #define PHP_RIAK_VERSION "1.2.0" 27 | 28 | PHP_MINIT_FUNCTION(riak); 29 | PHP_MSHUTDOWN_FUNCTION(riak); 30 | 31 | PHP_GINIT_FUNCTION(riak); 32 | PHP_GSHUTDOWN_FUNCTION(riak); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /riak/bucket.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_BUCKET__H__ 19 | #define RIAK_BUCKET__H__ 20 | 21 | #include "php_riak_internal.h" 22 | #include "connection.h" 23 | 24 | extern zend_class_entry *riak_bucket_ce; 25 | 26 | zval* create_bucket_object(zval* zclient, char* name, int name_len TSRMLS_DC); 27 | 28 | void riak_bucket_init(TSRMLS_D); 29 | 30 | PHP_METHOD(RiakBucket, __construct); 31 | PHP_METHOD(RiakBucket, setPropertyList); 32 | PHP_METHOD(RiakBucket, getPropertyList); 33 | PHP_METHOD(RiakBucket, put); 34 | PHP_METHOD(RiakBucket, get); 35 | PHP_METHOD(RiakBucket, delete); 36 | PHP_METHOD(RiakBucket, index); 37 | PHP_METHOD(RiakBucket, indexQuery); 38 | PHP_METHOD(RiakBucket, counter); 39 | 40 | PHP_METHOD(RiakBucket, getKeyStream); 41 | PHP_METHOD(RiakBucket, getKeyList); 42 | PHP_METHOD(RiakBucket, getName); 43 | PHP_METHOD(RiakBucket, getType); 44 | PHP_METHOD(RiakBucket, getConnection); 45 | 46 | PHP_METHOD(RiakBucket, getConflictResolver); 47 | PHP_METHOD(RiakBucket, setConflictResolver); 48 | 49 | riak_connection *get_riak_connection(zval *zbucket TSRMLS_DC); 50 | zval* object_from_riak_content(zval* key, riack_content* content TSRMLS_DC); 51 | riack_string riack_name_from_bucket(zval* bucket TSRMLS_DC); 52 | riack_string *riack_get_bucket_type_from_bucket(riack_client *client, zval* bucket TSRMLS_DC); 53 | void riak_name_from_bucket(zval* bucket, char **name, int *namelen TSRMLS_DC); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /riak/bucket_properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_BUCKET__PROPERTIES__H__ 19 | #define RIAK_BUCKET__PROPERTIES__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_bucket_properties_ce; 24 | 25 | void riak_bucket_props_init(TSRMLS_D); 26 | 27 | PHP_METHOD(RiakBucketProperties, __construct); 28 | 29 | PHP_METHOD(RiakBucketProperties, getNValue); 30 | PHP_METHOD(RiakBucketProperties, setNValue); 31 | PHP_METHOD(RiakBucketProperties, getAllowMult); 32 | PHP_METHOD(RiakBucketProperties, setAllowMult); 33 | PHP_METHOD(RiakBucketProperties, getLastWriteWins); 34 | PHP_METHOD(RiakBucketProperties, setLastWriteWins); 35 | PHP_METHOD(RiakBucketProperties, getOldVClock); 36 | PHP_METHOD(RiakBucketProperties, setOldVClock); 37 | PHP_METHOD(RiakBucketProperties, getYoungVClock); 38 | PHP_METHOD(RiakBucketProperties, setYoungVClock); 39 | PHP_METHOD(RiakBucketProperties, getSmallVClock); 40 | PHP_METHOD(RiakBucketProperties, setSmallVClock); 41 | PHP_METHOD(RiakBucketProperties, getBigVClock); 42 | PHP_METHOD(RiakBucketProperties, setBigVClock); 43 | PHP_METHOD(RiakBucketProperties, getR); 44 | PHP_METHOD(RiakBucketProperties, setR); 45 | PHP_METHOD(RiakBucketProperties, getPR); 46 | PHP_METHOD(RiakBucketProperties, setPR); 47 | PHP_METHOD(RiakBucketProperties, getW); 48 | PHP_METHOD(RiakBucketProperties, setW); 49 | PHP_METHOD(RiakBucketProperties, getDW); 50 | PHP_METHOD(RiakBucketProperties, setDW); 51 | PHP_METHOD(RiakBucketProperties, getPW); 52 | PHP_METHOD(RiakBucketProperties, setPW); 53 | PHP_METHOD(RiakBucketProperties, getRW); 54 | PHP_METHOD(RiakBucketProperties, setRW); 55 | 56 | PHP_METHOD(RiakBucketProperties, getBasicQuorum); 57 | PHP_METHOD(RiakBucketProperties, setBasicQuorum); 58 | PHP_METHOD(RiakBucketProperties, getNotFoundOk); 59 | PHP_METHOD(RiakBucketProperties, setNotFoundOk); 60 | PHP_METHOD(RiakBucketProperties, getSearchEnabled); 61 | PHP_METHOD(RiakBucketProperties, setSearchEnabled); 62 | PHP_METHOD(RiakBucketProperties, setBackend); 63 | PHP_METHOD(RiakBucketProperties, getBackend); 64 | PHP_METHOD(RiakBucketProperties, setPreCommitHookList); 65 | PHP_METHOD(RiakBucketProperties, getPreCommitHookList); 66 | PHP_METHOD(RiakBucketProperties, setPostCommitHookList); 67 | PHP_METHOD(RiakBucketProperties, getPostCommitHookList); 68 | PHP_METHOD(RiakBucketProperties, setCHashKeyFun); 69 | PHP_METHOD(RiakBucketProperties, getCHashKeyFun); 70 | PHP_METHOD(RiakBucketProperties, setLinkFun); 71 | PHP_METHOD(RiakBucketProperties, getLinkFun); 72 | 73 | PHP_METHOD(RiakBucketProperties, getReplicationMode); 74 | PHP_METHOD(RiakBucketProperties, setReplicationMode); 75 | 76 | PHP_METHOD(RiakBucketProperties, isConsistent); 77 | PHP_METHOD(RiakBucketProperties, setConsistent); 78 | PHP_METHOD(RiakBucketProperties, getDatatype); 79 | PHP_METHOD(RiakBucketProperties, setDatatype); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /riak/connection.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_CONNECTION__H__ 19 | #define RIAK_CONNECTION__H__ 20 | 21 | #include "php_riak_internal.h" 22 | #include "pool.h" 23 | 24 | extern zend_class_entry *riak_connection_ce; 25 | 26 | typedef struct _client_data { 27 | /* required */ 28 | zend_object std; 29 | 30 | riak_connection *connection; 31 | } client_data; 32 | 33 | /************************************************* 34 | * Constants 35 | *************************************************/ 36 | #define DEFAULT_HOST "127.0.0.1" 37 | #define DEFAULT_PORT 8087 38 | 39 | /************************************************* 40 | * Functions 41 | *************************************************/ 42 | 43 | zval* create_client_object(char* host, long port TSRMLS_DC); 44 | 45 | void riak_connection_init(TSRMLS_D); 46 | int create_object_connection(zval* zConn TSRMLS_DC); 47 | riak_connection *get_client_connection(zval *zclient TSRMLS_DC); 48 | zend_object_value create_client_data(zend_class_entry *class_type TSRMLS_DC); 49 | void free_client_data(void *object TSRMLS_DC); 50 | 51 | PHP_METHOD(RiakConnection, __construct); 52 | PHP_METHOD(RiakConnection, ping); 53 | PHP_METHOD(RiakConnection, getHost); 54 | PHP_METHOD(RiakConnection, getPort); 55 | PHP_METHOD(RiakConnection, getBucket); 56 | PHP_METHOD(RiakConnection, getServerInfo); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /riak/crdt/counter.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK__CRDT__COUNTER__H__ 19 | #define RIAK__CRDT__COUNTER__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_crdt_counter_ce; 24 | 25 | void riak_crdt_counter_init(TSRMLS_D); 26 | 27 | PHP_METHOD(Riak_Crdt_Counter, __construct); 28 | 29 | PHP_METHOD(Riak_Crdt_Counter, increment); 30 | PHP_METHOD(Riak_Crdt_Counter, incrementAndGet); 31 | PHP_METHOD(Riak_Crdt_Counter, get); 32 | 33 | #endif // RIAK__CRDT__COUNTER__H__ 34 | -------------------------------------------------------------------------------- /riak/crdt/input/get_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK__CRDT__INPUT__GET_INPUT__H__ 19 | #define RIAK__CRDT__INPUT__GET_INPUT__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_crdt_input_get_ce; 24 | 25 | void riak_crdt_input_get_input_init(TSRMLS_D); 26 | 27 | PHP_METHOD(Riak_Crdt_Input_GetInput, getR); 28 | PHP_METHOD(Riak_Crdt_Input_GetInput, setR); 29 | PHP_METHOD(Riak_Crdt_Input_GetInput, getPR); 30 | PHP_METHOD(Riak_Crdt_Input_GetInput, setPR); 31 | PHP_METHOD(Riak_Crdt_Input_GetInput, getBasicQuorum); 32 | PHP_METHOD(Riak_Crdt_Input_GetInput, setBasicQuorum); 33 | PHP_METHOD(Riak_Crdt_Input_GetInput, getNotFoundOk); 34 | PHP_METHOD(Riak_Crdt_Input_GetInput, setNotFoundOk); 35 | 36 | #endif // RIAK__CRDT__INPUT__GET_INPUT__H__ 37 | -------------------------------------------------------------------------------- /riak/crdt/input/update_input.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | #include "update_input.h" 18 | 19 | zend_class_entry *riak_crdt_input_update_ce; 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_crdt_input_update_noargs, 0, ZEND_RETURN_VALUE, 0) 22 | ZEND_END_ARG_INFO() 23 | 24 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_crdt_input_update_set_w, 0, ZEND_RETURN_VALUE, 1) 25 | ZEND_ARG_INFO(0, w) 26 | ZEND_END_ARG_INFO() 27 | 28 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_crdt_input_update_set_dw, 0, ZEND_RETURN_VALUE, 1) 29 | ZEND_ARG_INFO(0, dw) 30 | ZEND_END_ARG_INFO() 31 | 32 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_crdt_input_update_set_pw, 0, ZEND_RETURN_VALUE, 1) 33 | ZEND_ARG_INFO(0, pw) 34 | ZEND_END_ARG_INFO() 35 | 36 | static zend_function_entry riak_crdt_input_update_methods[] = { 37 | PHP_ME(Riak_Crdt_Input_UpdateInput, setW, arginfo_riak_crdt_input_update_set_w, ZEND_ACC_PUBLIC) 38 | PHP_ME(Riak_Crdt_Input_UpdateInput, getW, arginfo_riak_crdt_input_update_noargs, ZEND_ACC_PUBLIC) 39 | PHP_ME(Riak_Crdt_Input_UpdateInput, setDW, arginfo_riak_crdt_input_update_set_dw, ZEND_ACC_PUBLIC) 40 | PHP_ME(Riak_Crdt_Input_UpdateInput, getDW, arginfo_riak_crdt_input_update_noargs, ZEND_ACC_PUBLIC) 41 | PHP_ME(Riak_Crdt_Input_UpdateInput, setPW, arginfo_riak_crdt_input_update_set_pw, ZEND_ACC_PUBLIC) 42 | PHP_ME(Riak_Crdt_Input_UpdateInput, getPW, arginfo_riak_crdt_input_update_noargs, ZEND_ACC_PUBLIC) 43 | {NULL, NULL, NULL} 44 | }; 45 | 46 | 47 | void riak_crdt_input_update_input_init(TSRMLS_D)/* {{{ */ 48 | { 49 | zend_class_entry ce; 50 | 51 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Crdt\\Input", "UpdateInput", riak_crdt_input_update_methods); 52 | riak_crdt_input_update_ce = zend_register_internal_class(&ce TSRMLS_CC); 53 | zend_declare_property_null(riak_crdt_input_update_ce, "w", sizeof("w")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 54 | zend_declare_property_null(riak_crdt_input_update_ce, "dw", sizeof("dw")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 55 | zend_declare_property_null(riak_crdt_input_update_ce, "pw", sizeof("pw")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 56 | }/* }}} */ 57 | 58 | 59 | /* {{{ proto int|null Riak\Crdt\Input\UpdateInput->getW() 60 | Gets W value */ 61 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, getW) 62 | { 63 | RIAK_GETTER_LONG(riak_crdt_input_update_ce, "w"); 64 | } 65 | /* }}} */ 66 | 67 | /* {{{ proto Riak\Crdt\Input\UpdateInput Riak\Crdt\Input\UpdateInput->setW(int $w) 68 | Set W value */ 69 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, setW) 70 | { 71 | RIAK_SETTER_LONG(riak_crdt_input_update_ce, "w"); 72 | RIAK_RETURN_THIS 73 | } 74 | /* }}} */ 75 | 76 | /* {{{ proto int|null Riak\Crdt\Input\UpdateInput->getDW() 77 | Gets DW value */ 78 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, getDW) 79 | { 80 | RIAK_GETTER_LONG(riak_crdt_input_update_ce, "dw"); 81 | } 82 | /* }}} */ 83 | 84 | /* {{{ proto Riak\Crdt\Input\UpdateInput Riak\Crdt\Input\UpdateInput->setDW(int $dw) 85 | Set DW value */ 86 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, setDW) 87 | { 88 | RIAK_SETTER_LONG(riak_crdt_input_update_ce, "dw"); 89 | RIAK_RETURN_THIS 90 | } 91 | /* }}} */ 92 | 93 | /* {{{ proto int|null Riak\Crdt\Input\UpdateInput->getPW() 94 | Gets PW value */ 95 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, getPW) 96 | { 97 | RIAK_GETTER_LONG(riak_crdt_input_update_ce, "pw"); 98 | } 99 | /* }}} */ 100 | 101 | /* {{{ proto Riak\Crdt\Input\UpdateInput Riak\Crdt\Input\UpdateInput->setPW(int $pw) 102 | Set PW value */ 103 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, setPW) 104 | { 105 | RIAK_SETTER_LONG(riak_crdt_input_update_ce, "pw"); 106 | RIAK_RETURN_THIS 107 | } 108 | /* }}} */ 109 | 110 | -------------------------------------------------------------------------------- /riak/crdt/input/update_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK__CRDT__INPUT__UPDATE_INPUT__H__ 19 | #define RIAK__CRDT__INPUT__UPDATE_INPUT__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_crdt_input_update_ce; 24 | 25 | void riak_crdt_input_update_input_init(TSRMLS_D); 26 | 27 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, getW); 28 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, setW); 29 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, getDW); 30 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, setDW); 31 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, getPW); 32 | PHP_METHOD(Riak_Crdt_Input_UpdateInput, setPW); 33 | 34 | #endif // RIAK__CRDT__INPUT__UPDATE_INPUT__H__ 35 | -------------------------------------------------------------------------------- /riak/exception/exception.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2012 Trifork A/S 3 | Author: Kaspar Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #include "exception.h" 19 | 20 | zend_class_entry *riak_exception_ce; 21 | 22 | zend_class_entry *riak_badarguments_exception_ce; 23 | zend_class_entry *riak_connection_exception_ce; 24 | zend_class_entry *riak_communication_exception_ce; 25 | zend_class_entry *riak_response_exception_ce; 26 | zend_class_entry *riak_nonunique_exception_ce; 27 | zend_class_entry *riak_unresolvedconflict_exception_ce; 28 | 29 | void riak_exceptions_init(TSRMLS_D) 30 | { 31 | zend_class_entry ceBadArgs, ceRiak, ceConnExc, ceCommExc, ceRespExc; 32 | 33 | INIT_NS_CLASS_ENTRY(ceRiak, "Riak\\Exception", "RiakException", NULL); 34 | riak_exception_ce = zend_register_internal_class_ex(&ceRiak, 35 | (zend_class_entry*)zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC); 36 | 37 | INIT_NS_CLASS_ENTRY(ceBadArgs, "Riak\\Exception", "BadArgumentsException", NULL); 38 | riak_badarguments_exception_ce = zend_register_internal_class_ex(&ceBadArgs, 39 | riak_exception_ce, NULL TSRMLS_CC); 40 | 41 | INIT_NS_CLASS_ENTRY(ceConnExc, "Riak\\Exception", "ConnectionException", NULL); 42 | riak_connection_exception_ce = zend_register_internal_class_ex(&ceConnExc, 43 | riak_exception_ce, NULL TSRMLS_CC); 44 | 45 | INIT_NS_CLASS_ENTRY(ceCommExc, "Riak\\Exception","CommunicationException", NULL); 46 | riak_communication_exception_ce = zend_register_internal_class_ex(&ceCommExc, 47 | riak_exception_ce, NULL TSRMLS_CC); 48 | 49 | INIT_NS_CLASS_ENTRY(ceRespExc, "Riak\\Exception", "UnexpectedResponseException", NULL); 50 | riak_response_exception_ce = zend_register_internal_class_ex(&ceRespExc, 51 | riak_exception_ce, NULL TSRMLS_CC); 52 | 53 | INIT_NS_CLASS_ENTRY(ceRespExc, "Riak\\Exception", "NonUniqueException", NULL); 54 | riak_nonunique_exception_ce = zend_register_internal_class_ex(&ceRespExc, 55 | riak_exception_ce, NULL TSRMLS_CC); 56 | 57 | INIT_NS_CLASS_ENTRY(ceRespExc, "Riak\\Exception", "UnresolvedConflictException", NULL); 58 | riak_unresolvedconflict_exception_ce = zend_register_internal_class_ex(&ceRespExc, 59 | riak_exception_ce, NULL TSRMLS_CC); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /riak/exception/exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_EXCEPTIONS__H__ 19 | #define RIAK_EXCEPTIONS__H__ 20 | 21 | #include "php_riak_internal.h" 22 | #include 23 | 24 | extern zend_class_entry *riak_badarguments_exception_ce; 25 | 26 | extern zend_class_entry *riak_connection_exception_ce; 27 | extern zend_class_entry *riak_communication_exception_ce; 28 | extern zend_class_entry *riak_response_exception_ce; 29 | extern zend_class_entry *riak_nonunique_exception_ce; 30 | extern zend_class_entry *riak_unresolvedconflict_exception_ce; 31 | 32 | void riak_exceptions_init(TSRMLS_D); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /riak/input/delete_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_INPUT__DELETE_INPUT__H__ 18 | #define RIAK_INPUT__DELETE_INPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_delete_input_ce; 23 | 24 | void riak_input_delete_input_init(TSRMLS_D); 25 | 26 | /* Riak\Input\DeleteInput */ 27 | PHP_METHOD(Riak_Input_DeleteInput, setR); 28 | PHP_METHOD(Riak_Input_DeleteInput, getR); 29 | PHP_METHOD(Riak_Input_DeleteInput, setPR); 30 | PHP_METHOD(Riak_Input_DeleteInput, getPR); 31 | PHP_METHOD(Riak_Input_DeleteInput, setRW); 32 | PHP_METHOD(Riak_Input_DeleteInput, getRW); 33 | PHP_METHOD(Riak_Input_DeleteInput, setW); 34 | PHP_METHOD(Riak_Input_DeleteInput, getW); 35 | PHP_METHOD(Riak_Input_DeleteInput, setDW); 36 | PHP_METHOD(Riak_Input_DeleteInput, getDW); 37 | PHP_METHOD(Riak_Input_DeleteInput, setPW); 38 | PHP_METHOD(Riak_Input_DeleteInput, getPW); 39 | PHP_METHOD(Riak_Input_DeleteInput, setVClock); 40 | PHP_METHOD(Riak_Input_DeleteInput, getVClock); 41 | 42 | 43 | #endif //RIAK_INPUT__DELETE_INPUT__H__ 44 | -------------------------------------------------------------------------------- /riak/input/get_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_INPUT__GET_INPUT__H__ 18 | #define RIAK_INPUT__GET_INPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_get_input_ce; 23 | 24 | void riak_input_get_input_init(TSRMLS_D); 25 | 26 | 27 | /* Riak\Input\GetInput */ 28 | PHP_METHOD(Riak_Input_GetInput, setReturnHead); 29 | PHP_METHOD(Riak_Input_GetInput, getReturnHead); 30 | PHP_METHOD(Riak_Input_GetInput, getR); 31 | PHP_METHOD(Riak_Input_GetInput, setR); 32 | PHP_METHOD(Riak_Input_GetInput, getPR); 33 | PHP_METHOD(Riak_Input_GetInput, setPR); 34 | PHP_METHOD(Riak_Input_GetInput, getBasicQuorum); 35 | PHP_METHOD(Riak_Input_GetInput, setBasicQuorum); 36 | PHP_METHOD(Riak_Input_GetInput, getNotFoundOk); 37 | PHP_METHOD(Riak_Input_GetInput, setNotFoundOk); 38 | PHP_METHOD(Riak_Input_GetInput, getIfModifiedVClock); 39 | PHP_METHOD(Riak_Input_GetInput, setIfModifiedVClock); 40 | PHP_METHOD(Riak_Input_GetInput, getReturnDeletedVClock); 41 | PHP_METHOD(Riak_Input_GetInput, setReturnDeletedVClock); 42 | 43 | 44 | 45 | #endif //RIAK_INPUT__GET_INPUT__H__ 46 | -------------------------------------------------------------------------------- /riak/input/get_resolver_input.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "riak/output/conflict_resolver.h" 18 | #include "get_resolver_input.h" 19 | #include "get_input.h" 20 | 21 | zend_class_entry *riak_get_resolver_input_ce; 22 | 23 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_get_resolver_input_noargs, 0, ZEND_RETURN_VALUE, 0) 24 | ZEND_END_ARG_INFO() 25 | 26 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_get_resolver_input_ctor, 0, ZEND_RETURN_VALUE, 2) 27 | ZEND_ARG_OBJ_INFO(0, resolver, Riak\\Output\\ConflictResolver, 0) 28 | ZEND_END_ARG_INFO() 29 | 30 | static zend_function_entry riak_get_resolver_input_methods[] = { 31 | PHP_ME(Riak_Input_GetResolverInput, __construct, arginfo_riak_get_resolver_input_ctor, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) 32 | PHP_ME(Riak_Input_GetResolverInput, getConflictResolver, arginfo_riak_get_resolver_input_noargs, ZEND_ACC_PUBLIC) 33 | {NULL, NULL, NULL} 34 | }; 35 | 36 | void riak_input_get_resolver_input_init(TSRMLS_D) /* {{{ */ 37 | { 38 | zend_class_entry ce; 39 | 40 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Input", "GetResolverInput", riak_get_resolver_input_methods); 41 | 42 | riak_get_resolver_input_ce = zend_register_internal_class_ex(&ce, riak_get_input_ce, NULL TSRMLS_CC); 43 | 44 | zend_declare_property_null(riak_get_resolver_input_ce, "conflictResolver", sizeof("conflictResolver")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 45 | } 46 | /* }}} */ 47 | 48 | /************************************************************************* 49 | * Implementation: Riak\Input\GetResolverInput extends Riak\Input\GetInput 50 | **************************************************************************/ 51 | 52 | /* {{{ proto void Riak\Input\GetResolverInput->__construct(Riak\Output\ConflictResolver $resolver) 53 | Create a new Riak\Input\GetResolverInput */ 54 | PHP_METHOD(Riak_Input_GetResolverInput, __construct) 55 | { 56 | zval* zResolver; 57 | 58 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zResolver, riak_output_conflict_resolver_ce) == FAILURE) { 59 | return; 60 | } 61 | 62 | zend_update_property(riak_get_resolver_input_ce, getThis(), "conflictResolver", sizeof("conflictResolver")-1, zResolver TSRMLS_CC); 63 | } 64 | /* }}} */ 65 | 66 | /* {{{ proto Riak\Output\ConflictResolver Riak\Input\GetResolverInput->getConflictResolver() */ 67 | PHP_METHOD(Riak_Input_GetResolverInput, getConflictResolver) 68 | { 69 | RIAK_GETTER_OBJECT(riak_get_resolver_input_ce, "conflictResolver"); 70 | } 71 | /* }}} */ 72 | -------------------------------------------------------------------------------- /riak/input/get_resolver_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_INPUT__GET_RESOLVER_INPUT__H__ 18 | #define RIAK_INPUT__GET_RESOLVER_INPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_get_resolver_input_ce; 23 | 24 | void riak_input_get_resolver_input_init(TSRMLS_D); 25 | 26 | /* Riak\Input\GetResolverInput */ 27 | PHP_METHOD(Riak_Input_GetResolverInput, __construct); 28 | PHP_METHOD(Riak_Input_GetResolverInput, getConflictResolver); 29 | 30 | #endif //RIAK_INPUT__GET_RESOLVER_INPUT__H__ 31 | -------------------------------------------------------------------------------- /riak/input/index_input.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "index_input.h" 18 | #include "input.h" 19 | 20 | zend_class_entry *riak_index_input_ce; 21 | 22 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_index_input_set_continuation, 0, ZEND_RETURN_VALUE, 1) 23 | ZEND_ARG_INFO(0, continuation) 24 | ZEND_END_ARG_INFO() 25 | 26 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_index_input_set_maxresults, 0, ZEND_RETURN_VALUE, 1) 27 | ZEND_ARG_INFO(0, continuation) 28 | ZEND_END_ARG_INFO() 29 | 30 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_index_input_noargs, 0, ZEND_RETURN_VALUE, 0) 31 | ZEND_END_ARG_INFO() 32 | 33 | static zend_function_entry riak_index_input_methods[] = { 34 | PHP_ME(Riak_Input_IndexInput, setContinuation, arginfo_riak_index_input_set_continuation, ZEND_ACC_PUBLIC) 35 | PHP_ME(Riak_Input_IndexInput, getContinuation, arginfo_riak_index_input_noargs, ZEND_ACC_PUBLIC) 36 | PHP_ME(Riak_Input_IndexInput, setMaxResults, arginfo_riak_index_input_set_maxresults, ZEND_ACC_PUBLIC) 37 | PHP_ME(Riak_Input_IndexInput, getMaxResults, arginfo_riak_index_input_noargs, ZEND_ACC_PUBLIC) 38 | {NULL, NULL, NULL} 39 | }; 40 | 41 | 42 | void riak_input_index_input_init(TSRMLS_D) 43 | { 44 | zend_class_entry ce; 45 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Input", "IndexInput", riak_index_input_methods); 46 | riak_index_input_ce = zend_register_internal_class_ex(&ce, riak_input_ce, NULL TSRMLS_CC); 47 | zend_declare_property_null(riak_index_input_ce, "continuation", sizeof("continuation")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 48 | zend_declare_property_null(riak_index_input_ce, "maxResults", sizeof("maxResults")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 49 | } 50 | 51 | PHP_METHOD(Riak_Input_IndexInput, setContinuation) 52 | { 53 | RIAK_SETTER_STRING(riak_index_input_ce, "continuation"); 54 | RIAK_RETURN_THIS 55 | } 56 | 57 | PHP_METHOD(Riak_Input_IndexInput, getContinuation) 58 | { 59 | RIAK_GETTER_STRING(riak_index_input_ce, "continuation"); 60 | } 61 | 62 | PHP_METHOD(Riak_Input_IndexInput, setMaxResults) 63 | { 64 | RIAK_SETTER_LONG(riak_index_input_ce, "maxResults"); 65 | RIAK_RETURN_THIS 66 | } 67 | 68 | PHP_METHOD(Riak_Input_IndexInput, getMaxResults) 69 | { 70 | RIAK_GETTER_LONG(riak_index_input_ce, "maxResults"); 71 | } 72 | -------------------------------------------------------------------------------- /riak/input/index_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_INPUT__INDEX_INPUT__H__ 18 | #define RIAK_INPUT__INDEX_INPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_index_input_ce; 23 | 24 | void riak_input_index_input_init(TSRMLS_D); 25 | 26 | PHP_METHOD(Riak_Input_IndexInput, setContinuation); 27 | PHP_METHOD(Riak_Input_IndexInput, getContinuation); 28 | 29 | PHP_METHOD(Riak_Input_IndexInput, getMaxResults); 30 | PHP_METHOD(Riak_Input_IndexInput, setMaxResults); 31 | 32 | 33 | #endif //RIAK_INPUT__INDEX_INPUT__H__ 34 | -------------------------------------------------------------------------------- /riak/input/input.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "input.h" 18 | 19 | zend_class_entry *riak_input_ce; 20 | 21 | 22 | static zend_function_entry riak_input_methods[] = { 23 | {NULL, NULL, NULL} 24 | }; 25 | 26 | 27 | void riak_input_input_init(TSRMLS_D) /* {{{ */ 28 | { 29 | zend_class_entry ce; 30 | 31 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Input","Input", riak_input_methods); 32 | riak_input_ce = zend_register_internal_class(&ce TSRMLS_CC); 33 | } 34 | /* }}} */ 35 | 36 | -------------------------------------------------------------------------------- /riak/input/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_INPUT__INPUT__H__ 18 | #define RIAK_INPUT__INPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_input_ce; 23 | 24 | void riak_input_input_init(TSRMLS_D); 25 | 26 | #endif //RIAK_INPUT__INPUT__H__ 27 | -------------------------------------------------------------------------------- /riak/input/put_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_INPUT__PUT_INPUT__H__ 18 | #define RIAK_INPUT__PUT_INPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_put_input_ce; 23 | 24 | void riak_input_put_input_init(TSRMLS_D); 25 | 26 | /* Riak\Input\PutInput */ 27 | PHP_METHOD(Riak_Input_PutInput, setReturnHead); 28 | PHP_METHOD(Riak_Input_PutInput, getReturnHead); 29 | PHP_METHOD(Riak_Input_PutInput, getW); 30 | PHP_METHOD(Riak_Input_PutInput, setW); 31 | PHP_METHOD(Riak_Input_PutInput, getDW); 32 | PHP_METHOD(Riak_Input_PutInput, setDW); 33 | PHP_METHOD(Riak_Input_PutInput, getPW); 34 | PHP_METHOD(Riak_Input_PutInput, setPW); 35 | PHP_METHOD(Riak_Input_PutInput, getVClock); 36 | PHP_METHOD(Riak_Input_PutInput, setVClock); 37 | PHP_METHOD(Riak_Input_PutInput, getReturnBody); 38 | PHP_METHOD(Riak_Input_PutInput, setReturnBody); 39 | PHP_METHOD(Riak_Input_PutInput, getIfNoneMatch); 40 | PHP_METHOD(Riak_Input_PutInput, setIfNoneMatch); 41 | PHP_METHOD(Riak_Input_PutInput, getIfNotModified); 42 | PHP_METHOD(Riak_Input_PutInput, setIfNotModified); 43 | 44 | 45 | #endif //RIAK_INPUT__PUT_INPUT__H__ 46 | -------------------------------------------------------------------------------- /riak/link.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2012 Trifork A/S 3 | Author: Kaspar Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #include "link.h" 19 | 20 | zend_class_entry *riak_link_ce; 21 | 22 | ZEND_BEGIN_ARG_INFO_EX(arginfo_link_ctor, 0, ZEND_RETURN_VALUE, 3) 23 | ZEND_ARG_INFO(0, tag) 24 | ZEND_ARG_INFO(0, bucket) 25 | ZEND_ARG_INFO(0, key) 26 | ZEND_END_ARG_INFO() 27 | 28 | ZEND_BEGIN_ARG_INFO_EX(arginfo_link_noargs, 0, ZEND_RETURN_VALUE, 0) 29 | ZEND_END_ARG_INFO() 30 | 31 | static zend_function_entry riak_link_methods[] = { 32 | PHP_ME(RiakLink, __construct, arginfo_link_ctor, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) 33 | PHP_ME(RiakLink, getTag, arginfo_link_noargs, ZEND_ACC_PUBLIC) 34 | PHP_ME(RiakLink, getBucketName, arginfo_link_noargs, ZEND_ACC_PUBLIC) 35 | PHP_ME(RiakLink, getKey, arginfo_link_noargs, ZEND_ACC_PUBLIC) 36 | {NULL, NULL, NULL} 37 | }; 38 | 39 | void riak_link_init(TSRMLS_D)/* {{{ */ 40 | { 41 | zend_class_entry ce; 42 | 43 | INIT_NS_CLASS_ENTRY(ce, "Riak", "Link", riak_link_methods); 44 | riak_link_ce = zend_register_internal_class(&ce TSRMLS_CC); 45 | 46 | zend_declare_property_null(riak_link_ce, "tag", sizeof("tag")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 47 | zend_declare_property_null(riak_link_ce, "bucket", sizeof("bucket")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 48 | zend_declare_property_null(riak_link_ce, "key", sizeof("key")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 49 | } 50 | /* }}} */ 51 | 52 | zval* create_link_object(const char* tag, const char *bucket, const char* key TSRMLS_DC)/* {{{ */ 53 | { 54 | zval *zlink, *zbucket, *ztag, *zkey; 55 | 56 | MAKE_STD_ZVAL(zkey); 57 | ZVAL_STRING(zkey, key, 1); 58 | MAKE_STD_ZVAL(zbucket); 59 | ZVAL_STRING(zbucket, bucket, 1); 60 | MAKE_STD_ZVAL(ztag); 61 | ZVAL_STRING(ztag, tag, 1); 62 | 63 | MAKE_STD_ZVAL(zlink); 64 | object_init_ex(zlink, riak_link_ce); 65 | RIAK_CALL_METHOD3(RiakLink, __construct, zlink, zlink, ztag, zbucket, zkey); 66 | 67 | zval_ptr_dtor(&zkey); 68 | zval_ptr_dtor(&zbucket); 69 | zval_ptr_dtor(&ztag); 70 | return zlink; 71 | } 72 | /* }}} */ 73 | 74 | /* {{{ proto void Riak\Link->__construct(string $tag, string $bucket, string $key) 75 | Create a new link */ 76 | PHP_METHOD(RiakLink, __construct) 77 | { 78 | char *key, *bucket, *tag; 79 | int keylen, bucketlen, taglen; 80 | 81 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &tag, &taglen, &bucket, &bucketlen, &key, &keylen) == FAILURE) { 82 | return; 83 | } 84 | zend_update_property_stringl(riak_link_ce, getThis(), "tag", sizeof("tag")-1, tag, taglen TSRMLS_CC); 85 | zend_update_property_stringl(riak_link_ce, getThis(), "bucket", sizeof("bucket")-1, bucket, bucketlen TSRMLS_CC); 86 | zend_update_property_stringl(riak_link_ce, getThis(), "key", sizeof("key")-1, key, keylen TSRMLS_CC); 87 | } 88 | /* }}} */ 89 | 90 | /* {{{ proto string Riak\Link->getTag() */ 91 | PHP_METHOD(RiakLink, getTag) 92 | { 93 | RIAK_GETTER_STRING(riak_link_ce, "tag"); 94 | } 95 | /* }}} */ 96 | 97 | /* {{{ proto string Riak\Link->getBucketName() */ 98 | PHP_METHOD(RiakLink, getBucketName) 99 | { 100 | RIAK_GETTER_STRING(riak_link_ce, "bucket"); 101 | } 102 | /* }}} */ 103 | 104 | /* {{{ proto string Riak\Link->getKey() */ 105 | PHP_METHOD(RiakLink, getKey) 106 | { 107 | RIAK_GETTER_STRING(riak_link_ce, "key"); 108 | } 109 | /* }}} */ 110 | -------------------------------------------------------------------------------- /riak/link.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_LINK__H__ 19 | #define RIAK_LINK__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_link_ce; 24 | 25 | zval* create_link_object(const char* tag, const char *bucket, const char* key TSRMLS_DC); 26 | 27 | void riak_link_init(TSRMLS_D); 28 | 29 | PHP_METHOD(RiakLink, __construct); 30 | 31 | PHP_METHOD(RiakLink, getTag); 32 | PHP_METHOD(RiakLink, getBucketName); 33 | PHP_METHOD(RiakLink, getKey); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /riak/map_reduce/functions/base_function.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "base_function.h" 17 | 18 | zend_class_entry *riak_mrfunction_ce; 19 | 20 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mrfunction_toarray, 0, ZEND_RETURN_VALUE, 0) 21 | ZEND_END_ARG_INFO() 22 | 23 | static zend_function_entry riak_mrfunction_methods[] = { 24 | ZEND_ABSTRACT_ME(RiakMrFunction, toArray, arginfo_mrfunction_toarray) 25 | {NULL, NULL, NULL} 26 | }; 27 | 28 | void riak_map_reduce_functions_base_function_init(TSRMLS_D)/* {{{ */ 29 | { 30 | zend_class_entry ce; 31 | INIT_NS_CLASS_ENTRY(ce, "Riak\\MapReduce\\Functions", "BaseFunction", riak_mrfunction_methods); 32 | riak_mrfunction_ce = zend_register_internal_class(&ce TSRMLS_CC); 33 | } 34 | /* }}} */ 35 | -------------------------------------------------------------------------------- /riak/map_reduce/functions/base_function.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef RIAK_MAP_REDUCE__FUNCTIONS__BASE_FUNCTION__H__ 19 | #define RIAK_MAP_REDUCE__FUNCTIONS__BASE_FUNCTION__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_mrfunction_ce; 24 | 25 | void riak_map_reduce_functions_base_function_init(TSRMLS_D); 26 | 27 | #endif //RIAK_MAP_REDUCE__FUNCTIONS__BASE_FUNCTION__H__ 28 | 29 | -------------------------------------------------------------------------------- /riak/map_reduce/functions/erlang_function.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "erlang_function.h" 17 | #include "base_function.h" 18 | 19 | zend_class_entry *riak_mrfunction_erl_ce; 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_function_erl_toarray, 0, ZEND_RETURN_VALUE, 0) 22 | ZEND_END_ARG_INFO() 23 | 24 | ZEND_BEGIN_ARG_INFO_EX(arginfo_create_erl_named_ctor, 0, ZEND_RETURN_VALUE, 2) 25 | ZEND_ARG_INFO(0, module) 26 | ZEND_ARG_INFO(0, function) 27 | ZEND_END_ARG_INFO() 28 | 29 | 30 | static zend_function_entry riak_mrfunction_erl_methods[] = { 31 | PHP_ME(RiakMrErlangFunction, __construct, arginfo_create_erl_named_ctor, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) 32 | PHP_ME(RiakMrErlangFunction, toArray, arginfo_function_erl_toarray, ZEND_ACC_PUBLIC) 33 | {NULL, NULL, NULL} 34 | }; 35 | 36 | void riak_map_reduce_functions_erlang_function_init(TSRMLS_D)/* {{{ */ 37 | { 38 | zend_class_entry ce; 39 | INIT_NS_CLASS_ENTRY(ce, "Riak\\MapReduce\\Functions", "ErlangFunction", riak_mrfunction_erl_methods); 40 | riak_mrfunction_erl_ce = zend_register_internal_class_ex(&ce, riak_mrfunction_ce, NULL TSRMLS_CC); 41 | zend_declare_property_null(riak_mrfunction_erl_ce, "module", sizeof("module")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 42 | zend_declare_property_null(riak_mrfunction_erl_ce, "function", sizeof("function")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 43 | } 44 | /* }}} */ 45 | 46 | 47 | /************************************************************* 48 | * Implementation: Riak\MapReduce\Function\ErlangFunction 49 | *************************************************************/ 50 | 51 | /* {{{ proto void Riak\MapReduce\Function\ErlangFunction->__construct(string $module, string $function) 52 | Creates a new ErlangFunction */ 53 | PHP_METHOD(RiakMrErlangFunction, __construct) 54 | { 55 | char *module, *function; 56 | int modulelen, functionlen; 57 | 58 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &module, &modulelen, &function, &functionlen) == FAILURE) { 59 | return; 60 | } 61 | zend_update_property_stringl(riak_mrfunction_erl_ce, getThis(), "module", sizeof("module")-1, module, modulelen TSRMLS_CC); 62 | zend_update_property_stringl(riak_mrfunction_erl_ce, getThis(), "function", sizeof("function")-1, function, functionlen TSRMLS_CC); 63 | } 64 | /* }}} */ 65 | 66 | /* {{{ proto array Riak\MapReduce\Function\ErlangFunction->toArray() 67 | Returns this Funtion as an array */ 68 | PHP_METHOD(RiakMrErlangFunction, toArray) 69 | { 70 | zval *zarray, *zmodule, *zfunc; 71 | 72 | MAKE_STD_ZVAL(zarray); 73 | array_init(zarray); 74 | 75 | zmodule = zend_read_property(riak_mrfunction_erl_ce, getThis(), "module", sizeof("module")-1, 1 TSRMLS_CC); 76 | zfunc = zend_read_property(riak_mrfunction_erl_ce, getThis(), "function", sizeof("function")-1, 1 TSRMLS_CC); 77 | 78 | add_assoc_string_ex(zarray, "language", sizeof("language"), "erlang", 1); 79 | add_assoc_stringl_ex(zarray, "module", sizeof("module"), Z_STRVAL_P(zmodule), Z_STRLEN_P(zmodule), 1); 80 | add_assoc_stringl_ex(zarray, "function", sizeof("function"), Z_STRVAL_P(zfunc), Z_STRLEN_P(zfunc), 1); 81 | 82 | RETURN_ZVAL(zarray, 0, 1); 83 | } 84 | /* }}} */ 85 | 86 | -------------------------------------------------------------------------------- /riak/map_reduce/functions/erlang_function.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_MAP_REDUCE__FUNCTIONS__ERLANG_FUNCTION__H__ 18 | #define RIAK_MAP_REDUCE__FUNCTIONS__ERLANG_FUNCTION__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | void riak_map_reduce_functions_erlang_function_init(TSRMLS_D); 23 | 24 | PHP_METHOD(RiakMrErlangFunction, __construct); 25 | PHP_METHOD(RiakMrErlangFunction, toArray); 26 | 27 | #endif //RIAK_MAP_REDUCE__FUNCTIONS__ERLANG_FUNCTION__H__ 28 | -------------------------------------------------------------------------------- /riak/map_reduce/functions/javascript_function.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_MAP_REDUCE__FUNCTIONS__JAVASCRIPT_FUNCTION__H__ 18 | #define RIAK_MAP_REDUCE__FUNCTIONS__JAVASCRIPT_FUNCTION__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | void riak_map_reduce_functions_javascript_function_init(TSRMLS_D); 23 | 24 | PHP_METHOD(RiakMrJavascriptFunction, __construct); 25 | PHP_METHOD(RiakMrJavascriptFunction, toArray); 26 | PHP_METHOD(RiakMrJavascriptFunction, named); 27 | PHP_METHOD(RiakMrJavascriptFunction, anon); 28 | 29 | #endif //RIAK_MAP_REDUCE__FUNCTIONS__JAVASCRIPT_FUNCTION__H__ 30 | -------------------------------------------------------------------------------- /riak/map_reduce/input/bucket_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef RIAK_MAP_REDUCE__INPUT__BUCKET_INPUT__H__ 19 | #define RIAK_MAP_REDUCE__INPUT__BUCKET_INPUT__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | void riak_map_reduce_input_bucket_input_init(TSRMLS_D); 24 | 25 | PHP_METHOD(Riak_MapReduce_Input_BucketInput, __construct); 26 | PHP_METHOD(Riak_MapReduce_Input_BucketInput, getValue); 27 | PHP_METHOD(Riak_MapReduce_Input_BucketInput, setIndexFilter); 28 | 29 | 30 | #endif //RIAK_MAP_REDUCE__INPUT__BUCKET_INPUT__H__ 31 | 32 | -------------------------------------------------------------------------------- /riak/map_reduce/input/input.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "input.h" 17 | 18 | zend_class_entry *riak_mrinput_ce; 19 | 20 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mr_input_toarr, 0, ZEND_RETURN_VALUE, 0) 21 | ZEND_END_ARG_INFO() 22 | 23 | static zend_function_entry riak_mrinput_methods[] = { 24 | ZEND_ABSTRACT_ME(RiakMrInput, getValue, arginfo_mr_input_toarr) 25 | {NULL, NULL, NULL} 26 | }; 27 | 28 | void riak_map_reduce_input_input_init(TSRMLS_D) /* {{{ */ 29 | { 30 | zend_class_entry ce; 31 | 32 | INIT_NS_CLASS_ENTRY(ce, "Riak\\MapReduce\\Input", "Input", riak_mrinput_methods); 33 | riak_mrinput_ce = zend_register_internal_class(&ce TSRMLS_CC); 34 | } 35 | /* }}} */ 36 | 37 | -------------------------------------------------------------------------------- /riak/map_reduce/input/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef RIAK_MAP_REDUCE__INPUT__INPUT__H__ 19 | #define RIAK_MAP_REDUCE__INPUT__INPUT__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_mrinput_ce; 24 | 25 | void riak_map_reduce_input_input_init(TSRMLS_D); 26 | 27 | PHP_METHOD(RiakMrInput, toArray); 28 | 29 | #endif //RIAK_MAP_REDUCE__INPUT__INPUT__H__ 30 | 31 | -------------------------------------------------------------------------------- /riak/map_reduce/input/key_data_list_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef RIAK_MAP_REDUCE__INPUT__KEY_DATA_LIST_INPUT__H__ 19 | #define RIAK_MAP_REDUCE__INPUT__KEY_DATA_LIST_INPUT__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | void riak_map_reduce_input_key_data_list_input_init(TSRMLS_D); 24 | 25 | PHP_METHOD(Riak_MapReduce_Input_KeyDataListInput, __construct); 26 | PHP_METHOD(Riak_MapReduce_Input_KeyDataListInput, getValue); 27 | PHP_METHOD(Riak_MapReduce_Input_KeyDataListInput, add); 28 | 29 | 30 | #endif //RIAK_MAP_REDUCE__INPUT__KEY_DATA_LIST_INPUT__H__ 31 | 32 | -------------------------------------------------------------------------------- /riak/map_reduce/input/key_list_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef RIAK_MAP_REDUCE__INPUT__KEY_LIST_INPUT__H__ 19 | #define RIAK_MAP_REDUCE__INPUT__KEY_LIST_INPUT__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | void riak_map_reduce_input_key_list_input_init(TSRMLS_D); 24 | 25 | PHP_METHOD(Riak_MapReduce_Input_KeyListInput, __construct); 26 | PHP_METHOD(Riak_MapReduce_Input_KeyListInput, addArray); 27 | PHP_METHOD(Riak_MapReduce_Input_KeyListInput, addSingle); 28 | PHP_METHOD(Riak_MapReduce_Input_KeyListInput, getValue); 29 | 30 | #endif //RIAK_MAP_REDUCE__INPUT__KEY_LIST_INPUT__H__ 31 | 32 | -------------------------------------------------------------------------------- /riak/map_reduce/mapreduce.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_MAP_REDUCE__H__ 19 | #define RIAK_MAP_REDUCE__H__ 20 | 21 | #include 22 | 23 | extern zend_class_entry *riak_mapreduce_ce; 24 | 25 | void riak_mapreduce_init(TSRMLS_D); 26 | 27 | PHP_METHOD(RiakMapreduce, __construct); 28 | PHP_METHOD(RiakMapreduce, addPhase); 29 | PHP_METHOD(RiakMapreduce, setInput); 30 | PHP_METHOD(RiakMapreduce, run); 31 | PHP_METHOD(RiakMapreduce, toArray); 32 | PHP_METHOD(RiakMapreduce, toJson); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /riak/map_reduce/output/output.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "output.h" 17 | #include "ext/json/php_json.h" 18 | 19 | zend_class_entry *riak_mroutput_ce; 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(riak_arginfo_output_ctor, 0, ZEND_RETURN_VALUE, 1) 22 | ZEND_ARG_INFO(0, value) 23 | ZEND_ARG_INFO(1, phase) 24 | ZEND_END_ARG_INFO() 25 | 26 | ZEND_BEGIN_ARG_INFO_EX(riak_arginfo_output_noargs, 0, ZEND_RETURN_VALUE, 0) 27 | ZEND_END_ARG_INFO() 28 | 29 | static zend_function_entry riak_mroutput_methods[] = { 30 | PHP_ME(Riak_MapReduce_Output_Output, __construct, riak_arginfo_output_ctor, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) 31 | PHP_ME(Riak_MapReduce_Output_Output, getValue, riak_arginfo_output_noargs, ZEND_ACC_PUBLIC) 32 | PHP_ME(Riak_MapReduce_Output_Output, getPhaseNumber, riak_arginfo_output_noargs, ZEND_ACC_PUBLIC) 33 | {NULL, NULL, NULL} 34 | }; 35 | 36 | 37 | 38 | void riak_map_reduce_output_output_init(TSRMLS_D)/* {{{ */ 39 | { 40 | zend_class_entry ce; 41 | 42 | INIT_NS_CLASS_ENTRY(ce, "Riak\\MapReduce\\Output", "Output", riak_mroutput_methods); 43 | riak_mroutput_ce = zend_register_internal_class(&ce TSRMLS_CC); 44 | zend_declare_property_null(riak_mroutput_ce, "value", sizeof("value")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 45 | zend_declare_property_null(riak_mroutput_ce, "phase", sizeof("phase")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 46 | } 47 | /* }}} */ 48 | 49 | 50 | zval *riak_mroutput_from_riack_mapred(riack_mapred_response *mapresult TSRMLS_DC)/* {{{ */ 51 | { 52 | zval *zresult, *zvalue, *zphase; 53 | MAKE_STD_ZVAL(zresult); 54 | MAKE_STD_ZVAL(zvalue); 55 | 56 | php_json_decode(zvalue, (char*)mapresult->data, mapresult->data_size, 1, 10 TSRMLS_CC); 57 | object_init_ex(zresult, riak_mroutput_ce); 58 | 59 | if (mapresult->phase_present) { 60 | MAKE_STD_ZVAL(zphase); 61 | ZVAL_LONG(zphase, mapresult->phase); 62 | RIAK_CALL_METHOD2(Riak_MapReduce_Output_Output, __construct, zresult, zresult, zvalue, zphase); 63 | zval_ptr_dtor(&zphase); 64 | } else { 65 | RIAK_CALL_METHOD1(Riak_MapReduce_Output_Output, __construct, zresult, zresult, zvalue); 66 | } 67 | zval_ptr_dtor(&zvalue); 68 | return zresult; 69 | } 70 | /* }}} */ 71 | 72 | /* {{{ proto void Riak\MapReduce\Output\Output->__construct($value, [, int $phase]) 73 | Create a Riak_MapReduce_Output_Output */ 74 | PHP_METHOD(Riak_MapReduce_Output_Output, __construct) 75 | { 76 | zval* zvalue; 77 | long phase = 0; 78 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &zvalue, &phase) == FAILURE) { 79 | return; 80 | } 81 | zend_update_property_long(riak_mroutput_ce, getThis(), "phase", sizeof("phase")-1, phase TSRMLS_CC); 82 | zend_update_property(riak_mroutput_ce, getThis(), "value", sizeof("value")-1, zvalue TSRMLS_CC); 83 | } 84 | /* }}} */ 85 | 86 | /* {{{ proto mixed Riak\MapReduce\Output\Output->getValue() 87 | Get decoded value from this mr output */ 88 | PHP_METHOD(Riak_MapReduce_Output_Output, getValue) 89 | { 90 | RIAK_GETTER_MIXED(riak_mroutput_ce, "value"); 91 | } 92 | /* }}} */ 93 | 94 | /* {{{ proto int|null Riak\MapReduce\Output\Output->getPhaseNumber() 95 | Get phase number if set in response */ 96 | PHP_METHOD(Riak_MapReduce_Output_Output, getPhaseNumber) 97 | { 98 | RIAK_GETTER_LONG(riak_mroutput_ce, "phase"); 99 | } 100 | /* }}} */ 101 | 102 | -------------------------------------------------------------------------------- /riak/map_reduce/output/output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_MAP_REDUCE__OUTPUT__OUTPUT__H__ 18 | #define RIAK_MAP_REDUCE__OUTPUT__OUTPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_mroutput_ce; 23 | 24 | void riak_map_reduce_output_output_init(TSRMLS_D); 25 | 26 | zval *riak_mroutput_from_riack_mapred(riack_mapred_response *mapresult TSRMLS_DC); 27 | 28 | PHP_METHOD(Riak_MapReduce_Output_Output, __construct); 29 | PHP_METHOD(Riak_MapReduce_Output_Output, getValue); 30 | PHP_METHOD(Riak_MapReduce_Output_Output, getPhaseNumber); 31 | 32 | #endif //RIAK_MAP_REDUCE__OUTPUT__OUTPUT__H__ 33 | 34 | -------------------------------------------------------------------------------- /riak/map_reduce/output/stream_output.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "stream_output.h" 17 | 18 | zend_class_entry *riak_mr_streamer_ce; 19 | 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mrstreamer_rec, 0, ZEND_RETURN_VALUE, 1) 22 | ZEND_ARG_INFO(0, result) 23 | ZEND_END_ARG_INFO() 24 | 25 | 26 | static zend_function_entry riak_mapreduce_out_stream_methods[] = { 27 | ZEND_ABSTRACT_ME(Riak_MapReduce_Output_StreamOutput, receive, arginfo_mrstreamer_rec) 28 | {NULL, NULL, NULL} 29 | }; 30 | 31 | 32 | void riak_map_reduce_output_stream_output_init(TSRMLS_D)/* {{{ */ 33 | { 34 | zend_class_entry ce; 35 | INIT_NS_CLASS_ENTRY(ce, "Riak\\MapReduce\\Output","StreamOutput", riak_mapreduce_out_stream_methods); 36 | riak_mr_streamer_ce = zend_register_internal_interface(&ce TSRMLS_CC); 37 | } 38 | /* }}} */ 39 | -------------------------------------------------------------------------------- /riak/map_reduce/output/stream_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_MAP_REDUCE__OUTPUT__STREAM_OUTPUT__H__ 18 | #define RIAK_MAP_REDUCE__OUTPUT__STREAM_OUTPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_mr_streamer_ce; 23 | 24 | void riak_map_reduce_output_stream_output_init(TSRMLS_D); 25 | 26 | #endif //RIAK_MAP_REDUCE__OUTPUT__STREAM_OUTPUT__H__ 27 | 28 | -------------------------------------------------------------------------------- /riak/map_reduce/phase/map_phase.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "map_phase.h" 17 | #include "phase.h" 18 | 19 | zend_class_entry *riak_mr_mapphase_ce; 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_map_red_phase_map_phase_toarr, 0, ZEND_RETURN_VALUE, 0) 22 | ZEND_END_ARG_INFO() 23 | 24 | ZEND_BEGIN_ARG_INFO_EX(arginfo_map_red_phase_map_phase_ctor, 0, ZEND_RETURN_VALUE, 1) 25 | ZEND_ARG_INFO(0, function) 26 | ZEND_ARG_INFO(0, keep) 27 | ZEND_ARG_INFO(0, args) 28 | ZEND_END_ARG_INFO() 29 | 30 | static zend_function_entry riak_mrphase_map_methods[] = { 31 | PHP_ME(Riak_MapReduce_Phase_MapPhase, __construct, arginfo_map_red_phase_map_phase_ctor, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) 32 | PHP_ME(Riak_MapReduce_Phase_MapPhase, toArray, arginfo_map_red_phase_map_phase_toarr, ZEND_ACC_PUBLIC) 33 | {NULL, NULL, NULL} 34 | }; 35 | 36 | 37 | void riak_map_reduce_phase_map_phase_init(TSRMLS_D)/* {{{ */ 38 | { 39 | zend_class_entry ce; 40 | INIT_NS_CLASS_ENTRY(ce, "Riak\\MapReduce\\Phase", "MapPhase", riak_mrphase_map_methods); 41 | riak_mr_mapphase_ce = zend_register_internal_class_ex(&ce, riak_mrphase_ce, NULL TSRMLS_CC); 42 | } 43 | /* }}} */ 44 | 45 | /************************************************************* 46 | * Implementation: Riak\MapReduce\Phase\MapPhase 47 | *************************************************************/ 48 | 49 | /* {{{ proto void Riak\MapReduce\Phase\MapPhase->__construct(Riak\MapReduce\Function\Function $function [, bool $keep [, array $arguments]]) 50 | Create a new MapPhase */ 51 | PHP_METHOD(Riak_MapReduce_Phase_MapPhase, __construct) 52 | { 53 | zval *zfunction, *zargs; 54 | zend_bool keep; 55 | keep = 0; 56 | zargs = NULL; 57 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|ba", &zfunction, &keep, &zargs) == FAILURE) { 58 | return; 59 | } 60 | zend_update_property(riak_mr_mapphase_ce, getThis(), "function", sizeof("function")-1, zfunction TSRMLS_CC); 61 | zend_update_property_bool(riak_mr_mapphase_ce, getThis(), "keep", sizeof("keep")-1, keep TSRMLS_CC); 62 | if (zargs) { 63 | zend_update_property(riak_mr_mapphase_ce, getThis(), "arg", sizeof("arg")-1, zargs TSRMLS_CC); 64 | } 65 | } 66 | /* }}} */ 67 | 68 | /* {{{ proto array Riak\MapReduce\Phase\MapPhase->toArray() 69 | Convert this phase into an array */ 70 | PHP_METHOD(Riak_MapReduce_Phase_MapPhase, toArray) 71 | { 72 | zval *zarray, *zfuncarray, *zfunc, *zarg, zname; 73 | zend_bool keep; 74 | MAKE_STD_ZVAL(zarray); 75 | array_init(zarray); 76 | 77 | MAKE_STD_ZVAL(zfuncarray); 78 | zfunc = zend_read_property(riak_mr_mapphase_ce, getThis(), "function", sizeof("function")-1, 1 TSRMLS_CC); 79 | ZVAL_STRING(&zname, "toArray", 0); 80 | call_user_function(NULL, &zfunc, &zname, zfuncarray, 0, NULL TSRMLS_CC); 81 | 82 | keep = Z_BVAL_P(zend_read_property(riak_mr_mapphase_ce, getThis(), "keep", sizeof("keep")-1, 1 TSRMLS_CC)); 83 | if (keep) { 84 | add_assoc_bool_ex(zfuncarray, "keep", sizeof("keep"), 1); 85 | } 86 | add_assoc_zval_ex(zarray, "map", sizeof("map"), zfuncarray); 87 | zarg = zend_read_property(riak_mr_mapphase_ce, getThis(), "arg", sizeof("arg")-1, 1 TSRMLS_CC); 88 | if (Z_TYPE_P(zarg) != IS_NULL) { 89 | add_assoc_zval_ex(zarray, "arg", sizeof("arg"), zarg); 90 | zval_addref_p(zarg); 91 | } 92 | RETURN_ZVAL(zarray, 0, 1); 93 | } 94 | /* }}} */ 95 | 96 | 97 | -------------------------------------------------------------------------------- /riak/map_reduce/phase/map_phase.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_MAP_REDUCE__PHASE__MAP_PHASE__H__ 18 | #define RIAK_MAP_REDUCE__PHASE__MAP_PHASE__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | void riak_map_reduce_phase_map_phase_init(TSRMLS_D); 23 | 24 | PHP_METHOD(Riak_MapReduce_Phase_MapPhase, __construct); 25 | PHP_METHOD(Riak_MapReduce_Phase_MapPhase, toArray); 26 | 27 | 28 | #endif //RIAK_MAP_REDUCE__PHASE__MAP_PHASE__H__ 29 | 30 | -------------------------------------------------------------------------------- /riak/map_reduce/phase/phase.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "phase.h" 17 | 18 | zend_class_entry *riak_mrphase_ce; 19 | 20 | ZEND_BEGIN_ARG_INFO_EX(arginfo_map_red_phase_toarr, 0, ZEND_RETURN_VALUE, 0) 21 | ZEND_END_ARG_INFO() 22 | 23 | static zend_function_entry riak_mrphase_methods[] = { 24 | ZEND_ABSTRACT_ME(Riak_MapReduce_Phase_Phase, toArray, arginfo_map_red_phase_toarr) 25 | {NULL, NULL, NULL} 26 | }; 27 | 28 | 29 | void riak_map_reduce_phase_phase_init(TSRMLS_D)/* {{{ */ 30 | { 31 | zend_class_entry ce; 32 | INIT_NS_CLASS_ENTRY(ce, "Riak\\MapReduce\\Phase", "Phase", riak_mrphase_methods); 33 | riak_mrphase_ce = zend_register_internal_class(&ce TSRMLS_CC); 34 | zend_declare_property_null(riak_mrphase_ce, "function", sizeof("functions")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 35 | zend_declare_property_bool(riak_mrphase_ce, "keep", sizeof("keep")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC); 36 | zend_declare_property_null(riak_mrphase_ce, "arg", sizeof("arg")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 37 | } 38 | /* }}} */ 39 | 40 | 41 | -------------------------------------------------------------------------------- /riak/map_reduce/phase/phase.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_MAP_REDUCE__PHASE__PHASE__H__ 18 | #define RIAK_MAP_REDUCE__PHASE__PHASE__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | 23 | extern zend_class_entry *riak_mrphase_ce; 24 | 25 | void riak_map_reduce_phase_phase_init(TSRMLS_D); 26 | 27 | #endif //RIAK_MAP_REDUCE__PHASE__PHASE__H__ 28 | 29 | -------------------------------------------------------------------------------- /riak/map_reduce/phase/reduce_phase.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "reduce_phase.h" 17 | #include "phase.h" 18 | 19 | zend_class_entry *riak_mr_reducephase_ce; 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_map_red_phase_reduce_phase_toarr, 0, ZEND_RETURN_VALUE, 0) 22 | ZEND_END_ARG_INFO() 23 | 24 | ZEND_BEGIN_ARG_INFO_EX(arginfo_map_red_phase_reduce_phase_ctor, 0, ZEND_RETURN_VALUE, 1) 25 | ZEND_ARG_INFO(0, function) 26 | ZEND_ARG_INFO(0, keep) 27 | ZEND_ARG_INFO(0, args) 28 | ZEND_END_ARG_INFO() 29 | 30 | 31 | static zend_function_entry riak_mrphase_reduce_methods[] = { 32 | PHP_ME(Riak_MapReduce_Phase_ReducePhase, __construct, arginfo_map_red_phase_reduce_phase_ctor, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) 33 | PHP_ME(Riak_MapReduce_Phase_ReducePhase, toArray, arginfo_map_red_phase_reduce_phase_toarr, ZEND_ACC_PUBLIC) 34 | {NULL, NULL, NULL} 35 | }; 36 | 37 | 38 | void riak_map_reduce_phase_reduce_phase_init(TSRMLS_D)/* {{{ */ 39 | { 40 | zend_class_entry ce; 41 | INIT_NS_CLASS_ENTRY(ce, "Riak\\MapReduce\\Phase", "ReducePhase", riak_mrphase_reduce_methods); 42 | riak_mr_reducephase_ce = zend_register_internal_class_ex(&ce, riak_mrphase_ce, NULL TSRMLS_CC); 43 | } 44 | /* }}} */ 45 | 46 | 47 | /************************************************************* 48 | * Implementation: Riak\MapReduce\Phase\ReducePhase 49 | *************************************************************/ 50 | 51 | /* {{{ proto void Riak\MapReduce\Phase\ReducePhase->__construct(Riak\MapReduce\Function\Function $function [, bool $keep [, array $arguments]]) 52 | Create a new ReducePhase */ 53 | PHP_METHOD(Riak_MapReduce_Phase_ReducePhase, __construct) 54 | { 55 | zval *zfunction, *zargs; 56 | zend_bool keep; 57 | keep = 0; 58 | zargs = NULL; 59 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|ba", &zfunction, &keep, &zargs) == FAILURE) { 60 | return; 61 | } 62 | zend_update_property(riak_mr_reducephase_ce, getThis(), "function", sizeof("function")-1, zfunction TSRMLS_CC); 63 | zend_update_property_bool(riak_mr_reducephase_ce, getThis(), "keep", sizeof("keep")-1, keep TSRMLS_CC); 64 | if (zargs) { 65 | zend_update_property(riak_mr_reducephase_ce, getThis(), "arg", sizeof("arg")-1, zargs TSRMLS_CC); 66 | } 67 | } 68 | /* }}} */ 69 | 70 | /* {{{ proto array Riak\MapReduce\Phase\ReducePhase->toArray() 71 | Convert this phase into an array */ 72 | PHP_METHOD(Riak_MapReduce_Phase_ReducePhase, toArray) 73 | { 74 | zval *zarray, *zfuncarray, *zfunc, *zarg, zname; 75 | zend_bool keep; 76 | MAKE_STD_ZVAL(zarray); 77 | array_init(zarray); 78 | 79 | MAKE_STD_ZVAL(zfuncarray); 80 | zfunc = zend_read_property(riak_mr_reducephase_ce, getThis(), "function", sizeof("function")-1, 1 TSRMLS_CC); 81 | ZVAL_STRING(&zname, "toArray", 0); 82 | call_user_function(NULL, &zfunc, &zname, zfuncarray, 0, NULL TSRMLS_CC); 83 | 84 | keep = Z_BVAL_P(zend_read_property(riak_mr_reducephase_ce, getThis(), "keep", sizeof("keep")-1, 1 TSRMLS_CC)); 85 | if (keep) { 86 | add_assoc_bool_ex(zfuncarray, "keep", sizeof("keep"), 1); 87 | } 88 | add_assoc_zval_ex(zarray, "reduce", sizeof("reduce"), zfuncarray); 89 | zarg = zend_read_property(riak_mr_reducephase_ce, getThis(), "arg", sizeof("arg")-1, 1 TSRMLS_CC); 90 | if (Z_TYPE_P(zarg) != IS_NULL) { 91 | zval_addref_p(zarg); 92 | add_assoc_zval_ex(zarray, "arg", sizeof("arg"), zarg); 93 | } 94 | RETURN_ZVAL(zarray, 0, 1); 95 | } 96 | /* }}} */ 97 | 98 | -------------------------------------------------------------------------------- /riak/map_reduce/phase/reduce_phase.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_MAP_REDUCE__PHASE__REDUCE_PHASE__H__ 18 | #define RIAK_MAP_REDUCE__PHASE__REDUCE_PHASE__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | void riak_map_reduce_phase_reduce_phase_init(TSRMLS_D); 23 | 24 | PHP_METHOD(Riak_MapReduce_Phase_ReducePhase, __construct); 25 | PHP_METHOD(Riak_MapReduce_Phase_ReducePhase, toArray); 26 | 27 | #endif //RIAK_MAP_REDUCE__PHASE__REDUCE_PHASE__H__ 28 | 29 | -------------------------------------------------------------------------------- /riak/object.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_OBJECT__H__ 19 | #define RIAK_OBJECT__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_object_ce; 24 | 25 | zval* create_object_object(const char* key TSRMLS_DC); 26 | 27 | void riak_object_init(TSRMLS_D); 28 | void set_object_from_riak_content(zval* object, riack_content* content TSRMLS_DC); 29 | void set_riak_content_from_object(riack_content* content, zval* object, riack_client* client TSRMLS_DC); 30 | 31 | void riak_key_from_object(zval *zobject, char** key, int* keylen TSRMLS_DC); 32 | 33 | PHP_METHOD(RiakObject, __construct); 34 | PHP_METHOD(RiakObject, getKey); 35 | PHP_METHOD(RiakObject, setKey); 36 | PHP_METHOD(RiakObject, getContent); 37 | PHP_METHOD(RiakObject, setContent); 38 | PHP_METHOD(RiakObject, addIndex); 39 | PHP_METHOD(RiakObject, addLink); 40 | PHP_METHOD(RiakObject, addMetadata); 41 | PHP_METHOD(RiakObject, setCharset); 42 | PHP_METHOD(RiakObject, getCharset); 43 | PHP_METHOD(RiakObject, setContentType); 44 | PHP_METHOD(RiakObject, getContentType); 45 | PHP_METHOD(RiakObject, setContentEncoding); 46 | PHP_METHOD(RiakObject, getContentEncoding); 47 | PHP_METHOD(RiakObject, isDeleted); 48 | PHP_METHOD(RiakObject, getIndexMap); 49 | PHP_METHOD(RiakObject, getLinkList); 50 | PHP_METHOD(RiakObject, getMetadataMap); 51 | PHP_METHOD(RiakObject, getVTag); 52 | PHP_METHOD(RiakObject, getVClock); 53 | PHP_METHOD(RiakObject, setVClock); 54 | PHP_METHOD(RiakObject, getLastModified); 55 | PHP_METHOD(RiakObject, getLastModifiedUSecs); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /riak/object_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUT__OBJECT_LIST__H__ 18 | #define RIAK_OUTPUT__OBJECT_LIST__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_output_object_list_ce; 23 | 24 | void riak_output_object_list_init(TSRMLS_D); 25 | 26 | PHP_METHOD(Riak_Object_List, __construct); 27 | PHP_METHOD(Riak_Object_List, first); 28 | PHP_METHOD(Riak_Object_List, last); 29 | PHP_METHOD(Riak_Object_List, isEmpty); 30 | PHP_METHOD(Riak_Object_List, offsetExists); 31 | PHP_METHOD(Riak_Object_List, offsetGet); 32 | PHP_METHOD(Riak_Object_List, offsetSet); 33 | PHP_METHOD(Riak_Object_List, offsetUnset); 34 | PHP_METHOD(Riak_Object_List, count); 35 | PHP_METHOD(Riak_Object_List, getIterator); 36 | 37 | 38 | #endif //RIAK_OUTPUT__OBJECT_LIST__H__ 39 | -------------------------------------------------------------------------------- /riak/output/conflict_resolver.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "conflict_resolver.h" 18 | 19 | zend_class_entry *riak_output_conflict_resolver_ce; 20 | 21 | RIAK_OUTPUT_CONFLICT_RESOLVER_ARG_INFO_EXEC(arginfo_conflict_resolver_resolve) 22 | 23 | static zend_function_entry riak_conflict_resolver_methods[] = { 24 | ZEND_ABSTRACT_ME(Riak_Output_ConflictResolver, resolve, arginfo_conflict_resolver_resolve) 25 | {NULL, NULL, NULL} 26 | }; 27 | 28 | void riak_output_conflict_resolver_init(TSRMLS_D)/* {{{ */ 29 | { 30 | zend_class_entry ce; 31 | 32 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Output", "ConflictResolver", riak_conflict_resolver_methods); 33 | riak_output_conflict_resolver_ce = zend_register_internal_interface(&ce TSRMLS_CC); 34 | } 35 | /* }}} */ 36 | -------------------------------------------------------------------------------- /riak/output/conflict_resolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUT__CONFLICT_RESOLVER__H__ 18 | #define RIAK_OUTPUT__CONFLICT_RESOLVER__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | 23 | #define RIAK_OUTPUT_CONFLICT_RESOLVER_ARG_INFO_EXEC(name) \ 24 | ZEND_BEGIN_ARG_INFO_EX(name, 0, ZEND_RETURN_VALUE, 1) \ 25 | ZEND_ARG_OBJ_INFO(0, objects, Riak\\ObjectList, 0) \ 26 | ZEND_END_ARG_INFO(); 27 | 28 | PHP_METHOD(Riak_Output_ConflictResolver, resolve); 29 | 30 | extern zend_class_entry *riak_output_conflict_resolver_ce; 31 | 32 | void riak_output_conflict_resolver_init(TSRMLS_D); 33 | 34 | #endif //RIAK_OUTPUT__CONFLICT_RESOLVER__H__ 35 | -------------------------------------------------------------------------------- /riak/output/get_output.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "get_output.h" 18 | #include "output.h" 19 | 20 | zend_class_entry *riak_get_output_ce; 21 | 22 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_get_output_noargs, 0, ZEND_RETURN_VALUE, 0) 23 | ZEND_END_ARG_INFO() 24 | 25 | static zend_function_entry riak_get_output_methods[] = { 26 | PHP_ME(Riak_Output_GetOutput, isUnchanged, arginfo_riak_get_output_noargs, ZEND_ACC_PUBLIC) 27 | {NULL, NULL, NULL} 28 | }; 29 | 30 | void riak_output_get_output_init(TSRMLS_D)/* {{{ */ 31 | { 32 | zend_class_entry ce; 33 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Output", "GetOutput", riak_get_output_methods); 34 | riak_get_output_ce = zend_register_internal_class_ex(&ce, riak_output_ce, NULL TSRMLS_CC); 35 | zend_declare_property_null(riak_get_output_ce, "unchanged", sizeof("unchanged")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 36 | } 37 | /* }}} */ 38 | 39 | zval *get_output_from_riack_get_object(riack_get_object* getobj, zval* zkey TSRMLS_DC) /* {{{ */ 40 | { 41 | zval *zoutput; 42 | MAKE_STD_ZVAL(zoutput); 43 | object_init_ex(zoutput, riak_get_output_ce); 44 | if (getobj->unchanged_present) { 45 | zend_update_property_bool(riak_get_output_ce, zoutput, "unchanged", sizeof("unchanged")-1, getobj->unchanged TSRMLS_CC); 46 | } 47 | riak_set_output_properties(zoutput, zkey, &getobj->object TSRMLS_CC); 48 | return zoutput; 49 | } 50 | /* }}} */ 51 | 52 | 53 | /* {{{ proto bool|null Riak\Output\GetOutput->isUnchanged() 54 | Is unchanged */ 55 | PHP_METHOD(Riak_Output_GetOutput, isUnchanged) 56 | { 57 | zval* zunc = zend_read_property(riak_get_output_ce, getThis(), "unchanged", sizeof("unchanged")-1, 1 TSRMLS_CC); 58 | if (Z_TYPE_P(zunc) == IS_BOOL) { 59 | RETURN_BOOL(Z_BVAL_P(zunc)); 60 | } 61 | RETURN_BOOL(0); 62 | } 63 | /* }}} */ 64 | 65 | -------------------------------------------------------------------------------- /riak/output/get_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUT__GET_OUTPUT__H__ 18 | #define RIAK_OUTPUT__GET_OUTPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_get_output_ce; 23 | 24 | void riak_output_get_output_init(TSRMLS_D); 25 | zval *get_output_from_riack_get_object(riack_get_object* getobj, zval* zkey TSRMLS_DC); 26 | 27 | PHP_METHOD(Riak_Output_GetOutput, isUnchanged); 28 | 29 | #endif //RIAK_OUTPUT__GET_OUTPUT__H__ 30 | -------------------------------------------------------------------------------- /riak/output/index_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUT__INDEX_OUTPUT__H__ 18 | #define RIAK_OUTPUT__INDEX_OUTPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_index_output_ce; 23 | 24 | void riak_output_index_output_init(TSRMLS_D); 25 | 26 | zval *riak_index_output_from_string_list_and_continuation(riack_string_list *result_keys, riack_string *continuation TSRMLS_DC); 27 | 28 | PHP_METHOD(Riak_Index_Output, __construct); 29 | PHP_METHOD(Riak_Index_Output, getResultList); 30 | PHP_METHOD(Riak_Index_Output, getContinuation); 31 | 32 | #endif //RIAK_OUTPUT__INDEX_OUTPUT__H__ 33 | -------------------------------------------------------------------------------- /riak/output/index_result.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "index_result.h" 17 | #include "../exception/exception.h" 18 | 19 | zend_class_entry *riak_index_result_ce; 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_output_index_result_ctor, 0, ZEND_RETURN_VALUE, 1) 22 | ZEND_ARG_INFO(0, key) 23 | ZEND_END_ARG_INFO() 24 | 25 | ZEND_BEGIN_ARG_INFO_EX(arginfo_riak_output_index_result_noargs, 0, ZEND_RETURN_VALUE, 0) 26 | ZEND_END_ARG_INFO() 27 | 28 | static zend_function_entry riak_output_index_result_methods[] = { 29 | PHP_ME(Riak_Output_IndexResult, __construct, arginfo_riak_output_index_result_ctor, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) 30 | PHP_ME(Riak_Output_IndexResult, getKey, arginfo_riak_output_index_result_noargs, ZEND_ACC_PUBLIC) 31 | {NULL, NULL, NULL} 32 | }; 33 | 34 | 35 | void riak_output_index_result_init(TSRMLS_D) 36 | { 37 | zend_class_entry ce; 38 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Output", "IndexResult", riak_output_index_result_methods); 39 | riak_index_result_ce = zend_register_internal_class(&ce TSRMLS_CC); 40 | zend_declare_property_null(riak_index_result_ce, "key", sizeof("key")-1, ZEND_ACC_PROTECTED TSRMLS_CC); 41 | } 42 | 43 | /* {{{ proto void Riak\Output\IndexResult->__construct(string $key) 44 | Get list of returned objects */ 45 | PHP_METHOD(Riak_Output_IndexResult, __construct) 46 | { 47 | char *key; 48 | int key_len; 49 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { 50 | zend_throw_exception(riak_badarguments_exception_ce, "Bad or missing argument", 500 TSRMLS_CC); 51 | return; 52 | } 53 | zend_update_property_stringl(riak_index_result_ce, getThis(), "key", sizeof("key")-1, key, key_len TSRMLS_CC); 54 | } 55 | /* }}} */ 56 | 57 | 58 | /* {{{ proto Riak\Output\IndexResult Riak\Output\IndexResult->getKey() 59 | Get key */ 60 | PHP_METHOD(Riak_Output_IndexResult, getKey) 61 | { 62 | RIAK_GETTER_STRING(riak_index_result_ce, "key") 63 | } 64 | /* }}} */ 65 | -------------------------------------------------------------------------------- /riak/output/index_result.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUT__INDEX_RESULT__H__ 18 | #define RIAK_OUTPUT__INDEX_RESULT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_index_result_ce; 23 | 24 | void riak_output_index_result_init(TSRMLS_D); 25 | 26 | PHP_METHOD(Riak_Output_IndexResult, __construct); 27 | PHP_METHOD(Riak_Output_IndexResult, getKey); 28 | 29 | #endif //RIAK_OUTPUT__INDEX_RESULT__H__ 30 | -------------------------------------------------------------------------------- /riak/output/index_result_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUT__INDEX_RESULT_LIST__H__ 18 | #define RIAK_OUTPUT__INDEX_RESULT_LIST__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_index_result_list_ce; 23 | 24 | void riak_output_index_result_list_init(TSRMLS_D); 25 | 26 | PHP_METHOD(Riak_Index_Result_List, __construct); 27 | PHP_METHOD(Riak_Index_Result_List, offsetExists); 28 | PHP_METHOD(Riak_Index_Result_List, offsetGet); 29 | PHP_METHOD(Riak_Index_Result_List, offsetSet); 30 | PHP_METHOD(Riak_Index_Result_List, offsetUnset); 31 | PHP_METHOD(Riak_Index_Result_List, count); 32 | PHP_METHOD(Riak_Index_Result_List, getIterator); 33 | 34 | 35 | #endif //RIAK_OUTPUT__INDEX_RESULT_LIST__H__ 36 | -------------------------------------------------------------------------------- /riak/output/key_stream_output.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "key_stream_output.h" 17 | 18 | zend_class_entry *riak_key_streamer_ce; 19 | 20 | ZEND_BEGIN_ARG_INFO_EX(arginfo_keystreamer_key, 0, ZEND_RETURN_VALUE, 1) 21 | ZEND_ARG_INFO(0, key) 22 | ZEND_END_ARG_INFO() 23 | 24 | static zend_function_entry riak_keystreamer_methods[] = { 25 | ZEND_ABSTRACT_ME(RiakKeyStreamer, process, arginfo_keystreamer_key) 26 | {NULL, NULL, NULL} 27 | }; 28 | 29 | void riak_output_stream_output_init(TSRMLS_D)/* {{{ */ 30 | { 31 | zend_class_entry ce; 32 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Output", "KeyStreamOutput", riak_keystreamer_methods); 33 | riak_key_streamer_ce = zend_register_internal_interface(&ce TSRMLS_CC); 34 | } 35 | /* }}} */ 36 | 37 | -------------------------------------------------------------------------------- /riak/output/key_stream_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK__OUTPUT__KEY_STREAMING_OUTPUT__H__ 18 | #define RIAK__OUTPUT__KEY_STREAMING_OUTPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_key_streamer_ce; 23 | 24 | void riak_output_stream_output_init(TSRMLS_D); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /riak/output/output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUTS__H__ 18 | #define RIAK_OUTPUTS__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_output_ce; 23 | 24 | void riak_output_init(TSRMLS_D); 25 | 26 | void riak_set_output_properties(zval* zoutput, zval* zkey, riack_object* obj TSRMLS_DC); 27 | 28 | PHP_METHOD(Riak_Output_Output, getObjectList); 29 | PHP_METHOD(Riak_Output_Output, getVClock); 30 | PHP_METHOD(Riak_Output_Output, getKey); 31 | PHP_METHOD(Riak_Output_Output, hasSiblings); 32 | PHP_METHOD(Riak_Output_Output, hasObject); 33 | PHP_METHOD(Riak_Output_Output, getObject); 34 | PHP_METHOD(Riak_Output_Output, getFirstObject); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /riak/output/put_output.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "put_output.h" 18 | #include "output.h" 19 | 20 | zend_class_entry *riak_put_output_ce; 21 | 22 | static zend_function_entry riak_put_output_methods[] = { 23 | {NULL, NULL, NULL} 24 | }; 25 | 26 | void riak_output_put_output_init(TSRMLS_D)/* {{{ */ 27 | { 28 | zend_class_entry ce; 29 | 30 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Output", "PutOutput", riak_put_output_methods); 31 | riak_put_output_ce = zend_register_internal_class_ex(&ce, riak_output_ce, NULL TSRMLS_CC); 32 | } 33 | /* }}} */ 34 | 35 | 36 | zval *put_output_from_riack_object(riack_object* obj, zval* zkey TSRMLS_DC) /* {{{ */ 37 | { 38 | zval *zoutput; 39 | MAKE_STD_ZVAL(zoutput); 40 | object_init_ex(zoutput, riak_put_output_ce); 41 | riak_set_output_properties(zoutput, zkey, obj TSRMLS_CC); 42 | return zoutput; 43 | } 44 | /* }}} */ 45 | 46 | -------------------------------------------------------------------------------- /riak/output/put_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUT__PUT_OUTPUT__H__ 18 | #define RIAK_OUTPUT__PUT_OUTPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_put_output_ce; 23 | 24 | void riak_output_put_output_init(TSRMLS_D); 25 | zval *put_output_from_riack_object(riack_object* obj, zval* zkey TSRMLS_DC); 26 | 27 | #endif //RIAK_OUTPUT__PUT_OUTPUT__H__ 28 | -------------------------------------------------------------------------------- /riak/output/youngest_sibling_resolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_OUTPUT__FIRST_SIBLING_RESOLVER__H__ 18 | #define RIAK_OUTPUT__FIRST_SIBLING_RESOLVER__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | PHP_METHOD(Riak_Output_YoungestSiblingResolver, resolve); 23 | 24 | extern zend_class_entry *riak_output_youngest_sibling_resolver_ce; 25 | 26 | void riak_output_youngest_sibling_resolver_init(TSRMLS_D); 27 | 28 | #endif //RIAK_OUTPUT__FIRST_SIBLING_RESOLVER__H__ 29 | -------------------------------------------------------------------------------- /riak/pool.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_POOL__H__ 19 | #define RIAK_POOL__H__ 20 | 21 | #include "php_riak_internal.h" 22 | #include 23 | #include 24 | 25 | typedef struct _riak_connection { 26 | riack_client *client; 27 | zend_bool needs_reconnect; 28 | zend_bool persistent; 29 | time_t last_used_at; 30 | } riak_connection; 31 | 32 | typedef struct _riak_connection_pool_entry { 33 | zend_bool in_use; 34 | riak_connection connection; 35 | } riak_connection_pool_entry; 36 | 37 | typedef struct _riak_connection_pool { 38 | int count; 39 | riak_connection_pool_entry *entries; 40 | } riak_connection_pool; 41 | 42 | zend_bool ensure_connected(riak_connection *connection TSRMLS_DC); 43 | zend_bool ensure_connected_init(riak_connection *connection, char* host, int host_len, int port TSRMLS_DC); 44 | void mark_for_reconnect(riak_connection *connection); 45 | 46 | void release_connection(riak_connection *connection TSRMLS_DC); 47 | riak_connection *take_connection(char* host, int host_len, int port TSRMLS_DC); 48 | 49 | void le_riak_connections_pefree(zend_rsrc_list_entry *rsrc TSRMLS_DC); 50 | 51 | /* Internal */ 52 | void release_connection_from_pool(riak_connection_pool* pool, riak_connection *connection); 53 | riak_connection_pool *pool_for_host_port(char* host, int host_len, int port TSRMLS_DC); 54 | riak_connection_pool_entry *take_connection_entry_from_pool(riak_connection_pool *pool); 55 | riak_connection_pool* initialize_pool(TSRMLS_D); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /riak/pool_info.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #include "pool_info.h" 19 | 20 | zend_class_entry *riak_poolinfo_ce; 21 | 22 | static zend_function_entry riak_pool_info_methods[] = { 23 | PHP_ME(RiakPoolInfo, getNumActiveConnection, NULL, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) 24 | PHP_ME(RiakPoolInfo, getNumActivePersistentConnection, NULL, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) 25 | PHP_ME(RiakPoolInfo, getNumReconnect, NULL, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) 26 | {NULL, NULL, NULL} 27 | }; 28 | 29 | /* {{{ proto int Riak\PoolInfo::getNumActiveConnection() 30 | Returns number of active riak connections */ 31 | PHP_METHOD(RiakPoolInfo, getNumActiveConnection) 32 | { 33 | RETURN_LONG(RIAK_GLOBAL(open_connections)); 34 | } 35 | /* }}} */ 36 | 37 | /* {{{ proto int Riak\PoolInfo::getNumActivePersistentConnection() 38 | Returns number of active persistent riak connections */ 39 | PHP_METHOD(RiakPoolInfo, getNumActivePersistentConnection) 40 | { 41 | RETURN_LONG(RIAK_GLOBAL(open_connections_persistent)); 42 | } 43 | /* }}} */ 44 | 45 | /* {{{ proto int Riak\PoolInfo::getNumReconnect() 46 | How many reconnections has been performed, persistent and nonpersistent */ 47 | PHP_METHOD(RiakPoolInfo, getNumReconnect) 48 | { 49 | long reconnects = RIAK_GLOBAL(reconnects); 50 | RETURN_LONG(reconnects); 51 | } 52 | /* }}} */ 53 | 54 | void riak_poolinfo_init(TSRMLS_D) /* {{{ */ 55 | { 56 | zend_class_entry ce; 57 | 58 | INIT_NS_CLASS_ENTRY(ce, "Riak", "PoolInfo", riak_pool_info_methods); 59 | riak_poolinfo_ce = zend_register_internal_class(&ce TSRMLS_CC); 60 | } 61 | /* }}} */ 62 | -------------------------------------------------------------------------------- /riak/pool_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_POOL_INFO__H__ 19 | #define RIAK_POOL_INFO__H__ 20 | 21 | #include "php_riak_internal.h" 22 | 23 | extern zend_class_entry *riak_poolinfo_ce; 24 | 25 | PHP_METHOD(RiakPoolInfo, getNumActiveConnection); 26 | PHP_METHOD(RiakPoolInfo, getNumActivePersistentConnection); 27 | PHP_METHOD(RiakPoolInfo, getNumReconnect); 28 | 29 | void riak_poolinfo_init(TSRMLS_D); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /riak/property/commit_hook.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "commit_hook.h" 17 | #include "riak/exception/exception.h" 18 | 19 | zend_class_entry *riak_commit_hook_ce; 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_commit_hook_ctor, 0, ZEND_RETURN_VALUE, 1) 22 | ZEND_ARG_INFO(0, moduleOrName) 23 | ZEND_ARG_INFO(0, function) 24 | ZEND_END_ARG_INFO() 25 | 26 | ZEND_BEGIN_ARG_INFO_EX(arginfo_commit_hook_set, 0, ZEND_RETURN_VALUE, 1) 27 | ZEND_ARG_INFO(0, value) 28 | ZEND_END_ARG_INFO() 29 | 30 | ZEND_BEGIN_ARG_INFO_EX(arginfo_commit_hook_noargs, 0, ZEND_RETURN_VALUE, 0) 31 | ZEND_END_ARG_INFO() 32 | 33 | 34 | static zend_function_entry riak_commit_hook_methods[] = { 35 | PHP_ME(RiakCommitHook, __construct, arginfo_commit_hook_ctor, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) 36 | PHP_ME(RiakCommitHook, getJsName, arginfo_commit_hook_noargs, ZEND_ACC_PUBLIC) 37 | PHP_ME(RiakCommitHook, getErlModule, arginfo_commit_hook_noargs, ZEND_ACC_PUBLIC) 38 | PHP_ME(RiakCommitHook, getErlFunction, arginfo_commit_hook_set, ZEND_ACC_PUBLIC) 39 | PHP_ME(RiakCommitHook, isJavascript, arginfo_commit_hook_noargs, ZEND_ACC_PUBLIC) 40 | PHP_ME(RiakCommitHook, isErlang, arginfo_commit_hook_noargs, ZEND_ACC_PUBLIC) 41 | {NULL, NULL, NULL} 42 | }; 43 | 44 | void riak_property_commit_hook_init(TSRMLS_D)/* {{{ */ 45 | { 46 | zend_class_entry ce; 47 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Property", "CommitHook", riak_commit_hook_methods); 48 | riak_commit_hook_ce = zend_register_internal_class(&ce TSRMLS_CC); 49 | zend_declare_property_null(riak_commit_hook_ce, "moduleOrName", sizeof("moduleOrName")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 50 | zend_declare_property_null(riak_commit_hook_ce, "function", sizeof("function")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 51 | 52 | } 53 | /* }}} */ 54 | 55 | 56 | /* {{{ proto void Riak\Property\CommitHook->__construct(string $name, ModuleFunction $moduleFunction) 57 | Creates a new Riak\Property\CommitHook */ 58 | PHP_METHOD(RiakCommitHook, __construct) 59 | { 60 | char *mod_or_name, *fun; 61 | int mod_or_name_len, fun_len; 62 | fun_len = 0; 63 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &mod_or_name, &mod_or_name_len, &fun, &fun_len) == FAILURE) { 64 | zend_throw_exception(riak_badarguments_exception_ce, "Bad or missing argument", 500 TSRMLS_CC); 65 | return; 66 | } 67 | zend_update_property_stringl(riak_commit_hook_ce, getThis(), "moduleOrName", sizeof("moduleOrName")-1, mod_or_name, mod_or_name_len TSRMLS_CC); 68 | if (fun_len > 0) { 69 | zend_update_property_stringl(riak_commit_hook_ce, getThis(), "function", sizeof("function")-1, fun, fun_len TSRMLS_CC); 70 | } 71 | } 72 | /* }}} */ 73 | 74 | PHP_METHOD(RiakCommitHook, getJsName) 75 | { 76 | RIAK_GETTER_STRING(riak_commit_hook_ce, "moduleOrName") 77 | } 78 | 79 | PHP_METHOD(RiakCommitHook, getErlModule) 80 | { 81 | RIAK_GETTER_STRING(riak_commit_hook_ce, "moduleOrName") 82 | } 83 | 84 | PHP_METHOD(RiakCommitHook, getErlFunction) 85 | { 86 | RIAK_GETTER_STRING(riak_commit_hook_ce, "function") 87 | } 88 | 89 | PHP_METHOD(RiakCommitHook, isJavascript) 90 | { 91 | zval* ztmp = zend_read_property(riak_commit_hook_ce, getThis(), "function", sizeof("function")-1, 1 TSRMLS_CC); 92 | if (Z_TYPE_P(ztmp) == IS_STRING) { 93 | RETURN_FALSE; 94 | } 95 | RETURN_TRUE; 96 | } 97 | 98 | PHP_METHOD(RiakCommitHook, isErlang) 99 | { 100 | zval* ztmp = zend_read_property(riak_commit_hook_ce, getThis(), "function", sizeof("function")-1, 1 TSRMLS_CC); 101 | if (Z_TYPE_P(ztmp) == IS_STRING) { 102 | RETURN_TRUE; 103 | } 104 | RETURN_FALSE; 105 | } 106 | 107 | -------------------------------------------------------------------------------- /riak/property/commit_hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_PROPERTY__COMMIT_HOOK__H__ 18 | #define RIAK_PROPERTY__COMMIT_HOOK__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_commit_hook_ce; 23 | 24 | void riak_property_commit_hook_init(TSRMLS_D); 25 | 26 | PHP_METHOD(RiakCommitHook, __construct); 27 | PHP_METHOD(RiakCommitHook, getJsName); 28 | PHP_METHOD(RiakCommitHook, getErlModule); 29 | PHP_METHOD(RiakCommitHook, getErlFunction); 30 | PHP_METHOD(RiakCommitHook, isJavascript); 31 | PHP_METHOD(RiakCommitHook, isErlang); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /riak/property/commit_hook_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #ifndef RIAK_PROPERTY__COMMIT_HOOK_LIST__H__ 17 | #define RIAK_PROPERTY__COMMIT_HOOK_LIST__H__ 18 | 19 | #include "php_riak_internal.h" 20 | 21 | extern zend_class_entry *riak_commit_hook_list_ce; 22 | 23 | void riak_property_commit_hook_list_init(TSRMLS_D); 24 | 25 | PHP_METHOD(RiakCommitHookList, __construct); 26 | PHP_METHOD(RiakCommitHookList, offsetExists); 27 | PHP_METHOD(RiakCommitHookList, offsetGet); 28 | PHP_METHOD(RiakCommitHookList, offsetSet); 29 | PHP_METHOD(RiakCommitHookList, offsetUnset); 30 | PHP_METHOD(RiakCommitHookList, count); 31 | PHP_METHOD(RiakCommitHookList, getIterator); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /riak/property/module_function.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "module_function.h" 17 | #include "riak/exception/exception.h" 18 | 19 | zend_class_entry *riak_module_function_ce; 20 | 21 | 22 | ZEND_BEGIN_ARG_INFO_EX(arginfo_module_function_ctor, 0, ZEND_RETURN_VALUE, 2) 23 | ZEND_ARG_INFO(0, module) 24 | ZEND_ARG_INFO(0, function) 25 | ZEND_END_ARG_INFO() 26 | 27 | ZEND_BEGIN_ARG_INFO_EX(arginfo_module_function_set, 0, ZEND_RETURN_VALUE, 1) 28 | ZEND_ARG_INFO(0, value) 29 | ZEND_END_ARG_INFO() 30 | 31 | ZEND_BEGIN_ARG_INFO_EX(arginfo_module_function_noargs, 0, ZEND_RETURN_VALUE, 0) 32 | ZEND_END_ARG_INFO() 33 | 34 | 35 | static zend_function_entry riak_module_function_methods[] = { 36 | PHP_ME(RiakModuleFunction, __construct, arginfo_module_function_ctor, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) 37 | PHP_ME(RiakModuleFunction, getModule, arginfo_module_function_noargs, ZEND_ACC_PUBLIC) 38 | PHP_ME(RiakModuleFunction, setModule, arginfo_module_function_set, ZEND_ACC_PUBLIC) 39 | PHP_ME(RiakModuleFunction, getFunction, arginfo_module_function_noargs, ZEND_ACC_PUBLIC) 40 | PHP_ME(RiakModuleFunction, setFunction, arginfo_module_function_set, ZEND_ACC_PUBLIC) 41 | {NULL, NULL, NULL} 42 | }; 43 | 44 | 45 | void riak_property_module_function_init(TSRMLS_D)/* {{{ */ 46 | { 47 | zend_class_entry ce; 48 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Property", "ModuleFunction", riak_module_function_methods); 49 | riak_module_function_ce = zend_register_internal_class(&ce TSRMLS_CC); 50 | zend_declare_property_null(riak_module_function_ce, "module", sizeof("module")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 51 | zend_declare_property_null(riak_module_function_ce, "function", sizeof("function")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 52 | } 53 | /* }}} */ 54 | 55 | 56 | /* {{{ proto void Riak\Property\ModuleFunction->__construct(string $module, string $function) 57 | Creates a new Riak\Property\ModuleFunction */ 58 | PHP_METHOD(RiakModuleFunction, __construct) 59 | { 60 | char *module, *efunction; 61 | int module_len, efunction_len; 62 | 63 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &module, &module_len, &efunction, &efunction_len) == FAILURE) { 64 | zend_throw_exception(riak_badarguments_exception_ce, "Bad or missing argument", 500 TSRMLS_CC); 65 | return; 66 | } 67 | 68 | zend_update_property_stringl(riak_module_function_ce, getThis(), "module", sizeof("module")-1, module, module_len TSRMLS_CC); 69 | zend_update_property_stringl(riak_module_function_ce, getThis(), "function", sizeof("function")-1, efunction, efunction_len TSRMLS_CC); 70 | } 71 | /* }}} */ 72 | 73 | PHP_METHOD(RiakModuleFunction, getModule) 74 | { 75 | RIAK_GETTER_STRING(riak_module_function_ce, "module") 76 | } 77 | 78 | PHP_METHOD(RiakModuleFunction, setModule) 79 | { 80 | RIAK_SETTER_STRING(riak_module_function_ce, "module") 81 | RIAK_RETURN_THIS 82 | } 83 | 84 | PHP_METHOD(RiakModuleFunction, getFunction) 85 | { 86 | RIAK_GETTER_STRING(riak_module_function_ce, "function") 87 | } 88 | 89 | PHP_METHOD(RiakModuleFunction, setFunction) 90 | { 91 | RIAK_SETTER_STRING(riak_module_function_ce, "function") 92 | RIAK_RETURN_THIS 93 | } 94 | 95 | -------------------------------------------------------------------------------- /riak/property/module_function.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_PROPERTY__MODULE_FUNCTION__H__ 18 | #define RIAK_PROPERTY__MODULE_FUNCTION__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_module_function_ce; 23 | 24 | void riak_property_module_function_init(TSRMLS_D); 25 | 26 | PHP_METHOD(RiakModuleFunction, __construct); 27 | PHP_METHOD(RiakModuleFunction, getModule); 28 | PHP_METHOD(RiakModuleFunction, setModule); 29 | PHP_METHOD(RiakModuleFunction, getFunction); 30 | PHP_METHOD(RiakModuleFunction, setFunction); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /riak/property/replication_mode/replication_mode.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "replication_mode.h" 17 | 18 | 19 | zend_class_entry *riak_replication_mode_ce; 20 | zend_class_entry *riak_replication_mode_full_only_ce; 21 | zend_class_entry *riak_replication_mode_disabled_ce; 22 | zend_class_entry *riak_replication_mode_realtime_and_full_ce; 23 | zend_class_entry *riak_replication_mode_realtime_only_ce; 24 | 25 | static zend_function_entry riak_replication_mode_functions[] = { 26 | {NULL, NULL, NULL} 27 | }; 28 | 29 | 30 | void riak_property_replication_mode_init(TSRMLS_D)/* {{{ */ 31 | { 32 | zend_class_entry ce; 33 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Property\\ReplicationMode", "ReplicationMode", riak_replication_mode_functions); 34 | riak_replication_mode_ce = zend_register_internal_interface(&ce TSRMLS_CC); 35 | 36 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Property\\ReplicationMode", "FullSyncOnly", riak_replication_mode_functions); 37 | riak_replication_mode_full_only_ce = zend_register_internal_class(&ce TSRMLS_CC); 38 | zend_class_implements(riak_replication_mode_full_only_ce TSRMLS_CC, 1, riak_replication_mode_ce); 39 | 40 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Property\\ReplicationMode", "Disabled", riak_replication_mode_functions); 41 | riak_replication_mode_disabled_ce = zend_register_internal_class(&ce TSRMLS_CC); 42 | zend_class_implements(riak_replication_mode_disabled_ce TSRMLS_CC, 1, riak_replication_mode_ce); 43 | 44 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Property\\ReplicationMode", "RealTimeAndFullSync", riak_replication_mode_functions); 45 | riak_replication_mode_realtime_and_full_ce = zend_register_internal_class(&ce TSRMLS_CC); 46 | zend_class_implements(riak_replication_mode_realtime_and_full_ce TSRMLS_CC, 1, riak_replication_mode_ce); 47 | 48 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Property\\ReplicationMode", "RealTimeOnly", riak_replication_mode_functions); 49 | riak_replication_mode_realtime_only_ce = zend_register_internal_class(&ce TSRMLS_CC); 50 | zend_class_implements(riak_replication_mode_realtime_only_ce TSRMLS_CC, 1, riak_replication_mode_ce); 51 | 52 | } 53 | /* }}} */ 54 | 55 | -------------------------------------------------------------------------------- /riak/property/replication_mode/replication_mode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_PROPERTY__REPLICATION_MODE__REPLICATION_MODE__H__ 18 | #define RIAK_PROPERTY__REPLICATION_MODE__REPLICATION_MODE__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | void riak_property_replication_mode_init(TSRMLS_D); 23 | 24 | extern zend_class_entry *riak_replication_mode_ce; 25 | extern zend_class_entry *riak_replication_mode_full_only_ce; 26 | extern zend_class_entry *riak_replication_mode_disabled_ce; 27 | extern zend_class_entry *riak_replication_mode_realtime_and_full_ce; 28 | extern zend_class_entry *riak_replication_mode_realtime_only_ce; 29 | 30 | #endif // RIAK_PROPERTY__REPLICATION_MODE__REPLICATION_MODE__H__ 31 | -------------------------------------------------------------------------------- /riak/query/index_query.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_QUERY__INDEX_QUERY__H__ 18 | #define RIAK_QUERY__INDEX_QUERY__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_index_query_ce; 23 | 24 | void riak_query_index_query_init(TSRMLS_D); 25 | 26 | PHP_METHOD(Riak_Query_IndexQuery, setName); 27 | PHP_METHOD(Riak_Query_IndexQuery, getName); 28 | PHP_METHOD(Riak_Query_IndexQuery, setExactValue); 29 | PHP_METHOD(Riak_Query_IndexQuery, getExactValue); 30 | PHP_METHOD(Riak_Query_IndexQuery, setRangeValue); 31 | PHP_METHOD(Riak_Query_IndexQuery, getRangeValue); 32 | PHP_METHOD(Riak_Query_IndexQuery, isRangeQuery); 33 | PHP_METHOD(Riak_Query_IndexQuery, __construct); 34 | 35 | #endif //RIAK_QUERY__INDEX_QUERY__H__ 36 | -------------------------------------------------------------------------------- /riak/search/input/parameter_bag.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_SEARCH__INPUT__PARAMETER_BAG__H__ 18 | #define RIAK_SEARCH__INPUT__PARAMETER_BAG__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_search_input_ce; 23 | 24 | void riak_search_input_parameterbag_init(TSRMLS_D); 25 | 26 | /* Search\Input */ 27 | PHP_METHOD(Riak_Search_Input, setRowLimit); 28 | PHP_METHOD(Riak_Search_Input, getRowLimit); 29 | PHP_METHOD(Riak_Search_Input, setStartOffset); 30 | PHP_METHOD(Riak_Search_Input, getStartOffset); 31 | PHP_METHOD(Riak_Search_Input, setSort); 32 | PHP_METHOD(Riak_Search_Input, getSort); 33 | PHP_METHOD(Riak_Search_Input, setFilter); 34 | PHP_METHOD(Riak_Search_Input, getFilter); 35 | PHP_METHOD(Riak_Search_Input, setDefaultField); 36 | PHP_METHOD(Riak_Search_Input, getDefaultField); 37 | PHP_METHOD(Riak_Search_Input, setDefaultOperation); 38 | PHP_METHOD(Riak_Search_Input, getDefaultOperation); 39 | PHP_METHOD(Riak_Search_Input, setPresort); 40 | PHP_METHOD(Riak_Search_Input, getPresort); 41 | PHP_METHOD(Riak_Search_Input, setFieldLimits); 42 | PHP_METHOD(Riak_Search_Input, getFieldLimits); 43 | 44 | #endif // RIAK_SEARCH__INPUT__PARAMETER_BAG__H__ 45 | -------------------------------------------------------------------------------- /riak/search/output/document_output.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "document_output.h" 17 | 18 | zend_class_entry *riak_search_doc_ce; 19 | 20 | ZEND_BEGIN_ARG_INFO_EX(arginfo_search_output_document_noargs, 0, ZEND_RETURN_VALUE, 0) 21 | ZEND_END_ARG_INFO() 22 | 23 | static zend_function_entry riak_search_doc_methods[] = { 24 | PHP_ME(Riak_Search_Output_DocumentOutput, getFields, arginfo_search_output_document_noargs, ZEND_ACC_PUBLIC) 25 | {NULL, NULL, NULL} 26 | }; 27 | 28 | void riak_search_output_document_output_init(TSRMLS_D) /* {{{ */ 29 | { 30 | zend_class_entry ce; 31 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Search\\Output", "DocumentOutput", riak_search_doc_methods); 32 | riak_search_doc_ce = zend_register_internal_class(&ce TSRMLS_CC); 33 | zend_declare_property_null(riak_search_doc_ce, "fields", sizeof("fields")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 34 | } 35 | /* }}} */ 36 | 37 | zval *riak_search_document_from_riack_document(riack_search_doc* document TSRMLS_DC) /* {{{ */ 38 | { 39 | int cnt, i; 40 | zval *zresult, *zarr; 41 | MAKE_STD_ZVAL(zarr) 42 | array_init(zarr); 43 | 44 | MAKE_STD_ZVAL(zresult) 45 | object_init_ex(zresult, riak_search_doc_ce); 46 | 47 | cnt = document->field_count; 48 | for (i=0; ifields[i]; 52 | key_len = current_pair->key.len; 53 | // Silly... we need to make a copy because add_assoc relies on zero terminated string 54 | // riack will not zero terminate since it includes a length. 55 | // However estrndup will be nice enough to add a zero termination for us... 56 | szkey = estrndup(current_pair->key.value, key_len); 57 | if (current_pair->value_present) { 58 | add_assoc_stringl_ex(zarr, szkey, key_len + 1, 59 | (char*)current_pair->value, current_pair->value_len, 1); 60 | } else { 61 | add_assoc_null_ex(zarr, szkey, key_len+1); 62 | } 63 | efree(szkey); 64 | } 65 | zend_update_property(riak_search_doc_ce, zresult, "fields", sizeof("fields")-1, zarr TSRMLS_CC); 66 | zval_ptr_dtor(&zarr); 67 | return zresult; 68 | } 69 | /* }}} */ 70 | 71 | 72 | /************************************************************* 73 | * Implementation: Riak\Search\Output\DocumentOutput 74 | *************************************************************/ 75 | 76 | PHP_METHOD(Riak_Search_Output_DocumentOutput, getFields) 77 | { 78 | RIAK_GETTER_ARRAY(riak_search_doc_ce, "fields"); 79 | } 80 | 81 | -------------------------------------------------------------------------------- /riak/search/output/document_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK__SEARCH__OUTPUT__DOCUMENT_OUTPUT__H__ 18 | #define RIAK__SEARCH__OUTPUT__DOCUMENT_OUTPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_search_doc_ce; 23 | 24 | void riak_search_output_document_output_init(TSRMLS_D); 25 | zval *riak_search_document_from_riack_document(riack_search_doc* document TSRMLS_DC); 26 | 27 | 28 | /* Riak\Search\Output\DocumentOutput */ 29 | PHP_METHOD(Riak_Search_Output_DocumentOutput, getFields); 30 | 31 | #endif //#ifndef RIAK__SEARCH__OUTPUT__DOCUMENT_OUTPUT__H__ 32 | -------------------------------------------------------------------------------- /riak/search/output/output.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #include "output.h" 17 | #include "document_output.h" 18 | 19 | zend_class_entry *riak_search_output_ce; 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_search_output_noargs, 0, ZEND_RETURN_VALUE, 0) 22 | ZEND_END_ARG_INFO() 23 | 24 | static zend_function_entry riak_search_output_methods[] = { 25 | PHP_ME(Riak_Search_Output_Output, hasMaxScore, arginfo_search_output_noargs, ZEND_ACC_PUBLIC) 26 | PHP_ME(Riak_Search_Output_Output, getMaxScore, arginfo_search_output_noargs, ZEND_ACC_PUBLIC) 27 | PHP_ME(Riak_Search_Output_Output, hasNumFound, arginfo_search_output_noargs, ZEND_ACC_PUBLIC) 28 | PHP_ME(Riak_Search_Output_Output, getNumFound, arginfo_search_output_noargs, ZEND_ACC_PUBLIC) 29 | PHP_ME(Riak_Search_Output_Output, getDocuments, arginfo_search_output_noargs, ZEND_ACC_PUBLIC) 30 | {NULL, NULL, NULL} 31 | }; 32 | 33 | void riak_search_output_output_init(TSRMLS_D) /* {{{ */ 34 | { 35 | zend_class_entry ce; 36 | INIT_NS_CLASS_ENTRY(ce, "Riak\\Search\\Output", "Output", riak_search_output_methods); 37 | riak_search_output_ce = zend_register_internal_class(&ce TSRMLS_CC); 38 | zend_declare_property_null(riak_search_output_ce, "maxScore", sizeof("maxScore")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 39 | zend_declare_property_null(riak_search_output_ce, "numFound", sizeof("numFound")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 40 | zend_declare_property_null(riak_search_output_ce, "documents", sizeof("documents")-1, ZEND_ACC_PRIVATE TSRMLS_CC); 41 | } 42 | /* }}} */ 43 | 44 | /************************************************************* 45 | * Implementation: Riak\Search\Output\Output 46 | *************************************************************/ 47 | 48 | zval* riak_search_output_from_riack_search_result(riack_search_result *search_result TSRMLS_DC) 49 | { 50 | zval *zresult; 51 | MAKE_STD_ZVAL(zresult); 52 | object_init_ex(zresult, riak_search_output_ce); 53 | if (search_result->document_count > 0) { 54 | int cnt, i; 55 | zval* zdocs; 56 | cnt = search_result->document_count; 57 | MAKE_STD_ZVAL(zdocs); 58 | array_init(zdocs); 59 | for (i=0; idocuments[i] TSRMLS_CC); 61 | add_next_index_zval(zdocs, doc); 62 | } 63 | zend_update_property(riak_search_output_ce, zresult, "documents", sizeof("documents")-1, zdocs TSRMLS_CC); 64 | zval_ptr_dtor(&zdocs); 65 | } 66 | if (search_result->max_score_present) { 67 | zend_update_property_double(riak_search_output_ce, zresult, "maxScore", sizeof("maxScore")-1, search_result->max_score TSRMLS_CC); 68 | } 69 | if (search_result->num_found_present) { 70 | zend_update_property_long(riak_search_output_ce, zresult, "numFound", sizeof("numFound")-1, search_result->num_found TSRMLS_CC); 71 | } 72 | return zresult; 73 | } 74 | 75 | PHP_METHOD(Riak_Search_Output_Output, hasMaxScore) 76 | { 77 | zval *zprop = zend_read_property(riak_search_output_ce, getThis(), "maxScore", sizeof("maxScore")-1, 1 TSRMLS_CC); 78 | if (!zprop || Z_TYPE_P(zprop) == IS_NULL) { 79 | RETURN_BOOL(0); 80 | } 81 | RETURN_BOOL(1); 82 | } 83 | 84 | PHP_METHOD(Riak_Search_Output_Output, getMaxScore) 85 | { 86 | RIAK_GETTER_DOUBLE(riak_search_output_ce, "maxScore"); 87 | } 88 | 89 | PHP_METHOD(Riak_Search_Output_Output, hasNumFound) 90 | { 91 | zval *zprop = zend_read_property(riak_search_output_ce, getThis(), "numFound", sizeof("numFound")-1, 1 TSRMLS_CC); 92 | if (zprop == NULL || Z_TYPE_P(zprop) == IS_NULL) { 93 | RETURN_BOOL(0); 94 | } 95 | RETURN_BOOL(1); 96 | } 97 | 98 | PHP_METHOD(Riak_Search_Output_Output, getNumFound) 99 | { 100 | RIAK_GETTER_LONG(riak_search_output_ce, "numFound"); 101 | } 102 | 103 | PHP_METHOD(Riak_Search_Output_Output, getDocuments) 104 | { 105 | RIAK_GETTER_ARRAY(riak_search_output_ce, "documents"); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /riak/search/output/output.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_SEARCH__OUTPUT__OUTPUT__H__ 18 | #define RIAK_SEARCH__OUTPUT__OUTPUT__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_search_output_ce; 23 | 24 | void riak_search_output_output_init(TSRMLS_D); 25 | 26 | /* Riak\Search\Output\Output */ 27 | PHP_METHOD(Riak_Search_Output_Output, hasMaxScore); 28 | PHP_METHOD(Riak_Search_Output_Output, getMaxScore); 29 | PHP_METHOD(Riak_Search_Output_Output, hasNumFound); 30 | PHP_METHOD(Riak_Search_Output_Output, getNumFound); 31 | PHP_METHOD(Riak_Search_Output_Output, getDocuments); 32 | 33 | #endif // RIAK_SEARCH__OUTPUT__OUTPUT__H__ 34 | -------------------------------------------------------------------------------- /riak/search/search.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK_SEARCH__H__ 18 | #define RIAK_SEARCH__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_search_ce; 23 | 24 | /* helpers */ 25 | 26 | void riak_search_init(TSRMLS_D); 27 | void riak_search_set_optional_params(riack_client *client, zval* zparams, riack_search_optional_params* search_params TSRMLS_DC); 28 | void riak_search_free_optional_params(riack_client *client, riack_search_optional_params* search_params TSRMLS_DC); 29 | 30 | zval* riak_search_output_from_riack_search_result(riack_search_result *search_result TSRMLS_DC); 31 | 32 | /* Search */ 33 | 34 | PHP_METHOD(Riak_Search, __construct); 35 | PHP_METHOD(Riak_Search, search); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /riak/server_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013: Kaspar Bach Pedersen 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef RIAK__SERVER_INFO__H__ 18 | #define RIAK__SERVER_INFO__H__ 19 | 20 | #include "php_riak_internal.h" 21 | 22 | extern zend_class_entry *riak_server_info_ce; 23 | 24 | void riak_server_info_init(TSRMLS_D); 25 | 26 | PHP_METHOD(Riak_Server_Info, __construct); 27 | PHP_METHOD(Riak_Server_Info, getNode); 28 | PHP_METHOD(Riak_Server_Info, getServerVersion); 29 | 30 | #endif //RIAK__SERVER_INFO__H__ 31 | -------------------------------------------------------------------------------- /riak_session.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Trifork A/S 3 | Author: Kaspar Bach Pedersen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #ifndef RIAK_SESSION__H__ 19 | #define RIAK_SESSION__H__ 20 | 21 | #include "php_riak_internal.h" 22 | #include "ext/session/php_session.h" 23 | 24 | #ifdef PHP_RIAK_SESSION 25 | 26 | PS_FUNCS(riak); 27 | 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /script/build_module.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | phpize 4 | ./configure --quiet 5 | make install 6 | echo "extension=riak.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` 7 | -------------------------------------------------------------------------------- /script/configure-riak.php: -------------------------------------------------------------------------------- 1 | 7 | // {riak_search, [ 8 | // %% To enable Search functionality set this 'true'. 9 | // {enabled, true} 10 | // ]}, 11 | 12 | // {storage_backend, riak_kv_bitcask_backend}, 13 | //--> 14 | // {storage_backend, riak_kv_eleveldb_backend}, -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | *.diff 2 | *.exp 3 | *.log 4 | *.php 5 | *.sh 6 | *.out -------------------------------------------------------------------------------- /tests/bucket.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Riak\Bucket throws exception when connection is NULL 3 | --FILE-- 4 | getType() != 'phpriak_type') { 11 | echo "type mismatch " . $bucket->getType() . PHP_EOL; 12 | } 13 | if ($bucket->getName() == 'test') { 14 | echo "done!" . PHP_EOL; 15 | } 16 | } catch (\Riak\Exception\BadArgumentsException $e) { 17 | echo $e->getMessage(); 18 | } 19 | 20 | ?> 21 | --EXPECTF-- 22 | Warning: Riak\Bucket::__construct() expects parameter 1 to be Riak\Connection, null given in %s on line %d 23 | Bad or missing argument 24 | -------------------------------------------------------------------------------- /tests/bucket_props.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bucket properties old 3 | --FILE-- 4 | getPropertyList(); 10 | $newProps = new BucketPropertyList(1, false); 11 | $bucket->setPropertyList($newProps); 12 | $currentProps = $bucket->getPropertyList(); 13 | if ($currentProps->getNValue() === 1 && $currentProps->getAllowMult() === false) { 14 | echo "success!"; 15 | } else { 16 | var_dump($currentProps); 17 | } 18 | $bucket->setPropertyList($oldProps); 19 | ?> 20 | --EXPECT-- 21 | success! 22 | -------------------------------------------------------------------------------- /tests/bucket_props_ext.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bucket properties 3 | --FILE-- 4 | getPropertyList(); 11 | 12 | $newProps = new BucketPropertyList(); 13 | $postCommitHooks = new \Riak\Property\CommitHookList(); 14 | $postCommitHooks[] = new \Riak\Property\CommitHook('erl_module', 'erl_function'); 15 | $postCommitHooks[] = new \Riak\Property\CommitHook('js_name'); 16 | $newProps->setSearchEnabled(true) 17 | ->setR(1) 18 | ->setNValue(1) 19 | ->setW(1) 20 | ->setRW(1) 21 | ->setDW(1) 22 | ->setPostCommitHookList($postCommitHooks) 23 | ->setBigVClock(5000) 24 | ->setReplicationMode(new RM\FullSyncOnly()); 25 | 26 | $bucket->setPropertyList($newProps); 27 | $currentProps = $bucket->getPropertyList(); 28 | if ($currentProps->getNValue() === 1 && 29 | $currentProps->getAllowMult() === false && 30 | $currentProps->getSearchEnabled() === true && 31 | $currentProps->getR() === 1 && 32 | $currentProps->getW() === 1 && 33 | $currentProps->getDW() === 1 && 34 | $currentProps->getRW() === 1 && 35 | $currentProps->getBigVClock() === 5000) { 36 | $postHooks = $currentProps->getPostCommitHookList(); 37 | $foundJs = false; 38 | $foundErl = false; 39 | $replMode = $currentProps->getReplicationMode(); 40 | if (!is_a($replMode, 'Riak\Property\ReplicationMode\FullSyncOnly')) { 41 | var_dump($replMode); 42 | } 43 | foreach ($postHooks as $hook) { 44 | if ($hook->isJavascript() && $hook->getJsName() == "js_name") { 45 | $foundJs = true; 46 | } 47 | if ($hook->isErlang() && $hook->getErlModule() == "erl_module" && $hook->getErlFunction() == "erl_function") { 48 | $foundErl = true; 49 | } 50 | } 51 | if ($foundErl && $foundJs) { 52 | echo "success!"; 53 | } else { 54 | echo "could not verify hooks".PHP_EOL; 55 | var_dump($postHooks); 56 | } 57 | } else { 58 | var_dump($currentProps); 59 | } 60 | $bucket->setPropertyList($oldProps); 61 | ?> 62 | --EXPECT-- 63 | success! 64 | -------------------------------------------------------------------------------- /tests/builtin_conflict_resolver_db_objs.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test built-in conflict resolvers with real db fetch 3 | --FILE-- 4 | setAllowMult(true); 15 | $props->setLastWriteWins(false); 16 | 17 | $youngestResolver = new \Riak\Output\YoungestSiblingResolver(); 18 | $bucket->setConflictResolver($youngestResolver); 19 | 20 | // Put two objects on same key with no vclocks 21 | $object1 = new \Riak\Object('key_conflict'); 22 | $object1->setContent("content_1"); 23 | $object2 = new \Riak\Object('key_conflict'); 24 | $object2->setContent("content_2"); 25 | $bucket->put($object1); 26 | sleep(1); 27 | $bucket->put($object2); 28 | 29 | $getOutput = $bucket->get('key_conflict'); 30 | $winner = $getOutput->getObject(); 31 | echo "Resolve youngest : " . var_export($winner->getContent() == "content_2", true) . PHP_EOL; 32 | 33 | $bucket->delete($winner); 34 | ?> 35 | --EXPECT-- 36 | Resolve youngest : true 37 | -------------------------------------------------------------------------------- /tests/builtin_conflict_resolvers.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test built-in conflict resolvers 3 | --FILE-- 4 | resolve($list), true) . PHP_EOL; 19 | 20 | $list[] = $object1; 21 | $list[] = $object2; 22 | $list[] = $object3; 23 | 24 | echo "Is a resolver : " . var_export($youngestResolver instanceof ConflictResolver, true) . PHP_EOL; 25 | echo "Resolve youngest : " . var_export($youngestResolver->resolve($list) === $object1, true) . PHP_EOL; 26 | 27 | ?> 28 | --EXPECT-- 29 | Resolve empty : NULL 30 | Is a resolver : true 31 | Resolve youngest : true 32 | -------------------------------------------------------------------------------- /tests/client_ctor.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Basic riak connection 3 | --FILE-- 4 | ping(); 12 | 13 | echo "done!" .PHP_EOL; 14 | 15 | $riak2->ping(); 16 | 17 | echo "fail!" .PHP_EOL; 18 | 19 | } catch (ConnectionException $e) { 20 | echo $e->getMessage() . PHP_EOL; 21 | } 22 | ?> 23 | --EXPECT-- 24 | done! 25 | Connection error 26 | -------------------------------------------------------------------------------- /tests/conflict_resolver_bucket.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bucket conflict resolver 3 | --FILE-- 4 | first(); 16 | $value = 0; 17 | 18 | foreach ($objects as $object) { 19 | $value += intval($object->getContent()); 20 | } 21 | 22 | $winner->setContent($value); 23 | 24 | return $winner; 25 | } 26 | } 27 | 28 | $key = uniqid(); 29 | $resolver = new MyResolver(); 30 | $object1 = new \Riak\Object($key); 31 | $object2 = new \Riak\Object($key); 32 | $client = new \Riak\Connection($host, $port); 33 | $bucket = new \Riak\Bucket($client, 'test_bucket'); 34 | $props = new \Riak\BucketPropertyList($nVal = 1, $allowMult = true); 35 | 36 | $bucket->setPropertyList($props); 37 | $object1->setContent(1); 38 | $object2->setContent(2); 39 | $bucket->delete($key); 40 | 41 | $output = $bucket->get($key); 42 | $object = $output->getObject(); 43 | 44 | echo "Has object : " . var_export($output->hasObject(), true) . PHP_EOL; 45 | echo "Retrieve null : " . var_export($object, true) . PHP_EOL; 46 | 47 | $bucket->put($object1); 48 | 49 | $output = $bucket->get($key); 50 | $object = $output->getObject(); 51 | 52 | echo "Has Siblings : " . var_export($bucket->get($key)->hasSiblings(), true) . PHP_EOL; 53 | echo "Has object : " . var_export($bucket->get($key)->hasObject(), true) . PHP_EOL; 54 | echo "Unique count : " . count($bucket->get($key)->getObjectList()) . PHP_EOL; 55 | echo "Retrieve unique : " . var_export($object instanceof \Riak\Object, true) . PHP_EOL; 56 | 57 | $bucket->put($object2); 58 | $bucket->setConflictResolver($resolver); 59 | 60 | $output = $bucket->get($key); 61 | $object = $output->getObject(); 62 | // New put the winner back 63 | $bucket->put($object); 64 | 65 | echo "Has object : " . var_export($output->hasObject(), true) . PHP_EOL; 66 | echo "Siblings : " . count($output->getObjectList()) . PHP_EOL; 67 | echo "Get/Set Resolver : " . var_export($resolver === $bucket->getConflictResolver(), true) . PHP_EOL; 68 | echo "Winner value : " . $object->getContent() . PHP_EOL; 69 | echo "Has Siblings : " . var_export($bucket->get($key)->hasSiblings(), true) . PHP_EOL; 70 | echo "Read Winner : " . $bucket->get($key)->getFirstObject()->getContent() . PHP_EOL; 71 | 72 | $bucket->delete($key); 73 | 74 | ?> 75 | --EXPECT-- 76 | Has object : false 77 | Retrieve null : NULL 78 | Has Siblings : false 79 | Has object : true 80 | Unique count : 1 81 | Retrieve unique : true 82 | Has object : true 83 | Siblings : 2 84 | Get/Set Resolver : true 85 | Winner value : 3 86 | Has Siblings : false 87 | Read Winner : 3 88 | -------------------------------------------------------------------------------- /tests/conflict_resolver_exception.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test conflict resolver exceptions 3 | --FILE-- 4 | return = $return; 18 | } 19 | 20 | public function resolve(ObjectList $objects) 21 | { 22 | return $this->return; 23 | } 24 | } 25 | 26 | $key = uniqid(); 27 | $resolver = new DummyResolver(); 28 | $object1 = new \Riak\Object($key); 29 | $object2 = new \Riak\Object($key); 30 | $client = new \Riak\Connection($host, $port); 31 | $props = new \Riak\BucketPropertyList($nVal = 1, $allowMult = true); 32 | $bucket = new \Riak\Bucket($client, 'test_bucket'); 33 | 34 | $bucket->setPropertyList($props); 35 | $object1->setContent(1); 36 | $object2->setContent(2); 37 | 38 | $bucket->put($object1); 39 | $bucket->put($object2); 40 | 41 | try { 42 | $output = $bucket->get($key); 43 | $object = $output->getObject(); 44 | } catch (Exception $e) { 45 | echo get_class($e) . ' : ' . $e->getMessage() . PHP_EOL; 46 | } 47 | 48 | 49 | $bucket->setConflictResolver($resolver); 50 | 51 | try { 52 | $resolver->return = new \Riak\Object(); 53 | 54 | $output = $bucket->get($key); 55 | $object = $output->getObject(); 56 | } catch (Exception $e) { 57 | echo get_class($e) . ' : ' . $e->getMessage() . PHP_EOL; 58 | } 59 | 60 | try { 61 | $resolver->return = new \stdClass(); 62 | 63 | $output = $bucket->get($key); 64 | $object = $output->getObject(); 65 | } catch (Exception $e) { 66 | echo get_class($e) . ' : ' . $e->getMessage() . PHP_EOL; 67 | } 68 | 69 | try { 70 | $resolver->return = 0; 71 | 72 | $output = $bucket->get($key); 73 | $object = $output->getObject(); 74 | } catch (Exception $e) { 75 | echo get_class($e) . ' : ' . $e->getMessage() . PHP_EOL; 76 | } 77 | 78 | try { 79 | $resolver->return = null; 80 | 81 | $output = $bucket->get($key); 82 | $object = $output->getObject(); 83 | } catch (Exception $e) { 84 | echo get_class($e) . ' : ' . $e->getMessage() . PHP_EOL; 85 | } 86 | 87 | $bucket->delete($key); 88 | 89 | ?> 90 | --EXPECT-- 91 | Riak\Exception\NonUniqueException : GetOutput contains unresolved siblings 92 | Riak\Exception\UnresolvedConflictException : The resolved Riak\Object does not contain a valid key. 93 | Riak\Exception\UnresolvedConflictException : Conflict resolver should return a instance of Riak\Object 94 | Riak\Exception\UnresolvedConflictException : Conflict resolver should return a instance of Riak\Object 95 | Riak\Exception\UnresolvedConflictException : Conflict resolver should return a instance of Riak\Object 96 | -------------------------------------------------------------------------------- /tests/conflict_resolver_key.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test key conflict resolver 3 | --FILE-- 4 | first(); 16 | $value = 0; 17 | 18 | foreach ($objects as $object) { 19 | $value += intval($object->getContent()); 20 | } 21 | 22 | $winner->setContent($value); 23 | 24 | return $winner; 25 | } 26 | } 27 | 28 | $key = uniqid(); 29 | $resolver = new MyGetResolver(); 30 | $object1 = new \Riak\Object($key); 31 | $object2 = new \Riak\Object($key); 32 | $client = new \Riak\Connection($host, $port); 33 | $bucket = new \Riak\Bucket($client, 'test_bucket'); 34 | $options = new \Riak\Input\GetResolverInput($resolver); 35 | $props = new \Riak\BucketPropertyList($nVal = 1, $allowMult = true); 36 | 37 | $bucket->setPropertyList($props); 38 | $bucket->delete($key); 39 | 40 | $object1->setContent(1); 41 | $object2->setContent(2); 42 | 43 | $bucket->put($object1); 44 | $bucket->put($object2); 45 | 46 | $output = $bucket->get($key, $options); 47 | $object = $output->getObject(); 48 | // New put the winner back 49 | $bucket->put($object); 50 | 51 | echo "Has object : " . var_export($output->hasObject(), true) . PHP_EOL; 52 | echo "Siblings : " . count($output->getObjectList()) . PHP_EOL; 53 | echo "Get/Set Resolver : " . var_export($resolver === $options->getConflictResolver(), true) . PHP_EOL; 54 | echo "Winner value : " . $object->getContent() . PHP_EOL; 55 | echo "Has Siblings : " . var_export($bucket->get($key)->hasSiblings(), true) . PHP_EOL; 56 | echo "Read Winner : " . $bucket->get($key)->getFirstObject()->getContent() . PHP_EOL; 57 | 58 | $bucket->delete($key); 59 | 60 | ?> 61 | --EXPECT-- 62 | Has object : true 63 | Siblings : 2 64 | Get/Set Resolver : true 65 | Winner value : 3 66 | Has Siblings : false 67 | Read Winner : 3 68 | -------------------------------------------------------------------------------- /tests/conflict_resolver_precedence.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test conflict resolver precedence 3 | --FILE-- 4 | first(); 18 | $value = 0; 19 | 20 | foreach ($objects as $object) { 21 | $value += intval($object->getContent()); 22 | } 23 | 24 | $winner->setContent($value); 25 | 26 | return $winner; 27 | } 28 | } 29 | 30 | class MyKeyResolver implements ConflictResolver 31 | { 32 | public function resolve(ObjectList $objects) 33 | { 34 | echo __CLASS__ . PHP_EOL; 35 | 36 | $winner = $objects->first(); 37 | $value = 0; 38 | 39 | foreach ($objects as $object) { 40 | $value += intval($object->getContent()); 41 | } 42 | 43 | $winner->setContent($value); 44 | 45 | return $winner; 46 | } 47 | } 48 | 49 | $key = uniqid(); 50 | $keyResolver = new MyKeyResolver(); 51 | $buketResolver = new MyBuketResolver(); 52 | $object1 = new \Riak\Object($key); 53 | $object2 = new \Riak\Object($key); 54 | $client = new \Riak\Connection($host, $port); 55 | $bucket = new \Riak\Bucket($client, 'test_bucket'); 56 | $options = new \Riak\Input\GetResolverInput($keyResolver); 57 | $props = new \Riak\BucketPropertyList($nVal = 1, $allowMult = true); 58 | 59 | $bucket->delete($key); 60 | $bucket->setPropertyList($props); 61 | $bucket->setConflictResolver($buketResolver); 62 | 63 | $object1->setContent(1); 64 | $object2->setContent(2); 65 | 66 | $bucket->put($object1); 67 | $bucket->put($object2); 68 | 69 | $output = $bucket->get($key, $options); 70 | $object = $output->getObject(); 71 | // New put the winner back 72 | $bucket->put($object); 73 | 74 | echo "Siblings : " . count($output->getObjectList()) . PHP_EOL; 75 | echo "Read Winner : " . $bucket->get($key)->getFirstObject()->getContent() . PHP_EOL; 76 | echo "Has Siblings : " . var_export($bucket->get($key)->hasSiblings(), true) . PHP_EOL; 77 | 78 | $bucket->delete($key); 79 | 80 | ?> 81 | --EXPECT-- 82 | MyKeyResolver 83 | Siblings : 2 84 | Read Winner : 3 85 | Has Siblings : false 86 | -------------------------------------------------------------------------------- /tests/connect.inc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/connection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Riak\Connection 3 | --FILE-- 4 | getHost(), $host) !== 0) { 9 | echo "host differs".PHP_EOL; 10 | var_dump($connection); 11 | } 12 | // Get port 13 | if ($connection->getPort() !== $port) { 14 | echo "port differs".PHP_EOL; 15 | var_dump($connection); 16 | } 17 | $b1_a = $connection->getBucket("bucket1"); 18 | $b2 = $connection->getBucket("bucket2"); 19 | $b1_b = $connection->getBucket("bucket1"); 20 | if ($b1_a != $b1_b) { 21 | echo "1a:".PHP_EOL; 22 | var_dump($b1_a); 23 | echo "1b:".PHP_EOL; 24 | var_dump($b1_b); 25 | } 26 | echo "done!".PHP_EOL; 27 | ?> 28 | --EXPECT-- 29 | done! 30 | -------------------------------------------------------------------------------- /tests/connection_lazy.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Lazy Riak\Connection 3 | --FILE-- 4 | initializer = $initializer; 20 | } 21 | 22 | public function setValueHolder($valueHolder) 23 | { 24 | $this->valueHolder = $valueHolder; 25 | } 26 | 27 | public function getBucket($name) 28 | { 29 | $this->initializer->__invoke($this->valueHolder); 30 | 31 | return $this->valueHolder->getBucket($name); 32 | } 33 | 34 | public function getHost() 35 | { 36 | $this->initializer->__invoke($this->valueHolder); 37 | 38 | return $this->valueHolder->getHost(); 39 | } 40 | 41 | public function getPort() 42 | { 43 | $this->initializer->__invoke($this->valueHolder); 44 | 45 | return $this->valueHolder->getPort(); 46 | } 47 | } 48 | 49 | class RiakBucketProxy extends Bucket 50 | { 51 | private $valueHolder = null; 52 | 53 | private $initializer = null; 54 | 55 | public function __construct(\Closure $initializer) 56 | { 57 | $this->initializer = $initializer; 58 | } 59 | 60 | public function setValueHolder($valueHolder) 61 | { 62 | $this->valueHolder = $valueHolder; 63 | } 64 | 65 | public function setPropertyList($bucketPropertyList) 66 | { 67 | $this->initializer->__invoke($this->valueHolder); 68 | 69 | return $this->valueHolder->setPropertyList($bucketPropertyList); 70 | } 71 | 72 | public function getPropertyList() 73 | { 74 | $this->initializer->__invoke($this->valueHolder); 75 | 76 | return $this->valueHolder->getPropertyList(); 77 | } 78 | 79 | public function getConnection() 80 | { 81 | $this->initializer->__invoke($this->valueHolder); 82 | 83 | return $this->valueHolder->getConnection(); 84 | } 85 | 86 | public function getKeyList() 87 | { 88 | $this->initializer->__invoke($this->valueHolder); 89 | 90 | return $this->valueHolder->getKeyList(); 91 | } 92 | } 93 | 94 | $connectionInitializer = function(&$valueHolder) use ($host, $port) { 95 | $valueHolder = $valueHolder ?: new Connection($host, $port); 96 | }; 97 | 98 | $bucketInitializer = function(&$valueHolder) use ($connectionInitializer) { 99 | $valueHolder = $valueHolder ?: new \Riak\Bucket(new RiakConnectionProxy($connectionInitializer), "test_bucket"); 100 | }; 101 | 102 | $bucket = new RiakBucketProxy($bucketInitializer); 103 | $propList = new BucketPropertyList(1, false); 104 | 105 | $bucket->setPropertyList($propList); 106 | 107 | printf("bucket property : %s\n", json_encode($bucket->getPropertyList() instanceof BucketPropertyList)); 108 | printf("bucket keys : %s\n", json_encode(is_array($bucket->getKeyList()))); 109 | ?> 110 | --EXPECT-- 111 | bucket property : true 112 | bucket keys : true 113 | -------------------------------------------------------------------------------- /tests/crdt_counter.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Riak\Crdt\Counter 3 | --FILE-- 4 | setPropertyList($newProps); 10 | 11 | $counter1 = $bucket->counter("cnt1"); 12 | $counter2 = new \Riak\Crdt\Counter($bucket, "cnt2"); 13 | 14 | 15 | $getInput = new \Riak\Crdt\Input\GetInput(); 16 | $getInput->setR(1); 17 | $getInput->setPR(1); 18 | $getInput->setBasicQuorum(true); 19 | $getInput->setNotFoundOk(false); 20 | 21 | $updateInput = new \Riak\Crdt\Input\UpdateInput(); 22 | $updateInput->setW(1); 23 | $updateInput->setDW(1); 24 | $updateInput->setPW(1); 25 | 26 | $start1 = $counter1->get(); 27 | $start2 = $counter2->get($getInput); 28 | $read1 = $counter1->incrementAndGet(1); 29 | if ($start1+1 != $read1) { 30 | echo "Inc1 a failed".PHP_EOL; 31 | } 32 | $read1 = $counter1->incrementAndGet(1, $updateInput); 33 | if ($start1+2 != $read1) { 34 | echo "Inc1 b failed".PHP_EOL; 35 | } 36 | 37 | $counter2->increment(-1); 38 | $read2 = $counter2->get($getInput); 39 | if ($start2 - 1 != $read2) { 40 | echo "Inc2 a failed".PHP_EOL; 41 | } 42 | 43 | $counter2->increment(-1, $updateInput); 44 | $read2 = $counter2->get($getInput); 45 | if ($start2 - 2 != $read2) { 46 | echo "Inc2 b failed".PHP_EOL; 47 | } 48 | echo "done!".PHP_EOL; 49 | --EXPECT-- 50 | done! 51 | -------------------------------------------------------------------------------- /tests/delete_badarguments.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bucket delete using bad arguments 3 | --FILE-- 4 | setContent("foo"); 15 | 16 | $bucket->put($obj); 17 | 18 | try { 19 | $bucket->delete(new \Riak\Object()); 20 | } catch (Exception $e) { 21 | echo get_class($e) . ' : ' .$e->getMessage() . PHP_EOL; 22 | } 23 | 24 | try { 25 | $bucket->delete(new stdClass()); 26 | } catch (Exception $e) { 27 | echo get_class($e) . ' : ' .$e->getMessage() . PHP_EOL; 28 | } 29 | 30 | $bucket->delete($key); 31 | 32 | echo var_export($bucket->get($key)->hasObject()) . PHP_EOL; 33 | 34 | ?> 35 | --EXPECT-- 36 | Riak\Exception\BadArgumentsException : Unable to resolve the object key. 37 | Riak\Exception\BadArgumentsException : Argument 1 passed to Riak\Bucket#delete() must be a string or an instance of Riak\Object. 38 | false 39 | -------------------------------------------------------------------------------- /tests/get1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Simple get test 3 | --FILE-- 4 | setPropertyList($props); 12 | 13 | try { 14 | $obj = new \Riak\Object("get_head"); 15 | $obj->setContent("test-get plap"); 16 | $bucket->put($obj); 17 | $cfg = new GetInput(); 18 | $cfg->setReturnHead(true); 19 | $output = $bucket->get("get_head", $cfg); 20 | if (!$output->hasObject()) { 21 | echo "Output did not contain an object".PHP_EOL; 22 | var_dump($output); 23 | } 24 | $obj = $output->getFirstObject(); 25 | if (!is_null($obj->getContent()) && strlen($obj->getContent() > 0)) { 26 | echo "Did not expect returned object to have data, when return_head is set".PHP_EOL; 27 | var_dump($obj); 28 | } 29 | $obj = new \Riak\Object("get_test"); 30 | $obj->setContentType("text/plain"); 31 | $obj->setContent("test-get plap"); 32 | $obj->addMetadata("test", "test"); 33 | $bucket->put($obj); 34 | $output = $bucket->get("get_test"); 35 | if ($output->hasSiblings()) { 36 | echo "Did not expect siblings".PHP_EOL; 37 | var_dump($output); 38 | } 39 | $readdenObj = $output->getFirstObject(); 40 | $meta = $readdenObj->getMetadataMap(); 41 | if (strcmp($readdenObj->getContent(), $obj->getContent()) == 0 || strcmp($meta["test"], "test") !== 0 ) { 42 | echo "success!"; 43 | } 44 | } catch (Exception $e) { 45 | var_dump($e); 46 | } 47 | ?> 48 | --EXPECT-- 49 | success! 50 | -------------------------------------------------------------------------------- /tests/index_output.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test index output 3 | --FILE-- 4 | 17 | --EXPECT-- 18 | done! 19 | -------------------------------------------------------------------------------- /tests/index_perform.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test basic index queries 3 | --FILE-- 4 | setPropertyList($props); 11 | 12 | try { 13 | for ($i=0; $i<10; $i++) { 14 | $obj = new \Riak\Object("obj$i"); 15 | $obj->setContent("test-idx"); 16 | $obj->addIndex("tal_int", $i)->addIndex("tekst_bin", "text$i"); 17 | $bucket->put($obj); 18 | } 19 | $result = $bucket->index("tal_int", 1); 20 | if ($result[0] !== "obj1") { 21 | var_dump($result); 22 | } 23 | $result = $bucket->index("tekst_bin", "text4", "text6"); 24 | if (count($result) !== 3 || 25 | !in_array("obj4", $result) || 26 | !in_array("obj5", $result) || 27 | !in_array("obj6", $result)) { 28 | var_dump($result); 29 | } 30 | $props = NULL; 31 | $bucket = NULL; 32 | $result = NULL; 33 | echo "done!"; 34 | } catch (Exception $e) { 35 | var_dump($e); 36 | } 37 | ?> 38 | --EXPECT-- 39 | done! 40 | -------------------------------------------------------------------------------- /tests/index_perform_arr.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test index with multiple values 3 | --FILE-- 4 | setPropertyList($props); 11 | try { 12 | $obj = new \Riak\Object("obj"); 13 | $obj->setContent("test-idx"); 14 | $obj->addIndex("tal_int", 0)->addIndex("tekst_bin", "text0") 15 | ->addIndex("tal_int", 1)->addIndex("tekst_bin", "text1") 16 | ->addIndex("tal_int", 2)->addIndex("tekst_bin", "text3") 17 | ->addIndex("tal_int", 3)->addIndex("tekst_bin", "text4"); 18 | $in = $obj->getIndexMap("tal_int"); 19 | $bucket->put($obj); 20 | $getOutput = $bucket->get("obj"); 21 | $getObj = $getOutput->getObject(); 22 | $out = $obj->getIndexMap("tal_int"); 23 | if ($in !== $out) { 24 | echo "Different 1".PHP_EOL; 25 | var_dump($in); 26 | var_dump($out); 27 | } 28 | $bucket->put($getObj); 29 | $getOutput = $bucket->get("obj"); 30 | $getObj = $getOutput->getObject(); 31 | $out2 = $obj->getIndexMap("tal_int"); 32 | if ($in !== $out2) { 33 | echo "Different 2".PHP_EOL; 34 | var_dump($in); 35 | var_dump($out2); 36 | } 37 | echo "done!"; 38 | } catch (Exception $e) { 39 | var_dump($e); 40 | } 41 | ?> 42 | --EXPECT-- 43 | done! 44 | -------------------------------------------------------------------------------- /tests/index_query.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test index query 3 | --FILE-- 4 | isRangeQuery() == true) { 8 | echo "Should not be ranged query at this time".PHP_EOL; 9 | } 10 | $q->setRangeValue("min", "max"); 11 | if ($q->isRangeQuery() != true) { 12 | echo "Should be ranged query now".PHP_EOL; 13 | } 14 | $rv = $q->getRangeValue(); 15 | if ($rv[0] !== "min" || $rv[1] !== "max") { 16 | echo "Rangedvalues does not match".PHP_EOL; 17 | } 18 | $q->setExactValue("exact"); 19 | if ($q->isRangeQuery() == true) { 20 | echo "Should not be ranged query now".PHP_EOL; 21 | } 22 | echo "done!".PHP_EOL; 23 | ?> 24 | --EXPECT-- 25 | done! 26 | -------------------------------------------------------------------------------- /tests/index_query_ext.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test extended index querying 3 | --FILE-- 4 | setContent("test-idx"); 13 | $obj->addIndex("tal_int", $i)->addIndex("tekst_bin", "text$i"); 14 | $bucket->put($obj); 15 | } 16 | 17 | $q = new IndexQuery("tal_int"); 18 | $q->setExactValue(1); 19 | $result = $bucket->indexQuery($q); 20 | $resultList = $result->getResultList(); 21 | if ($resultList[0]->getKey() !== "obj1") { 22 | echo "exact failed".PHP_EOL; 23 | var_dump($result); 24 | } 25 | 26 | $q->setRangeValue(1, 8); 27 | $input = new \Riak\Input\IndexInput(); 28 | $input->setMaxResults(4); 29 | $result = $bucket->indexQuery($q, $input); 30 | $resultList = $result->getResultList(); 31 | if ($resultList[0]->getKey() !== "obj1") { 32 | echo "ranged failed".PHP_EOL; 33 | var_dump($result); 34 | } 35 | $cont = $result->getContinuation(); 36 | $input->setContinuation($cont); 37 | $input->setMaxResults(10); 38 | $result = $bucket->indexQuery($q, $input); 39 | $resultList = $result->getResultList(); 40 | if ($resultList[0]->getKey() !== "obj5") { 41 | echo "continuation failed ".$cont.PHP_EOL; 42 | var_dump($result); 43 | } 44 | 45 | echo "done!".PHP_EOL; 46 | ?> 47 | --EXPECT-- 48 | done! 49 | -------------------------------------------------------------------------------- /tests/key_not_found.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test key not found result in GetOutput with no objects 3 | --FILE-- 4 | get("Long_key_that_should_never_exists_hopefully"); 11 | if ($readdenObj->hasObject()) { 12 | echo "fail!".PHP_EOL; 13 | } 14 | if (count($readdenObj->getObjectList()) > 0) { 15 | echo "fail2!".PHP_EOL; 16 | } 17 | } catch (Exception $e) { 18 | var_dump($e); 19 | } 20 | echo "done!".PHP_EOL; 21 | ?> 22 | --EXPECT-- 23 | done! 24 | -------------------------------------------------------------------------------- /tests/links.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test links gets written and read correctly 3 | --FILE-- 4 | setPropertyList($props); 14 | 15 | $obj = new Object("key1"); 16 | try { 17 | for ($i=0; $i<10; $i++) { 18 | $obj2 = new Object("key_with_link_$i"); 19 | $bucket->put($obj2); 20 | // add link to obj 21 | $obj->addLink(new Link("link$i", "test_bucket", $obj2->getKey())); 22 | } 23 | $bucket->put($obj); 24 | 25 | $output = $bucket->get("key1"); 26 | $objs = $output->getObjectList(); 27 | $readdenObj = $objs[0]; 28 | $success = true; 29 | $readdenLinks = $readdenObj->getLinkList(); 30 | if (count($readdenLinks) == 10) { 31 | $i = 0; 32 | foreach ($readdenLinks as $link) { 33 | if (strcmp($link->getTag(), "link$i") !== 0) { 34 | $success = false; 35 | echo "expected tag name to be 'link$i' but was '".$link->tag."'".PHP_EOL; 36 | } 37 | if (strcmp($link->getBucketName(), 'test_bucket') !== 0) { 38 | $success = false; 39 | echo "expected bucket name to be 'test_bucket' but was '".$link->bucket."'".PHP_EOL; 40 | } 41 | if (strcmp($link->getKey(), "key_with_link_$i") !== 0) { 42 | $success = false; 43 | echo "expected key name to be 'key_with_link_$i' but was '".$link->key."'".PHP_EOL; 44 | } 45 | $i++; 46 | } 47 | } else { 48 | $success = false; 49 | var_dump($readdenLinks); 50 | } 51 | if ($success) { 52 | echo "success!"; 53 | } 54 | } catch (Exception $e) { 55 | var_dump($e); 56 | } 57 | ?> 58 | --EXPECT-- 59 | success! 60 | -------------------------------------------------------------------------------- /tests/list_keys.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bucket list keys 3 | --FILE-- 4 | setPropertyList($props); 12 | try { 13 | // Make some objects we can list afterwards 14 | for ($i=0; $i<20; $i++) { 15 | $obj = new Object("list$i"); 16 | $obj->setContent("test-get plap"); 17 | $bucket->put($obj); 18 | } 19 | $keys = $bucket->getKeyList(); 20 | $foundcnt = 0; 21 | foreach ($keys as $key) { 22 | $keystart = substr($key, 0, 4); 23 | if (strcmp($keystart, "list") == 0) { 24 | $foundcnt++; 25 | } 26 | } 27 | if ($foundcnt == 20) { 28 | echo "success!".PHP_EOL; 29 | } else { 30 | var_dump($keys); 31 | } 32 | for ($i=0; $i<20; $i++) { 33 | $bucket->delete("list$i"); 34 | } 35 | } catch (Exception $e) { 36 | var_dump($e); 37 | } 38 | ?> 39 | --EXPECT-- 40 | success! 41 | -------------------------------------------------------------------------------- /tests/mapreduce.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test mapreduce 3 | --FILE-- 4 | setContent($alice1); 36 | $alicebucket->put($obj1); 37 | 38 | $obj2 = new Object("alice2"); 39 | $obj2->setContent($alice2); 40 | $alicebucket->put($obj2); 41 | 42 | $obj3 = new Object("alice3"); 43 | $obj3->setContent($alice3); 44 | $alicebucket->put($obj3); 45 | 46 | $mrinput = new KeyListInput(array("test_alice" => array("alice1", $obj2, $obj3))); 47 | 48 | $jsmapfunc = JavascriptFunction::anon("function(v) {". 49 | "var m = v.values[0].data.toLowerCase().match(/\w*/g);". 50 | "var r = [];". 51 | "for(var i in m) {". 52 | " if(m[i] != '') {". 53 | " var o = {};". 54 | " o[m[i]] = 1;". 55 | " r.push(o);". 56 | " }". 57 | "}". 58 | "return r;". 59 | "}"); 60 | 61 | $jsredfunc = JavascriptFunction::anon("function(v) {". 62 | "var r = {};". 63 | "for(var i in v) {". 64 | " for(var w in v[i]) {". 65 | " if(w in r) r[w] += v[i][w];". 66 | " else r[w] = v[i][w];". 67 | " }". 68 | "}". 69 | "return [r];". 70 | "}"); 71 | 72 | $mr = new MapReduce($client); 73 | $mr ->addPhase(new MapPhase($jsmapfunc)) 74 | ->addPhase(new ReducePhase($jsredfunc)) 75 | ->setInput($mrinput); 76 | $json = $mr->toJson(); 77 | $result = $mr->run(); 78 | $res0val = $result[0]->getValue(); 79 | if ($res0val[0]["the"] !== 8) { 80 | var_dump($result); 81 | } 82 | 83 | global $streamedsomething; 84 | $streamedsomething = false; 85 | // Now do the same but stream it 86 | class MrStream implements \Riak\MapReduce\Output\StreamOutput { 87 | public function receive($response) { 88 | global $streamedsomething; 89 | $streamedsomething = true; 90 | } 91 | }; 92 | $mr->run(new MrStream()); 93 | if ($streamedsomething) { 94 | echo "success!".PHP_EOL; 95 | } 96 | } catch (Exception $e) { 97 | echo $e->getMessage(); 98 | } 99 | ?> 100 | --EXPECT-- 101 | success! 102 | -------------------------------------------------------------------------------- /tests/metadata.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test metadata gets read and written 3 | --FILE-- 4 | setPropertyList($props); 12 | 13 | $obj = new Object("get_test"); 14 | try { 15 | $obj->setContent("test-get plap") 16 | ->addMetadata("ost", 7); 17 | $bucket->put($obj); 18 | 19 | $output = $bucket->get("get_test"); 20 | $objs = $output->getObjectList(); 21 | $obj0 = $objs[0]; 22 | $meta0 = $obj0->getMetadataMap(); 23 | if (isset($meta0["ost"]) && $meta0["ost"] == 7) { 24 | echo "success!"; 25 | } else { 26 | var_dump($meta0); 27 | } 28 | } catch (Exception $e) { 29 | var_dump($e); 30 | } 31 | ?> 32 | --EXPECT-- 33 | success! 34 | -------------------------------------------------------------------------------- /tests/mrfunctions.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test map reduce function objects 3 | --FILE-- 4 | toArray(); 13 | if ($jsanonarr["language"] !== "javascript" || $jsanonarr["source"] !== "anon_source") { 14 | var_dump($jsanonarr); 15 | } 16 | $jsnamedarr = $jsnamed->toArray(); 17 | if ($jsnamedarr["language"] !== "javascript" || $jsnamedarr["name"] !== "named_source") { 18 | var_dump($jsanonarr); 19 | } 20 | 21 | $erl1 = new ErlangFunction("module", "function"); 22 | 23 | $erlnarr = $erl1->toArray(); 24 | if ($erlnarr["module"] !== "module" || $erlnarr["function"] !== "function") { 25 | var_dump($erlanonarr); 26 | } 27 | echo "done!"; 28 | ?> 29 | --EXPECT-- 30 | done! 31 | -------------------------------------------------------------------------------- /tests/mrinputs.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test map reduce input objects 3 | --FILE-- 4 | getValue(); 15 | $val = $buckeetInput1->getValue(); 16 | if ($val !== "bucket_name") { 17 | var_dump($buckeetInput1); 18 | } 19 | 20 | $buckeetInput2 = new BucketInput("bucket_name2"); 21 | $buckeetInput2->setIndexFilter("test_bin", "s", "e"); 22 | $val = $buckeetInput2->getValue(); 23 | if ($val["bucket"] !== "bucket_name2" || $val["index"] !== "test_bin" || $val["start"] != "s" || $val["end"] !== "e") { 24 | var_dump($val); 25 | } 26 | 27 | $obj = new Object("object_key"); 28 | $obj2 = new Object("object_key2"); 29 | $obj3 = new Object("object_key3"); 30 | 31 | $keyDataList = new KeyDataListInput(); 32 | $keyDataList->add("bucket","key1","data") 33 | ->add("bucket","key2","data") 34 | ->add("bucket","key3","data"); 35 | $val = $keyDataList->getValue(); 36 | if (count($val) !== 3) { 37 | var_dump($val); 38 | } 39 | 40 | $listInput = new KeyListInput(array("bucket1" => array("key1", "key2", "key3"))); 41 | $listInput ->addArray(array("bucket1" => array("key4", "key5"))) 42 | ->addArray(array("bucket2" => array("0", "asdf"))) 43 | ->addArray(array("bucket3" => $obj)) 44 | ->addArray(array("bucket4" => array($obj2, $obj3))) 45 | ->addSingle("bucket5", "ost") 46 | ->addSingle("bucket6", "ost2") 47 | ->addSingle("bucket7", $obj) 48 | ->addSingle($bucket, $obj2); 49 | 50 | $val = $listInput->getValue(); 51 | 52 | if (count($val) !== 14) { 53 | var_dump($val); 54 | } 55 | echo "done!"; 56 | ?> 57 | --EXPECT-- 58 | done! 59 | -------------------------------------------------------------------------------- /tests/mrkeyfilters.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test key filters 3 | --FILE-- 4 | setPropertyList($newProps); 17 | 18 | // Make 20 keys for testing 19 | for ($i=0; $i<20; $i++) { 20 | if ($i<10) { 21 | $obj = new Object("key_0$i"); 22 | } else { 23 | $obj = new Object("key_$i"); 24 | } 25 | $obj->setContent("dummy"); 26 | $bucket->put($obj); 27 | } 28 | $function1 = new ErlangFunction("riak_kv_mapreduce","map_object_value"); 29 | $input = new BucketInput("test_keyfilters"); 30 | $input->keyFilters = array( array("tokenize", "_", 2), array("between", "05", "15") ); 31 | 32 | $mr = new MapReduce($client); 33 | $mr ->addPhase(new MapPhase($function1)) 34 | ->setInput($input); 35 | $mrres = $mr->run(); 36 | 37 | // Should return 11 objects since we fetch 05-15 both inclusive 38 | $rescnt = 0; 39 | foreach ($mrres as $resp) { 40 | $rescnt += count($resp->getValue()); 41 | } 42 | if ($rescnt !== 11) { 43 | var_dump($result); 44 | } else { 45 | echo "success!"; 46 | } 47 | ?> 48 | --EXPECT-- 49 | success! 50 | -------------------------------------------------------------------------------- /tests/mrphase.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test map reduce phase object 3 | --FILE-- 4 | toArray(); 14 | $subarr1 = $arr1['map']; 15 | if ($subarr1["language"] !== "javascript" || $subarr1["name"] !== "source_name") { 16 | echo "map".PHP_EOL; 17 | var_dump($arr1); 18 | } 19 | $phase2 = new ReducePhase($jsnamed, true, array("plappe"=>"pluppe")); 20 | $arr2 = $phase2->toArray(); 21 | $subarr2 = $arr2['reduce']; 22 | $subarr2arg = $arr2['arg']; 23 | if ($subarr2["keep"] !== true || $subarr2arg["plappe"] !== "pluppe" || $subarr1["language"] !== "javascript" || $subarr1["name"] !== "source_name") { 24 | echo "reduce".PHP_EOL; 25 | var_dump($arr2); 26 | } 27 | echo "done!"; 28 | ?> 29 | --EXPECT-- 30 | done! 31 | -------------------------------------------------------------------------------- /tests/numeric_key.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Segmentation fault with numeric key 3 | --FILE-- 4 | delete($key) === null, true) . PHP_EOL; 21 | echo "Has object : " . var_export($bucket->get($key)->hasObject(), true) . PHP_EOL; 22 | } 23 | 24 | $object1 = new Object(); 25 | $object2 = new Object(); 26 | 27 | $object1->setKey('9999'); 28 | $object1->setContent('test 9999'); 29 | 30 | $object2->setKey('99.99'); 31 | $object2->setContent('test 99.99'); 32 | 33 | $bucket->put($object1); 34 | $bucket->put($object2); 35 | 36 | testRiakKey($bucket, 9999); 37 | testRiakKey($bucket, 99.99); 38 | 39 | try { 40 | testRiakKey($bucket, array(9999)); 41 | } catch (\Exception $e) { 42 | echo $e->getMessage() . PHP_EOL; 43 | } 44 | 45 | try { 46 | testRiakKey($bucket, new \ArrayObject(array(99.99))); 47 | } catch (\Exception $e) { 48 | echo $e->getMessage() . PHP_EOL; 49 | } 50 | 51 | 52 | ?> 53 | --EXPECT-- 54 | 55 | Using key : integer 56 | Delete object : true 57 | Has object : false 58 | 59 | Using key : double 60 | Delete object : true 61 | Has object : false 62 | 63 | Using key : array 64 | Argument 1 passed to Riak\Bucket#delete() must be a string or an instance of Riak\Object. 65 | 66 | Using key : object 67 | Argument 1 passed to Riak\Bucket#delete() must be a string or an instance of Riak\Object. 68 | -------------------------------------------------------------------------------- /tests/object_list.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Riak\Output\ObjectList works 3 | --FILE-- 4 | isEmpty()) { 9 | echo "List is supposed to be empty!".PHP_EOL; 10 | } 11 | if (!is_null($objList->first())) { 12 | echo "When list is empty null should be returned as first!".PHP_EOL; 13 | } 14 | $objList[] = $obj1; 15 | $objList["2"] = $obj2; 16 | 17 | if ($objList->count() !== 2) { 18 | echo "Count should be 2".PHP_EOL; 19 | } 20 | 21 | if (!$objList->offsetExists("2")) { 22 | echo "2 should exist in list".PHP_EOL; 23 | } 24 | 25 | if ($objList->first()->getKey() !== $obj1->getKey()) { 26 | echo "Keys key should be equal".PHP_EOL; 27 | } 28 | 29 | if ($objList->last()->getKey() !== $obj2->getKey()) { 30 | echo "Last key should be equal".PHP_EOL; 31 | } 32 | 33 | if ($objList->first() !== $obj1) { 34 | echo "First object fail".PHP_EOL; 35 | } 36 | 37 | if ($objList->last() !== $obj2) { 38 | echo "Last object fail".PHP_EOL; 39 | } 40 | 41 | $objList2 = new \Riak\ObjectList(); 42 | $objList2["plappe"] = $obj2; 43 | if ($objList2->isEmpty()) { 44 | echo "List2 is not supposed to be empty".PHP_EOL; 45 | } 46 | if ($objList2->first()->getKey() !== $obj2->getKey()) { 47 | echo "List2 keys should equal".PHP_EOL; 48 | } 49 | 50 | ////// 51 | // Try inserting a non riak object 52 | try { 53 | $objList2["fail"] = 3; 54 | } catch (\Riak\Exception\BadArgumentsException $e) { 55 | echo "done!".PHP_EOL; 56 | } 57 | ?> 58 | --EXPECTF-- 59 | Warning: Riak\ObjectList::offsetSet() expects parameter 2 to be Riak\Object, integer given in %s 60 | done! 61 | -------------------------------------------------------------------------------- /tests/ping.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Simple ping test 3 | --FILE-- 4 | ping(); 12 | echo "success!"; 13 | } catch (\Riak\ConnectionException $e) { 14 | echo "Connection error!".PHP_EOL; 15 | } catch (RiakCommunicationException $e1) { 16 | echo "Communication error!".PHP_EOL; 17 | } 18 | ?> 19 | --EXPECT-- 20 | connected! 21 | success! -------------------------------------------------------------------------------- /tests/pool.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test connection pool accepts limits 3 | --INI-- 4 | riak.persistent.connections=20 5 | riak.persistent.timeout=2000 6 | --FILE-- 7 | ping(); 22 | } 23 | 24 | echo 'active connection : ' . PoolInfo::getNumActiveConnection().PHP_EOL; 25 | echo 'persistent connection : ' . PoolInfo::getNumActivePersistentConnection().PHP_EOL; 26 | 27 | $clients = NULL; 28 | 29 | echo 'active connection : ' . PoolInfo::getNumActiveConnection().PHP_EOL; 30 | echo 'persistent connection : ' . PoolInfo::getNumActivePersistentConnection().PHP_EOL; 31 | echo 'reconnect : ' . PoolInfo::getNumReconnect().PHP_EOL; 32 | ?> 33 | --EXPECT-- 34 | active connection : 0 35 | active connection : 25 36 | persistent connection : 20 37 | active connection : 0 38 | persistent connection : 0 39 | reconnect : 0 40 | -------------------------------------------------------------------------------- /tests/pool_info.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Riak\PoolInfo class 3 | --INI-- 4 | riak.persistent.timeout=10000 5 | riak.persistent.connections=20 6 | --FILE-- 7 | ping(); 18 | 19 | echo 'active connection : ' . PoolInfo::getNumActiveConnection().PHP_EOL; 20 | echo 'persistent connection : ' . PoolInfo::getNumActivePersistentConnection().PHP_EOL; 21 | 22 | $client2 = new Connection($host, $port); 23 | $client2->ping(); 24 | 25 | echo 'active connection : ' . PoolInfo::getNumActiveConnection().PHP_EOL; 26 | echo 'persistent connection : ' . PoolInfo::getNumActivePersistentConnection().PHP_EOL; 27 | 28 | $client = NULL; 29 | $client2 = NULL; 30 | 31 | echo 'active connection : ' . PoolInfo::getNumActiveConnection().PHP_EOL; 32 | echo 'persistent connection : ' . PoolInfo::getNumActivePersistentConnection().PHP_EOL; 33 | echo 'reconnect : ' . PoolInfo::getNumReconnect().PHP_EOL; 34 | ?> 35 | --EXPECT-- 36 | active connection : 0 37 | active connection : 1 38 | persistent connection : 1 39 | active connection : 2 40 | persistent connection : 2 41 | active connection : 0 42 | persistent connection : 0 43 | reconnect : 0 44 | -------------------------------------------------------------------------------- /tests/property_commit_hook.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | CommitHook test 3 | --FILE-- 4 | isJavascript() || $jsHook->isErlang()) { 8 | echo 'Javascript hook unexpected became something else'.PHP_EOL; 9 | var_dump($jsHook); 10 | } 11 | if ($erlHook->isJavascript() || !$erlHook->isErlang()) { 12 | echo 'Erlang hook unexpected became something else'.PHP_EOL; 13 | var_dump($erlHook); 14 | } 15 | echo "done!".PHP_EOL; 16 | ?> 17 | --EXPECT-- 18 | done! 19 | -------------------------------------------------------------------------------- /tests/put1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Simple store test with no read back 3 | --FILE-- 4 | setContent("dummy"); 14 | $output = $bucket->put($obj, new \Riak\Input\PutInput(), 1000); 15 | if (is_null($output->getKey()) || strlen($output->getKey()) == 0) { 16 | var_dump($output); 17 | } 18 | $bucket->delete($output->getKey(), new \Riak\Input\DeleteInput(), 1000); 19 | 20 | $obj = new Object("dummy"); 21 | $obj->setContentType("text/plain"); 22 | $obj->setContent("test value that should get written"); 23 | $bucket->put($obj, null, 1000); 24 | $bucket->delete($obj, null, 1000); 25 | echo "done!"; 26 | } catch (Exception $e) { 27 | echo $e->getMessage(); 28 | } 29 | ?> 30 | --EXPECT-- 31 | done! 32 | -------------------------------------------------------------------------------- /tests/reconnect.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test that client auto reconnect if timeout passed 3 | --INI-- 4 | riak.persistent.timeout=1 5 | --FILE-- 6 | ping(); 10 | sleep(3); 11 | $c->ping(); 12 | echo \Riak\PoolInfo::getNumReconnect().PHP_EOL; 13 | ?> 14 | --EXPECT-- 15 | 1 16 | -------------------------------------------------------------------------------- /tests/reset_object_properties.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test we can set properties of an object to null 3 | --FILE-- 4 | setContent("dummy"); 13 | $obj->setContentEncoding("encoding"); 14 | $obj->setContentType("type"); 15 | $output = $bucket->put($obj); 16 | $key = $output->getKey(); 17 | 18 | $getOutput = $bucket->get($key); 19 | $obj = $getOutput->getFirstObject(); 20 | if (($obj->getContentEncoding() != "encoding") || ($obj->getContentType() != "type")) { 21 | var_dump($obj); 22 | } 23 | $obj->setContent(null); 24 | $obj->setContentEncoding(null); 25 | $obj->setContentType(null); 26 | 27 | $bucket->put($obj); 28 | $getOutput = $bucket->get($key); 29 | $obj = $getOutput->getFirstObject(); 30 | // It seems Riak set contentType to text/plain if it is not set 31 | if (($obj->getContentEncoding() != null) || 32 | ($obj->getContentType() != "text/plain") || 33 | ($obj->getContent() != null)) { 34 | echo "Not all properties was NULL as expected".PHP_EOL; 35 | var_dump($obj); 36 | } 37 | $bucket->delete($key); 38 | echo "done!"; 39 | ?> 40 | --EXPECT-- 41 | done! 42 | -------------------------------------------------------------------------------- /tests/resolve_siblings.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Resolve Siblings 3 | --FILE-- 4 | setPropertyList($props); 16 | $object1->setContent("object value 1"); 17 | $object2->setContent("object value 2"); 18 | 19 | $bucket->put($object1); 20 | $bucket->put($object2); 21 | 22 | $output = $bucket->get($key); 23 | $vClock = $output->getVClock(); 24 | $objects = $output->getObjectList(); 25 | 26 | echo "Has Siblings : " . var_export($bucket->get($key)->hasSiblings(), true) . PHP_EOL; 27 | echo "Same VClock 1 : " . var_export($objects[0]->getVClock() === $vClock, true) . PHP_EOL; 28 | echo "Same VClock 2 : " . var_export($objects[1]->getVClock() === $vClock, true) . PHP_EOL; 29 | 30 | $winner = $objects[1]; 31 | $putInput = new \Riak\Input\PutInput(); 32 | $merged = new \Riak\Object($key); 33 | 34 | $putInput->setVClock($vClock); 35 | $merged->setContent($winner->getContent()); 36 | 37 | $bucket->put($merged, $putInput); 38 | 39 | echo "Has Siblings : " . var_export($bucket->get($key)->hasSiblings(), true) . PHP_EOL; 40 | 41 | $getOutput = $bucket->get($key); 42 | $deleteInput = new \Riak\Input\DeleteInput(); 43 | $bucket->delete($key, $deleteInput->setVClock($getOutput->getVClock())); 44 | ?> 45 | --EXPECT-- 46 | Has Siblings : true 47 | Same VClock 1 : true 48 | Same VClock 2 : true 49 | Has Siblings : false 50 | -------------------------------------------------------------------------------- /tests/search.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Riak search test 3 | --FILE-- 4 | setContentType("application/json"); 23 | $obj->setContent($j); 24 | $bucket->put($obj); 25 | } 26 | 27 | $search = new Search($riak); 28 | $si = new ParameterBag(); 29 | $si->setDefaultField('name'); 30 | $res = $search->search("testsearch", "apple", $si); 31 | if (!$res->hasMaxScore() && !$res->hasNumFound()) { 32 | echo "Did not find any results :(".PHP_EOL; 33 | } 34 | foreach ($res->getDocuments() as $doc) { 35 | $fields = $doc->getFields(); 36 | if ($fields["name"] != "apple") { 37 | var_dump($doc); 38 | } 39 | } 40 | for ($i=0; $idelete("id$i"); 42 | } 43 | echo "done!".PHP_EOL; 44 | ?> 45 | --EXPECT-- 46 | done! 47 | -------------------------------------------------------------------------------- /tests/search_input.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Riak Search Input test 3 | --FILE-- 4 | setRowLimit(10); 10 | if ($inp->getRowLimit() != 10) { 11 | echo "rowlimit".PHP_EOL; 12 | var_dump($inp); 13 | } 14 | $inp->setStartOffset(15); 15 | if ($inp->getStartOffset() != 15) { 16 | echo "startoffset".PHP_EOL; 17 | var_dump($inp); 18 | } 19 | $inp->setSort("plappe_sort"); 20 | if ($inp->getSort() != "plappe_sort") { 21 | echo "sort".PHP_EOL; 22 | var_dump($inp); 23 | } 24 | $inp->setFilter("plappe_filter"); 25 | if ($inp->getFilter() != "plappe_filter") { 26 | echo "filter".PHP_EOL; 27 | var_dump($inp); 28 | } 29 | $inp->setDefaultField("def_field"); 30 | if ($inp->getDefaultField() != "def_field") { 31 | echo "default_field".PHP_EOL; 32 | var_dump($inp); 33 | } 34 | $inp->setDefaultOperation("def_op"); 35 | if ($inp->getDefaultOperation() != "def_op") { 36 | echo "def_op".PHP_EOL; 37 | var_dump($inp); 38 | } 39 | $inp->setPresort("plappe_presort"); 40 | if ($inp->getPresort() != "plappe_presort") { 41 | echo "presort".PHP_EOL; 42 | var_dump($inp); 43 | } 44 | $inp->setFieldLimits(array("1", "2", "3")); 45 | $fls = $inp->getFieldLimits(); 46 | if ($fls[0] != "1" || $fls[1] != "2" || $fls[2] != "3") { 47 | echo "fieldlimits".PHP_EOL; 48 | var_dump($inp); 49 | } 50 | echo "done!".PHP_EOL; 51 | ?> 52 | --EXPECT-- 53 | done! 54 | -------------------------------------------------------------------------------- /tests/server_info.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test server info 3 | --FILE-- 4 | getServerInfo(); 9 | $node = $serverInfo->getNode(); 10 | $serverVersion = $serverInfo->getServerVersion(); 11 | if (is_string($node) && is_string($serverVersion)) { 12 | echo "done!".PHP_EOL; 13 | } else { 14 | var_dump($node); 15 | var_dump($serverVersion); 16 | } 17 | ?> 18 | --EXPECT-- 19 | done! 20 | -------------------------------------------------------------------------------- /tests/session.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Riak session handler test 3 | --INI-- 4 | riak.persistent.timeout=10000 5 | inisession.use_cookies=0 6 | session.cache_limiter= 7 | session.serialize_handler=php 8 | session.save_handler=riak 9 | --FILE-- 10 | 27 | --EXPECT-- 28 | success! 29 | -------------------------------------------------------------------------------- /tests/session_respects_options.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Riak session handler test 3 | --INI-- 4 | riak.persistent.timeout=10000 5 | inisession.use_cookies=0 6 | session.cache_limiter= 7 | session.serialize_handler=php 8 | session.save_handler=riak 9 | --FILE-- 10 | n 19 | $props = new BucketPropertyList(2, false); 20 | $bucket->setPropertyList($props); 21 | 22 | ini_set('session.save_path',"proto://$host:$port/sessions_violation?w=4&dw=4&pw=4&r=4&rw=4&pr=4"); 23 | //try { 24 | session_start(); 25 | $_SESSION['favcolor'] = 'green'; 26 | session_commit(); 27 | //} catch (UnexpectedResponseException $exc) { 28 | // Exceptions are no longer thrown from session handler 29 | echo "done!"; 30 | //} 31 | ?> 32 | --EXPECTF-- 33 | Warning: session_commit(): Failed to write session data (riak). Please verify that the current setting of session.save_path %s 34 | done! 35 | -------------------------------------------------------------------------------- /tests/stream_keys.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bucket stream keys 3 | --FILE-- 4 | setPropertyList($props); 13 | 14 | class KeyStreamer implements KeyStreamOutput { 15 | public $cnt = 0; 16 | public function process($key) { 17 | if (strcmp(substr($key, 0, 6), "stream") == 0) { 18 | $this->cnt++; 19 | } 20 | } 21 | } 22 | 23 | try { 24 | // Make some objects we can list afterwards 25 | for ($i=0; $i<20; $i++) { 26 | $obj = new Object("stream$i"); 27 | $obj->setContent("test-get plap"); 28 | $bucket->put($obj); 29 | } 30 | $streamer = new KeyStreamer(); 31 | $bucket->getKeyStream($streamer); 32 | if ($streamer->cnt == 20) { 33 | echo "success!".PHP_EOL; 34 | } else { 35 | var_dump($streamer); 36 | } 37 | for ($i=0; $i<20; $i++) { 38 | $bucket->delete("stream$i"); 39 | } 40 | } catch (Exception $e) { 41 | var_dump($e); 42 | } 43 | ?> 44 | --EXPECT-- 45 | success! 46 | -------------------------------------------------------------------------------- /tests/update_object.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Object update 3 | --FILE-- 4 | setPropertyList($props); 18 | $object->setContent($objectValue1); 19 | $bucket->put($object); 20 | 21 | var_dump($bucket->get($key)->hasSiblings()); 22 | var_dump($bucket->get($key)->getFirstObject()->getContent()); 23 | 24 | $output = $bucket->get($key); 25 | $object = $output->getFirstObject(); 26 | 27 | var_dump($object->getVClock() === $output->getVClock()); 28 | 29 | $object->setContent($objectValue2); 30 | $bucket->put($object); 31 | 32 | $getOutput = $bucket->get($key); 33 | var_dump($getOutput->getFirstObject()->getContent()); 34 | var_dump($getOutput->hasSiblings()); 35 | 36 | $deleteInput = new \Riak\Input\DeleteInput(); 37 | $bucket->delete($key, $deleteInput->setVClock($getOutput->getVClock())); 38 | ?> 39 | --EXPECT-- 40 | bool(false) 41 | string(14) "object value 1" 42 | bool(true) 43 | string(14) "object value 2" 44 | bool(false) 45 | --------------------------------------------------------------------------------