nhachicha / SnappyDB

A key-value database for Android
1.78k stars 220 forks source link

Using Parcelable instead of serializable #34

Open Aexyn opened 9 years ago

Aexyn commented 9 years ago

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.?

crossle commented 9 years ago

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

nhachicha commented 9 years ago

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,

Aexyn commented 9 years ago

Great :+1: Thanks