· Jun 9, 2021

Streams and %IsModified after %Save

Found one interesting behaviour in one system with Ensemble. Some Request class has a property with type %XML.CharacterStream by design, this class is the heaviest request in the system, and with profiling journal files, it got about 40% of the file. When I counted all the sizes of such streams per one day and found that the real stored data is three times less. After deep inspecting the journal file, I found the first save of stream data, then removing previously stored data, and saving again and there were no reasons to change the content of the stream, it should be stored only once.

After some tests, I found, that it happens due to %IsModified() method for such a stream property, it still returns 1 if the parent object was already saved. And any subsequent %Save() even immediately, will overwrite stream in the storage.

And I found a workaround if I would change the type to %Stream.GlobalCharacter, the behaviour now as expected, no more useless overwrites.

So, the issue only with stream classes in %Library, %XML.CharacterStream just extends %Library.GlobalCharacterStream


And my question would be, is it safe enough to change all my GlobalCharacterStream to %Stream.GlobalCharacterStream, anything else I should look at after changes?

Product version: Ensemble 2018.1
Discussion (3)1
Log in or sign up to continue