Thanks Brian, very good news! Kaspar Am 17.07.2012 18:14 schrieb "Brian Roach" <ro...@basho.com>:
> Kaspar - > > Unfortunately it's worse than that. The reason it's doing that is because > that's how the underlying, original Protobuf client is handling things - it > uses ByteString.copyFromUtf8() on Strings that are passed to store(), > fetch(), etc as the key. > > Basically, above com.basho.riak.pbc.RiakClient there's simply not a way to > use a non-UTF8 encoded String currently. > > The problem with what you propose is that it requires modifying the higher > level interfaces which will of course break code built on top of them (we > have users who have built things on top of these interfaces). This is not > something we want to do in a minor point release. > > That being said, there's a few things we'd like to change in the client > but haven't for this same reason. Along with the Riak 1.2 release we'll be > cutting the 1.0.6 release of the Java client. After that, I'd be willing to > look into what it would take to sanely allow for arbitrary byte arrays to > be used as keys for a 1.1 client release that would include other interface > breaking changes. > > Thanks, > Brian Roach > > > On Jul 17, 2012, at 4:32 AM, Kaspar Thommen wrote: > > > Brian, > > > > I just identified a potential issue. In my application code all keys are > byte[] arrays (or corresponding 64 bit integers), and in order to make sure > I can generate a valid Riak key String from that byte array I convert using > ISO-8859-1. However, when looking at PBClientAdapter.store() I see that it > calls ConversionUtil.convert(), which in turn calls > ConversionUtil.nullSafeToByteString() which uses UTF-8 encoding. Hence, my > original byte array will likely be different in Riak. > > > > This could could lead to tricky problems like the application code > logging a byte array key that cannot be found in Riak. Do you think it > would make sense to allow the user to specify a custom String/byte[] > converter? > > > > Thanks, > > Kaspar > > Am 16.07.2012 15:51 schrieb "Brian Roach" <ro...@basho.com>: > > Kaspar - > > > > Russell and I got together and discussed this a little more this morning. > > > > The reason it's not exposed at the IRiakClient and RawClient interfaces > is because the underlying original HTTP client API doesn't support a byte > array as a key; it only uses String. Because of this, our IRiakObject > default implementation only takes a String for a key, and our annotation > processing only works with a String as well. It was all designed around > being protocol neutral to sit on top of both of the old clients. > > > > That being said, what does work perfectly fine is creating a new String > from the byte array. Java does the right thing and this works regardless of > whether you are using the PB or HTTP client: > > > > IRiakClient client = RiakFactory.pbcClient(); // or .httpClient() > > Bucket b = client.fetchBucket("this").execute(); > > > > byte[] foo = { 0, 5, 120, 1 }; > > String key = new String(foo); > > > > b.store(key, "this is my value").execute(); > > IRiakObject o = b.fetch(key).execute(); > > System.out.println(o.getValueAsString()); > > > > client.shutdown(); > > > > Thanks! > > Brian Roach > > > > On Jul 16, 2012, at 1:01 AM, Russell Brown wrote: > > > > > Hi Kaspar, > > > > > > Sorry for the slow reply. > > > > > > On 16 Jul 2012, at 07:49, Kaspar Thommen wrote: > > > > > >> Anyone please? > > >> > > >> On Jun 26, 2012 8:57 PM, "Kaspar Thommen" <kaspar.thom...@gmail.com> > wrote: > > >> Hi, > > >> > > >> The high-level API in the Java client library (IRiakClient) does not > allow one to use byte[] arrays as keys, only Strings, whereas the > underlying PBC and http APIs (e.g. com.basho.riak.pbc.RiakClient) do, via > the fetch(ByteString, ...) methods. Any reason for this? > > > > > > Oversight or oversimplifying by me. > > > > > > > > >> Is it planned to add byte array keys to IRiakClient as well at some > point? > > > > > > We should. Please will you raise an issue for it on the RJC github > repo[1] to ensure we get to it? > > > > > > Cheers > > > > > > Russell > > > > > > [1] Java client issues - > https://github.com/basho/riak-java-client/issues?direction=desc&sort=created&state=open > > > > > >> > > >> Thanks, > > >> Kaspar > > >> > > >> > > >> _______________________________________________ > > >> 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 > > > >
_______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com