/* {{{ proto Riak\Bucket Riak\Bucket->setPropertyList(Riak\BucketProperties $properties) Apply given properties to this bucket */ PHP_METHOD(RiakBucket, setPropertyList) { riak_connection *connection; RIACK_STRING bucketName; zval* zpropsObj, znval, zallowmult; int riackResult; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zpropsObj) == FAILURE) { return; } GET_RIAK_CONNECTION_RETURN_EXC_ON_ERROR(connection) bucketName = riack_name_from_bucket(getThis() TSRMLS_CC); RIAK_CALL_METHOD(RiakBucketProperties, getNValue, &znval, zpropsObj); RIAK_CALL_METHOD(RiakBucketProperties, getAllowMult, &zallowmult, zpropsObj); riackResult = riack_set_bucket_props(connection->client, bucketName, Z_LVAL(znval), Z_BVAL(zallowmult)); CHECK_RIACK_STATUS_THROW_AND_RETURN_ON_ERROR(connection, riackResult); RIAK_RETURN_THIS }
/* {{{ proto array Riak\Bucket->indexQuery(IndexQuery $query[, IndexInput $input]) Apply given properties to this bucket */ PHP_METHOD(RiakBucket, indexQuery) { riak_connection *connection; riack_2i_query_req req; riack_string_list *result_keys; riack_string *continuation, *type; zval *zquery, *zinput, *zname, *zisrange, *zcontinuation, *zresult; int riackstatus; zinput = zquery = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|O", &zquery, riak_index_query_ce, &zinput, riak_index_input_ce) == FAILURE) { zend_throw_exception(riak_badarguments_exception_ce, "Bad or missing argument", 500 TSRMLS_CC); return; } // TODO Validate query have exact or ranged values connection = get_riak_connection(getThis() TSRMLS_CC); THROW_EXCEPTION_IF_CONNECTION_IS_NULL(connection); memset(&req, 0, sizeof(req)); type = riack_get_bucket_type_from_bucket(connection->client, getThis() TSRMLS_CC); if (type != NULL) { req.bucket_type.len = type->len; req.bucket_type.value = type->value; } req.bucket = riack_name_from_bucket(getThis() TSRMLS_CC); MAKE_STD_ZVAL(zname); RIAK_CALL_METHOD(Riak_Query_IndexQuery, getName, zname, zquery); req.index.len = Z_STRLEN_P(zname); req.index.value = Z_STRVAL_P(zname); continuation = NULL; zcontinuation = NULL; if (zinput) { zval *zmaxresults; MAKE_STD_ZVAL(zmaxresults); RIAK_CALL_METHOD(Riak_Input_IndexInput, getMaxResults, zmaxresults, zinput); if (Z_TYPE_P(zmaxresults) == IS_LONG) { req.max_results = Z_LVAL_P(zmaxresults); } zval_ptr_dtor(&zmaxresults); MAKE_STD_ZVAL(zcontinuation); RIAK_CALL_METHOD(Riak_Input_IndexInput, getContinuation, zcontinuation, zinput); if (Z_TYPE_P(zcontinuation) == IS_STRING) { req.continuation_token.len = Z_STRLEN_P(zcontinuation); req.continuation_token.value = Z_STRVAL_P(zcontinuation); } } MAKE_STD_ZVAL(zisrange); RIAK_CALL_METHOD(Riak_Query_IndexQuery, isRangeQuery, zisrange, zquery); if (Z_BVAL_P(zisrange)) { zval *zmin, *zmax; // TODO Call getter instead, this is cheat zmin = zend_read_property(riak_index_query_ce, zquery, "minValue", sizeof("minValue")-1, 1 TSRMLS_CC); zmax = zend_read_property(riak_index_query_ce, zquery, "maxValue", sizeof("maxValue")-1, 1 TSRMLS_CC); req.search_min.len = Z_STRLEN_P(zmin); req.search_min.value = Z_STRVAL_P(zmin); req.search_max.len = Z_STRLEN_P(zmax); req.search_max.value = Z_STRVAL_P(zmax); RIACK_RETRY_OP(riackstatus, connection, riack_2i_query(connection->client, &req, &result_keys, &continuation)); } else { zval *zexact; zexact = zend_read_property(riak_index_query_ce, zquery, "exactValue", sizeof("exactValue")-1, 1 TSRMLS_CC); req.search_exact.len = Z_STRLEN_P(zexact); req.search_exact.value = Z_STRVAL_P(zexact); RIACK_RETRY_OP(riackstatus, connection, riack_2i_query(connection->client, &req, &result_keys, &continuation)); } zval_ptr_dtor(&zname); zval_ptr_dtor(&zisrange); if (zcontinuation) { zval_ptr_dtor(&zcontinuation); } RFREE(connection->client, type); CHECK_RIACK_STATUS_THROW_AND_RETURN_ON_ERROR(connection, riackstatus); zresult = riak_index_output_from_string_list_and_continuation(result_keys, continuation TSRMLS_CC); riack_free_string_p(connection->client, &continuation); riack_free_string_list_p(connection->client, &result_keys); RETURN_ZVAL(zresult, 0, 1); }