shogun-toolbox/shogun — pull request #355 by karlnapf (2012-01-10 10:10:37+00:00)
Title: First working migration example

Finally, after all this sweat and blood :)

There is a new example which illustrates some migration cases.
This example is about type changes. There are two classes which are constructed in such way, that one is two versions older than the other one. The more current one has all the needed mappings implemented.
Also see the overloaded migration method in the current one.
The old one with old types is serialized, then the new one is deserialized and all the mappings/migration is done internally.

What I did:
Added some new methods to TParamter, i.e. copy_data() to copy data from another TParameter in the way I need it, delete_all_but_data() which de-allocates all the things (lengths, data pointers) that may be created by allocate_from_scratch()

I added a string prefix to CMath::display_vector /display_matrix to make my example look nicer
The load_serializable/save_serializable now have a new parameter where one can specify the current parameter version. Default value is VERSION_PARAMETER, but I need this for testing, its used in the example.

Finally, the load_serializable checks if the file has a parameter version less than current, and tries to perform migration. When something is saved with current version, and then loaded, nothing changes.

There are still some things missing: non-scalar SG_OBJECT migration, adding of new parameter, removing old parameters.
Also, I think both of you (Soeren and Sergey) should have a look at how things are used when it comes to changing a parameter - basically this only requires adding the mappings and overloading the migrate method in a correct way, I wrote a helper method CSGObject:.one_to_one_migration_prepare which should cover many cases, but there might be other cases, so if we think about it with three people thats probably better

I also suggest that we meet to go a bit through the stuff. A separate documentation/HOWTO how to migrate parameters might also be useful, where should I put stuff like this?

PS. sorry for the huge patch