Size of serialization

Feb 7, 2013 at 11:16 AM
Currently I am using DbCustomSerializer from Newtonsoft.Json.JsonConvert, 148610 recods take up 30.5MB file size.
    public class Foo
    {
        public ulong ID { get; set; }
        public ulong ServerConnectionKey { get; set; }
        public DateTime TaskTime { get; set; }
        public string Result { get; set; }
        public string Message { get; set; }
        public uint FooType { get; set; }
        public uint ResponseTime { get; set; }
    }
the Result and Message are all empty strings.

and this recalls my initial concern: custom serilization to compact byte[], maybe even with compression will greatly reduce the size.
Coordinator
Feb 7, 2013 at 12:18 PM
If you are concerned so much ab. the size, make explicit serialier/deserializer for every POCO object you have - it will greatly reduce the size.
For example your given object is:
      public ulong ID { get; set; }  - 8bytes
    public ulong ServerConnectionKey { get; set; } - 8bytes
    public DateTime TaskTime { get; set; } - 8bytes
    public string Result { get; set; } ???
    public string Message { get; set; } ??? 
    public uint FooType { get; set; } - 4 bytes
    public uint ResponseTime { get; set; } - 4bytes
=> 32 bytes + 2 strings which can be saved as DataBlocks (16 byte reference * 2) => 32+32 = 64 byte. (in case if strings are nul)
148610 * 64 = 9511040 => 9,5MB (+ trie search data I think may be 1MB or so)
Feb 8, 2013 at 2:23 AM
Edited Feb 8, 2013 at 2:23 AM
I found a generic way to quickly serialize object to byte[] and deserialize object from byte[]. I will post the code tonight
Feb 8, 2013 at 6:05 AM
I got the idea from fastjson, and based on it, implemented simple POCO serialization/deserialization, right now no support for deep-copy (nested objects).