void RiakTest::ListKeys() { //const char* uuid = "48740512-e7e7-4661-871e-dfa837a2b973"; const char* uuid = "af926e3d-b855-4d90-990c-db717b0a412d"; riack_string_linked_list *list; riack_string_linked_list *rkey; riack_string bucket; bucket.value = (char*)uuid; bucket.len = strlen(uuid); int ret = riack_list_keys(m_riak, &bucket, &list); std::ofstream os("g:\\temp\\_aaa.txt"); char key[RADI_PATH_MAX]; for (rkey = list; rkey != NULL; rkey = rkey->next) { memset(key, 0, RADI_PATH_MAX); memcpy(key, rkey->string.value, rkey->string.len); //printf("[key]:%s\n", key); os << key << std::endl; } os.close(); riack_free_string_linked_list_p(m_riak, &list); }
int test_meta_links_load() { RIACK_STRING bucket_posts, bucket_answers; struct RIACK_GET_OBJECT get_post; struct RIACK_OBJECT put_post; struct RIACK_STRING_LINKED_LIST *keys_posts, *current_post, *keys_answers, *current_answer; bucket_posts.len = strlen(RIAK_TEST_BUCKET_POSTS); bucket_posts.value = RIAK_TEST_BUCKET_POSTS; bucket_answers.len = strlen(RIAK_TEST_BUCKET_ANSWERS); bucket_answers.value = RIAK_TEST_BUCKET_ANSWERS; // Make random links between posts and comments if ((riack_list_keys(test_client, bucket_posts, &keys_posts) == RIACK_SUCCESS)&& (riack_list_keys(test_client, bucket_answers, &keys_answers) == RIACK_SUCCESS)) { current_post = keys_posts; current_answer = keys_answers; while (current_post && current_post->next) { if (riack_get(test_client, bucket_posts, current_post->string, 0, &get_post) == RIACK_SUCCESS) { if (get_post.object.content_count == 1) { memset(&put_post, 0, sizeof(put_post)); put_post.bucket = copy_string(&bucket_posts); put_post.key = copy_string(¤t_post->string); put_post.content_count = 1; put_post.content = copy_content(get_post.object.content); current_answer = test_make_links(current_answer, get_post.object.content); if (riack_put(test_client, put_post, 0, 0) != RIACK_SUCCESS) { return 1; } riack_free_object(test_client, &put_post); } riack_free_get_object(test_client, &get_post); } current_post = current_post->next; } } return 0; }
/* {{{ proto string[] Riak\Bucket->getKeyList() List all keys in the bucket */ PHP_METHOD(RiakBucket, getKeyList) { struct RIACK_STRING_LINKED_LIST* resultlist, *curr; RIACK_STRING rsbucket; riak_connection *connection; zval* zresultarr; int riackstatus; GET_RIAK_CONNECTION_RETURN_EXC_ON_ERROR(connection) rsbucket = riack_name_from_bucket(getThis() TSRMLS_CC); riackstatus = riack_list_keys(connection->client, rsbucket, &resultlist); CHECK_RIACK_STATUS_THROW_AND_RETURN_ON_ERROR(connection, riackstatus); MAKE_STD_ZVAL(zresultarr); array_init(zresultarr); curr = resultlist; while (curr) { add_next_index_stringl(zresultarr, curr->string.value, curr->string.len, 1); curr = curr->next; } riack_free_string_linked_list(connection->client, &resultlist); RETURN_ZVAL(zresultarr, 0, 1); }