domain~ StreamAggregateDatum

A stream aggregate datum entity.

A stream aggregate datum is a datum representing some aggregate calculation, without any metadata describing the datum property names. The instantantaneous and accumulating property values are stored as 2D array fields iProps and aProps that hold the property values as well as associated aggregate statistics. The datum status properties are stroed in the 1D array field sProps. A DatumStreamMetadata object is required to associate names with these arrays.

The instantaneous properties are 4-element arrays containing:

  1. property average value
  2. property count
  3. minimum value
  4. maximum value

The accumulatingn statistics are 3-element arrays containing:

  1. difference between ending and starting property values
  2. starting property value
  3. ending property value

Constructor

new StreamAggregateDatum(streamId, ts, iPropsopt, aPropsopt, sPropsopt, tagsopt)

Constructor.

Parameters:
NameTypeAttributesDescription
streamIdstring

the datum stream ID

tsArray.<(Date|number|string)>

an array with 2 elements for the datum start and end timestamps, either as a Date instance or a form suitable for constructing as new Date(ts)

iPropsArray.<Array.<number>><optional>

the instantaneous property values and associated statistics

aPropsArray.<Array.<number>><optional>

the accumulating property values and associated statistics

sPropsArray.<String><optional>

the status property values

tagsSet.<String> | Array.<String><optional>

the tag values

Methods

toJsonEncoding(registryopt) → {string}

Get this object as a standard JSON encoded string value.

This method returns the JSON form of the result of StreamAggregateDatum#toJsonObject().

Parameters:
NameTypeAttributesDescription
registrymodule:util~DatumStreamMetadataRegistry<optional>

a stream metadata registry to encode as a registry-indexed stream datum

Returns:

the JSON encoded string

Type: 
string

toJsonObject(registryopt) → {Array}

Get this object as an array suitable for encoding into a standard stream datum JSON string.

This method can encode the datum into an array using one of two ways, depending on whether the registry argument is provided. When provided, the first array element will be the stream metadata index based on calling DatumStreamMetadataRegistry#indexOfMetadataStreamId(). Otherwise the first array element will be the stream ID itself.

For example if a registry is used, the resulting array might look like this:

[0,[1650945600000,1651032000000],[3.6,2,0,7.2],[19.1,2,18.1, 20.1],[1.422802,1138.446687,1139.869489]]

while without a registry the array might look like this:

["7714f762-2361-4ec2-98ab-7e96807b32a6", [1650945600000,1651032000000],[3.6,2,0,7.2],[19.1,2,18.1, 20.1],[1.422802,1138.446687,1139.869489]]
Parameters:
NameTypeAttributesDescription
registrymodule:util~DatumStreamMetadataRegistry<optional>

a stream metadata registry to encode as a registry-indexed stream datum

Returns:

the datum stream array object

Type: 
Array

toObject(meta, withoutStatisticsopt) → {Object}

Get this instance as a simple object.

The following basic properties will be set on the returned object:

  • streamId - the stream ID
  • date - the timestamp
  • date_end - the ending timestamp, if available
  • sourceId - the metadata source ID
  • nodeId or locationId - either the node ID or location ID from the metadata
  • tags - any tags (as an Array)

Beyond that, all instantaneous, accumulating, and status properties will be included. If duplicate property names exist between the different classifications, the first-available value will be used. Any available statistics for each property are included as well, using property names with the following suffixes:

  • _count - count of datum
  • _min - minimum value
  • _max - maximum value
  • _start - starting value
  • _end - ending value
Parameters:
NameTypeAttributesDescription
metamodule:domain~DatumStreamMetadata

a metadata instance to encode the property names with

withoutStatisticsboolean<optional>

true to omit statistic properties

Returns:

an object populated with all available properties

Type: 
Object

(static) fromJsonEncoding(json, meta) → {module:domain~StreamAggregateDatum}

Parse a JSON string into a StreamAggregateDatum instance.

The JSON must be encoded the same way StreamAggregateDatum#toJsonEncoding() does.

Parameters:
NameTypeDescription
jsonstring

the JSON to parse

metamodule:domain~DatumStreamMetadata | module:util~DatumStreamMetadataRegistry

a metadata instance or metadata registry to decode with

Returns:

the stream datum instance

Type: 
module:domain~StreamAggregateDatum

(static) fromJsonObject(data, meta) → {module:domain~StreamAggregateDatum}

Create a new StreamAggregateDatum instance from an array parsed from a stream datum JSON string.

The array must have been parsed from JSON that was encoded the same way StreamAggregateDatum#toJsonEncoding() does.

Parameters:
NameTypeDescription
dataArray

the array parsed from JSON

metamodule:domain~DatumStreamMetadata | module:util~DatumStreamMetadataRegistry

a metadata instance or metadata registry to decode with

Returns:

the stream datum instance

Type: 
module:domain~StreamAggregateDatum