Skip to main content


stream class HS.SDA3.QuickStream extends %Stream.Object

Stream class that stores character data in global nodes.
This is cloned from %Stream.GlobalCharacter, for use for quick messaging. Both the temporary and stored version of the stream are stored in the same place, usually ^CacheTemp.HS.Stream(Id). The Id is assigned when the stream is created, and the creator can pass in an ID as an argument to %New.
Unlike %Stream.GlobalCharacter, this never participates in a transaction, and is never journaled. This drastically reduces both journal usage and contention, eliminating performance delays.
Optionally, one of these can be created using %New(,0). This is a hybrid usage, which stores both the temporary and stored versions in ^HS.Stream(id). It's somewhat slower, since this is journalled, but it's still used outside the scope of transactions, and the stream ID can be passed around in Ensemble messages to avoid repeated saving of the stream. This variation should be used, for instance, with Async messaging of inbound data, where the stream needs to survive a machine crash.

Property Inventory

Method Inventory


parameter BUFFERLEN = 32000;
Number of characters that we are storing in each global node
final parameter READCHANGED = 2;
final parameter READNODATA = 0;
final parameter READNOTCHANGED = 1;
final parameter WRITE = 3;


property GRef as %String;
will either be of form ^CacheTemp.HS.Stream(number) or ^HS.Stream(number)
Property methods: GRefDisplayToLogical(), GRefGet(), GRefIsValid(), GRefLogicalToDisplay(), GRefLogicalToOdbc(), GRefNormalize(), GRefSet()
property LineTerminator as %String (MAXLEN = 10) [ InitialExpression = $char(13,10) , Transient ];
Type of line terminator we use for this stream, defaults to Cr/Lf. Maximum length is 10 characters.
Property methods: LineTerminatorDisplayToLogical(), LineTerminatorGet(), LineTerminatorIsValid(), LineTerminatorLogicalToDisplay(), LineTerminatorLogicalToOdbc(), LineTerminatorNormalize(), LineTerminatorSet()


classmethod %DeleteData(streamvalue As %String, concurrency As %Integer) as %Status
[Previously private]
classmethod %Exists(soid As %ObjectIdentity) as %Boolean
Inherited description: Checks to see if the object identified by the OID oid exists in the extent.

Returns %Boolean TRUE is it exists, FALSE if it does not.

method %NormalizeObject() as %Status
Inherited description: Normalizes all of an object's property values by invoking the data type Normalize methods. Many data types may allow many different representations of the same value. Normalization converts a value to its cannonical, or normalized, form.
method %ValidateObject(force As %Library.Integer = 0, checkserial As %Library.Integer = 1) as %Status
Inherited description:

This method validates an object.

The %Save() method of a persistent class calls this method before filing any objects in the database. The %ValidateObject() of a referencing object can call it. You can also call it explicitly at any time.

%ValidateObject() does the following:

  1. If present, it will call a user-supplied %OnValidateObject() method.
  2. It checks if any required property values are missing.
  3. If the PROPERTYVALIDATION class parameter is set to ValidateOnSave, it validates each non-null property value by calling the property method IsValid on each literal property and the %ValidateObject method for each object-valued embedded object property (properties whose type extend %SerialObject).
  4. If checkserial is 1, it forces the checking of any embedded object properties by calling their %ValidateObject method after swizzling this property.
  5. If checkserial is 2, it forces the checking of any collections of serial types by iterating over those collections and calling their %ValidateObject() method after swizzling this property, in addition to the validation that occurs when checkserial is 1.

%ValidateObject() returns a %Status indicating success or error. It is up to the caller to process the error value.

%ValidateObject() does not validate object-valued reference properties (properties whose type extends %Persistent) due to the possibility of circular dependencies between objects. The %Save() method of a persistent class automatically detects and handles circular references between objects. If you require the validation of reference properties, you can override this method in a subclass or call %Save() directly.

method Clear(permanent As %Boolean = 1) as %Status
Inherited description: Clear the contents of this Stream from permanent storage. This will remove the permanent stream storage and any temporary stream and initialise the stream to its initial state that it starts in, including removing all the stream attributes.

