Kevin - in this specific case, Riak itself will accept a slash in the key name. It will not, however, accept a slash through the HTTP interface. See http://riak.markmail.org/search/?q=slash#query:slash+page:1+mid:5j5jb4maepr3epc3+state:resultsThe short version is that there's no sane way we can safely check strings for validity since all bucket and key names are valid, but they're different values of valid depending on the API you're using at the time.
As best as I can tell, there's no restriction on the riak KV side about how a bucket or key is named. As far as Erlang is concerned it's just a bunch of bytes masquerading as a string. If you do anything goofy and want that goofy/unexpected name to work everywhere you need to properly escape your bucket name. This is similar to how SQL Server requires square brackets around reserved keywords or database objects with special characters in their name (e.g. CREATE TABLE [i like data] ( id INT ); ). As long as names are correctly escaped, you won't run into any problems. Continuing the same analogy, CorrugatedIron is a lot like ADO.NET. If I create a SqlCommand with CommandText of "OMGWTFBBQ", The SqlCommand object doesn't care trying to do or that what I passed in probably isn't valid T-SQL, it only knows that I've given it a command that needs to be sent to a SQL Server. OJ and I have debated how much smarts CorrugatedIron should have. Our ultimate decision is that it should have just enough smarts to get the job done and not a speck more. It's a relatively low level client (along the lines of ADO.NET), but we do what we can to hide a lot of the nastiness and idiosyncrasies of Riak from the user in places where it might get confusing. One of the things we hide is the dual nature of Riak's API. Almost all operations are supported via ProtocolBuffers (which doesn't care about names) but a few are only supported through HTTP. I hope this helps clear up some of your questions. --- Jeremiah Peschka - Founder, Brent Ozar Unlimited MCITP: SQL Server 2008, MVP Cloudera Certified Developer for Apache Hadoop On Wed, Feb 6, 2013 at 5:32 AM, OJ Reeves <[email protected]> wrote: > I am not aware of the rules in bucket naming, I don't even know if there > are any or if they're documented anywhere. All I can say is that I wouldn't > personally use a forward-slash because it's an obvious conflict with other > areas of the system. > > OJ > > On Wed, Feb 6, 2013 at 10:44 PM, Kevin Burton <[email protected]>wrote: > >> The set properties method returns without error on the "illegally named" >> bucket as do all of the put operations. It is just the get properties >> operation that returns an error. If the bucket is indeed improperly named >> then the bug is in the operations that allow the bucket name. Right? >> >> On Feb 5, 2013, at 10:44 PM, Alexander Moore <[email protected]> >> wrote: >> >> I think the problem you are having here is that you are using an invalid >> bucket name. >> >> "buyseasons/products" would actually refer to a bucket/key pair. Riak >> doesn't have nested buckets. >> >> If you change your bucket name to "buyseasons-products" or >> "buyseasons%20products" it should work. >> >> As for the weird/misleading exception, I'll report it to CorrugatedIron. >> >> Thanks, >> Alex Moore >> >> >> I still have a question. Based on your input I modified the code slightly >>> as follows: >>> >>> ** ** >>> >>> RiakBucketProperties bucketProperties = new >>> RiakBucketProperties();**** >>> >>> bucketProperties.SetNVal(4);**** >>> >>> bucketProperties.SetSearch(true);**** >>> >>> bucketProperties.SetAllowMultiple(true);**** >>> >>> bucketProperties.SetWVal("all");**** >>> >>> bucketProperties.SetRVal("quorum");**** >>> >>> if (!client.SetBucketProperties("buyseasons/products", >>> bucketProperties).IsSuccess)**** >>> >>> {**** >>> >>> Console.WriteLine("Setting bucket properties failed");** >>> ** >>> >>> }**** >>> >>> RiakResult<RiakBucketProperties> riakBuckpropertiesResult = >>> client.GetBucketProperties("buyseasons/products", true);**** >>> >>> ** ** >>> >>> But I get a NullReferenceException**** >>> >>> ** ** >>> >>> at CorrugatedIron.Models.RiakBucketProperties.ReadQuorum(JObject >>> props, String key, Action`1 setter)**** >>> >>> at CorrugatedIron.Models.RiakBucketProperties..ctor(RiakRestResponse >>> response)**** >>> >>> at CorrugatedIron.RiakClient.GetBucketProperties(String bucket, >>> Boolean extended)**** >>> >>> . . . . .**** >>> >>> ** ** >>> >>> So the bucket should have been created when I set the properties. But >>> then I tried to read the properties back and I get the exception.**** >>> >>> ** ** >>> >>> *From:* Alexander Sicular [mailto:[email protected]] >>> *Sent:* Tuesday, February 05, 2013 5:17 PM >>> *To:* Kevin Burton >>> *Cc:* riak-users >>> *Subject:* Re: Bucket creation.**** >>> >>> ** ** >>> >>> "buckets" are a virtual concept. you dont need to "create" them. just >>> write a key to any bucket. also by modifying the default bucket parameters, >>> by adding the search hook on a bucket, let's say, you are also "creating" >>> the bucket.**** >>> >>> ** ** >>> >>> -alexander**** >>> >>> ** ** >>> >>> On Tue, Feb 5, 2013 at 6:09 PM, Kevin Burton <[email protected]> >>> wrote:**** >>> >>> **** >>> >>> I have filed to find code that would create a bucket. It must be in the >>> past I have just put objects into a bucket and Riak must construct the >>> bucket if it does not exist. Now I would like to create the bucket and set >>> some properties on that bucket. But I don’t know how to create the bucket. >>> **** >>> >>> **** >>> >>> So I have code like:**** >>> >>> **** >>> >>> BuildProduct(source, destination);**** >>> >>> RiakObject value = new RiakObject("products", >>> keySku, JsonConvert.SerializeObject(destination))**** >>> >>> {**** >>> >>> ContentType = "application/json"**** >>> >>> };**** >>> >>> **** >>> >>> RiakResult<RiakObject> response = >>> client.Put(value, new RiakPutOptions { W = 2 });**** >>> >>> **** >>> >>> But I would like to create the bucket and set properties on the bucket >>> before I put things into the bucket. Like:**** >>> >>> **** >>> >>> RiakResult<RiakBucketProperties> riakBuckpropertiesResult = >>> client.GetBucketProperties("products", true);**** >>> >>> if (riakBuckpropertiesResult.IsSuccess)**** >>> >>> {**** >>> >>> riakBuckpropertiesResult.Value >>> >> >> >> _______________________________________________ >> riak-users mailing list >> [email protected] >> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com >> >> > > > -- > > OJ Reeves > +61 431 952 586 > http://buffered.io/ > > _______________________________________________ > riak-users mailing list > [email protected] > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com > >
_______________________________________________ riak-users mailing list [email protected] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
