est / terrastore

Automatically exported from code.google.com/p/terrastore
Other
0 stars 0 forks source link

The java client APIs should provide methods for directly storing and retrieving json docs as byte arrays #147

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In some circumstances it would be more effective to be able to store key/value 
pairs as just byte arrays. 

Original issue reported on code.google.com by grec...@gmail.com on 16 Dec 2010 at 1:07

GoogleCodeExporter commented 9 years ago
I assume you mean directly storing json documents as byte arrays, without going 
through an intermediate object conversion.

I think this is very useful indeed, in particular when the object<->json 
conversion is externally done.

Original comment by sergio.b...@gmail.com on 16 Dec 2010 at 1:13

GoogleCodeExporter commented 9 years ago
Sven,

what's your take on this?

Original comment by sergio.b...@gmail.com on 16 Dec 2010 at 1:14

GoogleCodeExporter commented 9 years ago
Yes, indeed. yes, like having an API like:
put(byte[] key, byte[] value)

Original comment by grec...@gmail.com on 16 Dec 2010 at 1:16

GoogleCodeExporter commented 9 years ago
It's a rather small thing to do.
I don't see any obvious use case for referring to the key using a byte-array, 
though.
Unless there are any concrete reasons for this I suggest:
 put(String key, byte[] value).

Assigning it to myself.

Original comment by johansso...@gmail.com on 16 Dec 2010 at 1:49

GoogleCodeExporter commented 9 years ago
Good point about the key: no need to use byte arrays for that.

Anyways, I think we should provide alternative bytearray-based methods for all 
read/write operations, rather than just put ... thoughts?

Original comment by sergio.b...@gmail.com on 16 Dec 2010 at 1:51

GoogleCodeExporter commented 9 years ago

Original comment by sergio.b...@gmail.com on 16 Dec 2010 at 1:52

GoogleCodeExporter commented 9 years ago
The use-case I'm referring to is providing a persistent storage backend for  
akka based on TS. 
In this case the key is passed as a byte array.

Original comment by grec...@gmail.com on 16 Dec 2010 at 2:01

GoogleCodeExporter commented 9 years ago
David,

yo should manually convert the key from byte[] to utf8-string prior to passing 
it to the client: it shouldn't be a problem, nor provide any performance 
penalty.

Original comment by sergio.b...@gmail.com on 16 Dec 2010 at 2:04

GoogleCodeExporter commented 9 years ago
Yes, no  problem, I wanted only to give you an example of a use-case. However, 
I agree on the fact that the key as a String is a more general use-case 

Original comment by grec...@gmail.com on 16 Dec 2010 at 2:08

GoogleCodeExporter commented 9 years ago
Sven,

just thinking aloud about possible implementations.

We have two ways to do that:
1) Add alternative byte[]-based methods, mirroring already existent 
object-based ones.
2) Leave already existent interfaces untouched, and implement a "RawJsonObject" 
which users willing to pass raw json data back and forth will have to use to 
wrap their json byte[]: our client will recognize the use of such a special 
object and apply no conversion but simply using the wrapped json byte[].

Thoughts?

Original comment by sergio.b...@gmail.com on 16 Dec 2010 at 2:09

GoogleCodeExporter commented 9 years ago
As for using a byte-array as key, that Akka somehow works this way does not 
feel like a general enough use case to add a method to the API for this.

Come to think of it, though, given that you pass in a byte-array value that in 
fact _is_ a valid UTF-8 JSON String, it should be possible to do this already, 
just as you can pass a JSON String.

I'd need to double-check this, but I'm pretty sure.

Original comment by johansso...@gmail.com on 16 Dec 2010 at 2:59

GoogleCodeExporter commented 9 years ago
Sven,
I agree. I really don't mind to convert the byte array into a String. Really no 
problem

Original comment by grec...@gmail.com on 16 Dec 2010 at 3:03

GoogleCodeExporter commented 9 years ago
Sorry, David - I didn't see comment(9) above about that.

Original comment by johansso...@gmail.com on 16 Dec 2010 at 3:09

GoogleCodeExporter commented 9 years ago
Please go ahead with the discussion on the project mailing list: 
http://groups.google.com/group/terrastore-discussions/t/a04a72880ab3c005

Original comment by sergio.b...@gmail.com on 16 Dec 2010 at 3:29

GoogleCodeExporter commented 9 years ago
Closing this issue, as no change is required.

Original comment by johansso...@gmail.com on 17 Dec 2010 at 9:59