php-judy icon indicating copy to clipboard operation
php-judy copied to clipboard

Implement serialization

Open Zyava opened this issue 11 years ago • 4 comments

Here one guy implemented serialization for Judy::INT_TO_INT: http://habrahabr.ru/sandbox/48527/. Is it possible to have the same for other types?

Zyava avatar Aug 28 '13 20:08 Zyava

The idea isn't that useful, tbh, so it's up to you whether to implement it or not. The initial implementation was supposed to support negative keys, which isn't quite possible with Judy itself - it uses unsigned long for keys and -1 is kind of a special value. So I went ahead and pretty much copied the implementation from the Habr, but dropped negative keys support in the process. See https://github.com/tony2001/php-judy/tree/serialize

tony2001 avatar Sep 25 '13 15:09 tony2001

Thanks @tony2001. I'm not sure either on the benefit of this. If you guys feel like it can serve few folks, I'd be happy to merge the changes. Tho, I haven't done any extensive test on it yet.

orieg avatar Oct 07 '13 07:10 orieg

Hi Guys,

Just a question about serialize() implementation. I've got a huge array of object. I use for this

$result = new \Judy(\Judy::INT_TO_MIXED);

Now i want to store the judy object into a noDB like REDIS ; unfortunately no way to serialize the whole Judy object.

You Guys got any advices on how to perform this operation ?

Thanks by advance

alexis-gruet-deel avatar Oct 30 '13 17:10 alexis-gruet-deel

You can do exactly what any serialization does: go over the array and add your entries to some string, then store that string in the DB. Make sure you're able to deserialize that string back, though.

tony2001 avatar Oct 30 '13 17:10 tony2001