SnappyDB icon indicating copy to clipboard operation
SnappyDB copied to clipboard

Using Parcelable instead of serializable

Open Aexyn opened this issue 10 years ago • 3 comments

I may sound noob here but I have read some where that parcelable is 10 times faster than serializable for android. So why using Serializable Object instead of Parcelable objects.?

Aexyn avatar Jan 06 '15 10:01 Aexyn

+1, if support Parcelable, will use on Android.

crossle avatar Jan 12 '15 10:01 crossle

Hi @Aexyn You're right Parcelable is faster than Serializable but only when it comes to pass object between activities & fragments. this comparison/benchmark has nothing to do with the process of persisting the object into disk.

Moreover, Parcelable representation is not stable (the implementation is subject to change) i.e we can't just grab the byte array out of a Parcelable then save it :)

btw you can save non Serializable objects: https://github.com/nhachicha/SnappyDB#insert-object

you can even create your own Kryo serializer: https://github.com/nhachicha/SnappyDB/blob/master/library/src/androidTest/java/com/snappydb/sample/tests/api/BasicOperations.java#L60

or use one provided by https://github.com/magro/kryo-serializers check https://github.com/nhachicha/SnappyDB/issues/6

Cheers,

nhachicha avatar Jan 13 '15 12:01 nhachicha

Great :+1: Thanks

Aexyn avatar Jan 14 '15 05:01 Aexyn