0

The question is clear I think. I saw that it's possible for python in this stack overflow question: Avoiding Memcache "1000000 bytes in length" limit on values but how to do it in java. (synchronously)

For example I have the object in bytes[] how to split before save and merge after that :

ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutput out = null;
        byte[] bytes;
        try {
            out = new ObjectOutputStream(bos);
            out.writeObject(obj);
            bytes = bos.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
    ...

As I see in Python is used only one key and the rest of the keys are generated somehow according to the size of the byte array that is generated. So the chunks are save under keys: key0, key1, key2 and so on. If I want to retrieve them back how to know how many are the chunks. May be to save them under the 'key' itself.

Community
  • 1
  • 1
makkasi
  • 6,328
  • 4
  • 45
  • 60
  • so basically you're asking how to rewrite this code from the answer, from python to java? – Igor Artamonov Mar 12 '15 at 16:57
  • Basically no because there is not library in java that match the library in python. The documentation is completely different for both languages. – makkasi Mar 12 '15 at 17:01
  • 1
    library to split long `byte[]` into few smaller arrays? instead of `get_multi`/`put_multi` Java have `getAll`/`putAll` – Igor Artamonov Mar 12 '15 at 17:19
  • the method putAll is receiving java.util.Map,?> values. I have only one key value for only one object. How exactly to get the rest. May be to generate them ? If I understand right , I need to split this object on small arrays and to put every small array as value under key in this map. I updated the question a little bit – makkasi Mar 12 '15 at 17:29
  • Answering your own question and accepting it would be useful now. – Paul Collingwood Mar 12 '15 at 20:28
  • @mikkasi they just make 32 keys from original one (and split original data into max 32 pieces), like `foobar.0`, `foobar.1`, ..., `foobar.31` for original `foobar`. and put bytes into this range of keys, then read all possible keys, and join returned data (btw, keep in mind that memcache can forget some piece, like one of the keys, so you could receive corrupted data after join) – Igor Artamonov Mar 13 '15 at 02:17

0 Answers0