· Mar 13, 2020

Stream.Read method of %Stream.Object class.

In one of my class, I use Stream.Read() method of the %Stream.Object class.

  • Method OnRequest(request As Ens.StreamContainer, Output response As %Library.Persistent) As %Status
  • {
  •    SET sc=$$$OK
  •    SET strRequest=request.Stream.Read(,.sc)
  • ​​   $$$TRACE($L(​​strRequest))
  • ....  

The Trace value gives 32,000. But the Read() method of the %Stream.Object class specifies 32,656 by default.

  1. Method Read(ByRef len As %Integer = 32656, ByRef sc As %Status) As %CacheString
  2. {
  3.    Set len=0,i%AtEnd=1,sc=$$$OK
  4.    Quit ""
  5. }

Why ?

Best Regards.

Discussion (2)2
Log in or sign up to continue

To add to what Peter said, there is a clue in the Read method documentation, snippet follows:

If no len is passed in, ie. 'Read()' then it is up to the Read implementation as to how much data to return. Some stream classes use this to optimize the amount of data returned to align this with the underlying storage of the stream.  

[[ Extra emphasis mine. ]]

And, if for some reason the FindAt method was called, it does only read a maximum of 20000 characters, snippet follows:

Method FindAt(position As %Integer, target As %CacheString, ByRef tmpstr As %CacheString = "", caseinsensitive As %Boolean = 0) As %Integer
If caseinsensitive Set target=$zconvert(target,"l")
;; truncation for brevity... While '..AtEnd {
Set tmp=..Read(20000)
If caseinsensitive Set tmp=$zconvert(tmp,"l")
Set tmpstr=$extract(tmpstr,*-targetlen+2,*)_tmp

[[ extra emphasis also mine. ]]

Hope this helps!