Skip to content

Instantly share code, notes, and snippets.

@asonge
Created February 12, 2011 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asonge/9dc39b4784618e0dc826 to your computer and use it in GitHub Desktop.
Save asonge/9dc39b4784618e0dc826 to your computer and use it in GitHub Desktop.
function getKeys() {
$params = array('props'=>'false','keys'=>'true');
$url = RiakUtils::buildRestPath($this->client, $this, NULL, NULL, $params);
$response = RiakUtils::httpRequest('GET', $url);
# Use a RiakObject to interpret the response, we are just interested in the value.
$obj = new RiakObject($this->client, $this, NULL);
$obj->populate($response, array(200));
if (!$obj->exists()) {
throw Exception("Error getting bucket properties.");
}
$keys = $obj->getData();
return array_map("urldecode",$keys["keys"]);
}
@kevburnsjr
Copy link

This method sure is expensive.

200 keys
$bucket->getKeys() * 10

---
549ms
556ms
542ms
538ms
539ms
545ms
539ms
540ms
537ms
542ms

---
Total: 5427ms
Average: 543ms

keys=true and keys=stream are about the same.

@asonge
Copy link
Author

asonge commented Feb 15, 2011

Which is why it's not recommended...though I'm just using it on an admin panel until i start building indexes.

@kevburnsjr
Copy link

Just ran a map/reduce (no indexing) and it took even longer

$client->add($bucket->name)
    ->map("function(v){return [v.key];}")
    ->run();

---
645ms
620ms
621ms
626ms
623ms
628ms
627ms
622ms
625ms
628ms

---
Total: 6267ms
Average: 627ms

Not familiar with indexing in Riak.
I'd be interested to see how you do it.
I'm usually found idling in #riak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment