Question
Dmitry Maslennikov · 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
1
0 226
Discussion (3)1
Log in or sign up to continue

Hi Dmitry,
Did you ever get some useful echo?
Except: "use the newer version". 
No surprise. But ISC mostly doesn't follow their own rules and suggestions
You may create your own %ZXML.CharacterStream extending  %Stream.GlobalCharacter.

I would not expect as much resistance from ISC as against my backport of %JSON* to Caché

Yeah, I've replaced %Library.GlobalCharacterStream with %Stream.GlobalCharacterStream, solved the main issue, but was a cause to another issue, with storage format, they are not compatible, any new data is ok, but all the previously saved data became unavailable, but it's possible to fix its storing. In my case that change was worth it.

Thanks! Very valuable to know that they are not compatible!