Yeah, ok I see it now... guess I'm still too much in some sql mindset. We will 
store lots of files of the same type
so I guess I would need some way of separating them, perhaps by name or 
something into "directories". You're
right of course about not putting 10 000 files into a directory.

Actually, in some ways we do want to use riak as a distributed file system, but 
would also like to run queries against
the file metadata.

4 sep 2010 kl. 21.19 skrev Sean Cribbs:

> You wouldn't put 10,000 files in a single directory on your computer, so 
> there's no reason you would have to in Riak either.  What about representing 
> your directories as objects, too? The only thing you would require would be a 
> known key that's the root of the hierarchy. For example:
> 
> /riak/files/__root, which has links to:
> -> "/riak/files/images" (directory)
> -> "/riak/files/text" (directory)
> -> "/riak/files/index.html" (file)
> 
> "/riak/files/images" which has links to:
> -> "/riak/files/images%2Ffavicon.ico" (file)
> -> "/riak/files/images%2Flogo.jpg" (file)
> 
> (note I escape the slashes in the key names)
> 
> With proper use of links and tags, this is not a difficult problem.  If you 
> just want to mount Riak like a file system, you might look at Artur Bergman's 
> riakfuse project.
> 
> Sean Cribbs <s...@basho.com>
> Developer Advocate
> Basho Technologies, Inc.
> http://basho.com/
> 
> On Sep 4, 2010, at 2:51 PM, John Axel Eriksson wrote:
> 
>> Yes, I've thought of this but as I understand it there is a bit of a problem 
>> attaching a large amount of links to a key which
>> would be necessary here am I right? If I had 10 000 files in riak that would 
>> mean 10 000 links attached to the "listing" key.
>> 
>> 4 sep 2010 kl. 20.44 skrev Matthew Scott:
>> 
>>> 
>>> On Sat, Sep 4, 2010 at 11:31, John Axel Eriksson <j...@insane.se> wrote:
>>> Listing keys in a bucket has been described as "bad" and something you use 
>>> in development but
>>> not in production. I'm just starting out on Riak so I'm a newbie...
>>> 
>>> I'm thinking of building an application using Riak as filestorage and 
>>> possibly much more than that, but it would
>>> at least store lots of files with, perhaps, metadata attached. How would I 
>>> then list files for display in a webapp if
>>> I don't use key listing?
>>> 
>>> I'm still very much a Riak newb myself, but I'll take a shot at answering 
>>> this one by suggesting the use of links.
>>> 
>>> From what I understand, links some quantity limits when you attach a large 
>>> number, but adding and removing them is an inexpensive operation.  (Someone 
>>> fact check me on that please :)
>>> 
>>> - Create a key called 'listing', perhaps even in its own bucket to prevent 
>>> namespace collision.
>>> 
>>> - Create links from that 'listing' key to metadata keys.  Remember that you 
>>> can attach a tag to each link to differentiate different types of links, 
>>> such as "metadata".
>>> 
>>> - The metadata keys' values would contain file metadata in JSON form, and 
>>> in turn have a link to the file contents key, tagged "contents".
>>> 
>>> - Remember to attach the proper mime type to the key containing your file 
>>> contents.
>>> 
>>> - To get a file listing, do a map/reduce starting at "listing", following 
>>> its "metadata" links and grabbing those values, then reduce to sort by a 
>>> key.
>>> 
>>> - To get file contents, follow the "contents" link from the metadata key.
>>> 
>>> --
>>> Matthew Scott
>>> ElevenCraft, Inc.
>>> http://11craft.com/
>>> +1 360 389-2512
>>> 
>>>  
>> 
>> _______________________________________________
>> riak-users mailing list
>> riak-users@lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to