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