I am using Protocol Buffers for my data and want to store and retrieve this data from Memcached (running on ElastiCache). I am using the MemcachedClient in Java.
I am currently storing data to Memcache using code similiar to this:
memClient.set("keyString", protobufBuilder.build().toByteArray());
But, I am not sure how to get this data from Memcached and convert it back into a Protobuf object.
Any help is really appreciated.
I figured it out.
I simply typecasted the data I get from MemcachedCleint to byte[] and gave it as input to the pasreFrom method of my Protobuf object.
Related
I want to send the ByteBuffer from FlatBuffers over network to an Android Application.
I tried using echo $builder->sizedByteArray, but then I'm wondering how to deserialize this String.
Note that this bytearray has to be sent in a way suited to binary transmission, not text.
As for deserialization with Java, have you looked here: https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html (make sure you select Java as your language) ? You can use ByteBuffer.wrap with a byte[] you received over the network.
Ok, just a simple question, I would like to send a object via java and obj-c. Is this possible to do so? Or I need to change the object to string or something first, and convert it back in to the receive side? Thanks.
It is possible to send a serialised Java object to objective C over a socket, but recovering it is difficult since you'd need to write a library to parse the binary data stream. It's possible someone has already written such a library.
It's easier to send objects encoded in JSON or XML, or with Google protocol buffers.
I would like to send a object via java and obj-c
This is the classic problem of communication between different systems/languages.
The solution has always been XML (usually SOAP which is not my taste) and nowadays the options #Joni mentions in his answer
I have a situation like this.
Some of my data was compressed using gzdeflate() function in php and stored in the database. Now I need to do some work with the data stored in database. I tried a lot of options in Java(including GZipStream, Inflater etc) but was unable to retrieve the data from database.
So I thought of using gzinflate() function in php and was able to retrieve the data quite easily. Now I have the data in a variable in php which I want to pass back to my java program so that I can continue with my previous work.
I have come across some of the options like Java/PHP bridge, Caurces and all but couldn't find a way either.
Is there a way which can solve this requirement of mine. I am stuck in this part for a while now and would really appreciate your help.
Try JZlib library to decompress using java. JZlib can inflate data deflated by zlib.
The coding language is Java.
I have a ByteArray embedded in ActionScriptObject.(http://smartfoxserver.com/'>Smartfox Server)
I want to convert it into ByteArray.
The idea is to save it as an image.
This a sequel to the post --> Convert Byte Array from Action Script to Image in Java and save it
Have tried http://www.javafaq.nu/java-article236.html'>this method
It failed with the
java.io.NotSerializable Exception
Regards,
naveenj
The NotSerializableException is because the ActionScriptObject does not implement Serializable.
The ActionScriptObject does not support byte arrays. This is according to information found on the SmartFox Server forum. This probably means that when it creates the Java object that represents your ActionScript object, it does not copy the "arr" property at all!
To transfer the image data to the server you will have to use a network socket and write the data down the wire.
Reading the docs for Smartfox Server, there is a SocketLoader tutorial in chapter 8.17 which should allow you to transmit the image data to the server. http://www.smartfoxserver.com/docs/index.htm?http://www.smartfoxserver.com/docs/docPages/tutorials_pro/17_socketFileLoader/index.htm
Have you tried with JBoss Serialization? http://www.jboss.org/serialization
Regards.
An extra requirement is that the attachments can be stored as a stream, as there might be potentially very large binaries that has to be saved. Videos etc.
I have looked at Voldemort and other key value stores, but they all seem to expect byte arrays, which is completely out of the question.
This should, preferrably, be written in Java, and be embeddable.
The use case is:
I have written a HTTP Cache library which has multiple backends.
I have a Memory based one (using hashmap and Byte arrays), Derby database, persistent hashmap with file attachment, EHCache with file attachment.
I was hoping there was something out there which didn't use the file system, or if it does, it's transparent from the API.
I am storing the Headers with some more meta information in a datastore. But I also need to store the payload of the HTTP response.
The HTTP response payload might be VERY big, thats why I need to use streaming.
Why is a byte[] value out of the question? Any object graph can be serialized into a byte array!
Have you looked at sleepycat's Berkeley DB (it's free)?
EDIT - having seen jhedding's comment, it seems like you need to store data which is too big to fit into a single JVM in one go. Have you:
Checked that it won't fot into a 64-bit JVM?
Tried using a network file system? (NAS or whatever)