Question Carl Deitrich · Oct 10, 2024

Simple Way To Compare Streams

Is there a simple way to compare Stream data between two objects?

We have used $ZCRC to create a checksum and that seems to be work.
We have also read each line of the streams and compared them and that seems to work too.

We just think there has to be a simpler way than looping through all the lines of the stream.

Any suggestions would be appreciated.

Product version: IRIS 2023.1
$ZV: IRIS for Windows (x86-64) 2023.1.2 (Build 450_0_22859) Mon Dec 4 2023 14:32:44 EST

Comments

Carl Deitrich  Oct 10, 2024 to Luis Angel Pérez Ramos

Luis, Thanks,  How does one go about loading a persistent object's stream data into a dynamic object?

0
Enrico Parisi  Oct 11, 2024 to Luis Angel Pérez Ramos

I miss how you are going to compare the two base64 json properties.

If you assume that the stream AND the base64 converted stream sizes are less than maximum string length, then I miss the point of converting to base64.

0
Timo Lindenschmid · Oct 10, 2024

very quick and dirty test, probably only works on small streams, also needs to actually read the whole stream for compare.
 

# test compare - streams are same
set stream1=##class(%Stream.TmpCharacter).%New()
set stream2=##class(%Stream.TmpCharacter).%New()
do stream1.WriteLine("ABC123")
do stream2.WriteLine("ABC123")
do stream1.Rewind()
do stream2.Rewind()
w (stream1.Read() = stream2.Read())

1

# test compare - stream are different
set stream1=##class(%Stream.TmpCharacter).%New()
set stream2=##class(%Stream.TmpCharacter).%New()
do stream1.WriteLine("ABC123")
do stream2.WriteLine("DEF456")
do stream1.Rewind()
do stream2.Rewind()
w (stream1.Read() = stream2.Read())

0
0
Enrico Parisi  Oct 11, 2024 to Timo Lindenschmid

This works only if you assume that the stream size is less than the maximum string length.

0
Vitaliy Serdtsev · Oct 11, 2024

It seems to me that in this case it would be advisable to use a comparison of stream hashes, using, for example, the SHA3HashStream method.

0