Returns a %Status value indicating success or failure.

method CopyFrom(source As %Stream.Object) as %Status
Inherited description: Copies the contents of source into this Stream. Does not call Rewind() on this Stream before copying.

For example, you can copy oldstream into a new stream:

  Set newstream=##class(%GlobalCharacterStream).%New()
  Do newstream.CopyFrom(oldstream)

Returns a %Status value indicating success or failure.

method CopyFromAndSave(source As %Stream.Object) as %Status
Inherited description: Copy the stream from source into the current stream ignoring anything already in the current stream and save the result to the permanent location. This is used to optimise the copying of say a %GlobalCharacterStream to another %GlobalCharacterStream to avoid copying into temporary storage first and then moving this to the permanent storage when SaveStream() is called.

Note that any locking or transaction handling must be done by the caller.

method Flush() as %Status
Inherited description: Flush any output in the stream not already saved.
method GSave(related) as %Status
method Initialize(pID="", pTemp=1)
method IsNull() as %Boolean
Returns true if this is a "NULL" stream; that is, a stream which has never been written to and saved. This is used by the Caché ODBC server.
final method LastModifiedGet() as %TimeStamp
method MoveToEnd() as %Status
Inherited description: Move to the end of the stream so the next Write will be appended to the end. This allows you to read from a stream, then MoveToEnd() and append new data, where just calling Write() after a read will clear the stream before writing new data.

Returns a %Status value indicating success or failure.

method OutputToDevice(ByRef len As %Integer = -1) as %Status
Inherited description: Write out len characters of the stream to the current device starting from the current position. This method is optimised for performance by the various sub classes. If len is omitted or set to -1 then it will write out the entire stream starting at the beginning.
method Read(ByRef len As %Integer = 32000, ByRef sc As %Status) as %Library.RawString
Inherited description: Reads up to len characters from the current position in the stream. The current position is advanced by the number of characters read. Upon exit, len is set to the actual number of characters read. If a read occurs when the stream position is at the end of the stream, len will be set to -1 and Read() will return a null string (""). 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.

You must call Rewind() if you want to read a stream from the beginning again. Calling Read() after Write() implicitly ends the Write() operation and rewinds to the start of the stream.

Returns a string up to len characters long. The byref argument sc will return a %Status if any error occurred during the read.

method ReadLine(ByRef len As %Integer = 32000, ByRef sc As %Status, ByRef eol As %Boolean) as %Library.RawString
Inherited description: Read a line from the stream. This will look for the line terminator in the stream and once it finds the terminator it will return the string minus the terminator character/s. If it reaches the end of the stream before it finds a terminator it will return the data it has so far, and if you specify a maximum size in len it will only read up to this number of characters. On exit len will contain the actual number of characters read. The byref argument sc will return a %Status() if any error occured during the read and the byref argument eol is true if it found the line terminator and false otherwise. So for example you can read in a stream a line at a time and output the results to the current device with:
While 'stream.AtEnd { Write stream.ReadLine(,.sc,.eol) If $$$ISERR(sc) { Write "ERROR" Quit } If eol { Write ! } }
method ReadLineIntoStream(ByRef sc As %Status) as %Stream.Object
This reads from the stream until it find the LineTerminator and returns this as a stream. If the stream does not contain the line terminator this can potentially be the entire stream.
method Rewind() as %Status
Inherited description: Go back to the start of the stream.
method SizeGet() as %Integer
Return the current size of the data stream.
classmethod TestCopy()
method Write(data As %Library.String = "") as %Status
Inherited description: Appends the string data to the stream and advances the current stream position by the number of characters in data.

Note that a write operation immediately following a read or rewind will clear out the existing data in the stream.

Returns a %Status value indicating success or failure.

method WriteLine(data As %Library.String = "") as %Status
Appends the string data along with a line terminator to the stream and advances the current stream position by the number of characters in data plus the line terminator.

Returns a %Status value indicating success or failure.

Inherited Members

Inherited Properties

Inherited Methods

FeedbackOpens in a new tab