• michal.lisinski (7/19/2016)


    So it confirmed my assumptions that the problem exist in serialization.

    This is what I was saying in #2. You aren't fully serializing the collection, just the keys. The values are all hard-coded to be 1.

    I added the Value part to write out each value in the SortedDictionary, but now it returns very strange result, sum of all values doesn't give integer.

    You need to attach your updated code. Also, are you testing with the exact same values as before? There is a code path in the Terminate method that will pick the Min or Max value instead of doing a Sum. Please also post your test values if they are different from before.

    I've found some articles with warnings that the interface IDictionary is not serializable for some unknown reason so all the classes that implement the IDictionary interface (SortedDictionary, Dictionary ) can not be serialized in simple way, so I wonder if the Read() and Write() methods of the IBinarySerialize interface are used to deserialize and serialize work with SortedDictionary?

    I don't see any issue with the SortedDictionary since you aren't serializing it. Nor is it being auto serialized. You wrote the serialization code in the Write method. If there is no issue with the Terminate method or the test data, then perhaps look at how you are serializing. I am not sure if relying upon the stream length is an issue. It might not be, but I have never tried that. I have always written the number of elements in the collection as one of the first items in the Write method, and then I read it first in the Read method and do a for loop to read that number of elements from the stream.

    Still, I am not sure why you are using a SortedDictionary. Is that required for doing Min and Max? If not, then perhaps try a regular Dictionary?

    Take care,

    Solomon...

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR