InterSystems IRIS Data Platform 2020.4 > Class Reference > ENSLIB namespace > %iKnow.Metrics.MetricBuilder

%iKnow.Metrics.MetricBuilder

deprecated abstract class %iKnow.Metrics.MetricBuilder extends %Library.RegisteredObject

The %iKnow.Metrics infrastructure is deprecated in favour of the more SQL-oriented approach offered through %iKnow.Tables.Utils, where you can add computed fields at different levels and choose whether they need to be persisted or not.

Subclasses of this class should implement at least one of the Calculate***Metrics() methods in this interface to support calculating custom metrics for the corresponding target and type. Supported metrics should then register this subclass as their "builder class" in their definition (see %iKnow.Metrics.MetricDefinition).

Metric Builder implementations are invoked through their Build() or BuildAll() methods and will then start building all applicable metrics, forwarding the actual metric calculations to the Calculate***Metrics() implementations (for example, CalculateEntUniMetrics() for target $$$IKMTRENTITY and type $$$IKMTRTYPEDOMAIN). Instances of these implementations will be running in parallel if SUPPORTSMULTIPROCESS is set to 1 (default = 1), or will run single-threaded otherwise.

Note: When Calculate***Metrics() methods don't return any values for a particular target element, the existing metric value is retained (if any). Returning "" for a value will overwrite (erase) the existing value.

Property Inventory (Including Private)

Method Inventory (Including Private)

Parameters

parameter BATCHSIZE = 1024;
Indicates how many entries a process will reserve for itself to calculate per batch
parameter SUPPORTSMULTIPROCESS = 1;
This parameter indicates whether or not this MetricBuilder implementation supports multiple instances running in parallel to optimize performance. By default, it is set to 1 which means different instances will work in parallel.

Properties (Including Private)

property CurrentFieldId as %Integer;
If Type = $$$IKMTRTYPEGROUP, this property contains the current Metadata Field ID for which metrics are gathered. To be used from within the metrics calculation methods such as CalculateEntityMetrics().
Property methods: CurrentFieldIdDisplayToLogical(), CurrentFieldIdGet(), CurrentFieldIdIsValid(), CurrentFieldIdLogicalToDisplay(), CurrentFieldIdNormalize(), CurrentFieldIdSet()
property CurrentFieldName as %String;
If Type = $$$IKMTRTYPEGROUP, this property contains the current Metadata Field name for which metrics are gathered. To be used from within the metrics calculation methods such as CalculateEntityMetrics().
Property methods: CurrentFieldNameDisplayToLogical(), CurrentFieldNameGet(), CurrentFieldNameIsValid(), CurrentFieldNameLogicalToDisplay(), CurrentFieldNameLogicalToOdbc(), CurrentFieldNameNormalize(), CurrentFieldNameSet()
property CurrentFieldValue as %String;
If Type = $$$IKMTRTYPEGROUP, this property contains the current Metadata Value for which metrics are gathered. To be used from within the metrics calculation methods such as CalculateEntityMetrics().
Property methods: CurrentFieldValueDisplayToLogical(), CurrentFieldValueGet(), CurrentFieldValueIdDisplayToLogical(), CurrentFieldValueIdGet(), CurrentFieldValueIdIsValid(), CurrentFieldValueIdLogicalToDisplay(), CurrentFieldValueIdNormalize(), CurrentFieldValueIdSet(), CurrentFieldValueIsValid(), CurrentFieldValueLogicalToDisplay(), CurrentFieldValueLogicalToOdbc(), CurrentFieldValueNormalize(), CurrentFieldValueSet()
property CurrentFieldValueId as %Integer;
If Type = $$$IKMTRTYPEGROUP, this property contains the current Metadata Value ID for which metrics are gathered. To be used from within the metrics calculation methods such as CalculateEntityMetrics().
Property methods: CurrentFieldValueIdDisplayToLogical(), CurrentFieldValueIdGet(), CurrentFieldValueIdIsValid(), CurrentFieldValueIdLogicalToDisplay(), CurrentFieldValueIdNormalize(), CurrentFieldValueIdSet()
property CurrentSrcId as %Integer;
If Type = $$$IKMTRTYPESOURCE, this property contains the current Source ID for which metrics are gathered. To be used from within the metrics calculation methods such as CalculateEntityMetrics().
Property methods: CurrentSrcIdDisplayToLogical(), CurrentSrcIdGet(), CurrentSrcIdIsValid(), CurrentSrcIdLogicalToDisplay(), CurrentSrcIdNormalize(), CurrentSrcIdSet()
property DomainId as %Integer [ Final , ReadOnly ];
Property methods: DomainIdDisplayToLogical(), DomainIdGet(), DomainIdIsValid(), DomainIdLogicalToDisplay(), DomainIdNormalize()
property SrcFilter as %iKnow.Filters.Filter [ Final ];
Property methods: SrcFilterGet(), SrcFilterGetSwizzled(), SrcFilterIsValid(), SrcFilterNewObject(), SrcFilterSet()
property Target as %String [ Final , ReadOnly ];
Property methods: TargetDisplayToLogical(), TargetGet(), TargetIsValid(), TargetLogicalToDisplay(), TargetLogicalToOdbc(), TargetNormalize()
property Type as %String [ Final , ReadOnly ];
Property methods: TypeDisplayToLogical(), TypeGet(), TypeIsValid(), TypeLogicalToDisplay(), TypeLogicalToOdbc(), TypeNormalize()

Methods (Including Private)

private method %OnNew(pDomainId As %Integer, pType As %String, pTarget As %String, pProcNumber As %Integer, pSrcFilter As %String = "") as %Status [ Language = objectscript ]
Inherited description: This callback method is invoked by the %New() method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status If instead of returning a %Status code this returns an oref and this oref is a subclass of the current class then this oref will be the one returned to the caller of %New method.

final classmethod Build(pDomainId As %String, pSourceFilter As %iKnow.Filters.Filter = "", pVerbose As %Boolean = 1, pAsync As %Boolean = 1) as %Status [ Language = objectscript ]

Builds all the metrics referring this class in their BuilderClass property. See also BuildAll().

final classmethod BuildAll(pDomainId As %String, pMetrics As %List = "", pSrcFilter As %String = "", pVerbose As %Boolean = 1, pAsync As %Boolean = 1) as %Status [ Language = objectscript ]

This is the main method to be invoked to build all the Metrics for a given domain, optionally limited to a number of metrics specified by ID through pMetrics. It will build a list of all MetricBuilder implementations referred by registered metrics and then run through all targets and types. For each target, it will first invoke all MetricBuilder implementations NOT supporting parallel processing (with SUPPORTSMULTIPROCESS=0) and then spawn a number of jobs to take care of the ones that can run in parallel. These spawned processes will reserve batches of the target element (for example a batch of entities) and then let all MetricBuilder implementations that support metrics for that target run through them and calculate any metric values using the different Calculate***Metrics() methods.

Note: metrics can only be calculated in a domain in which they are already registered. See the Register() method in the %iKnow.Metrics.MetricDefinition class for more details.

final classmethod BuildIndex(pDomainId As %Integer, pMetricId As %Integer, pTarget As %String) as %Status [ Language = objectscript ]

This method builds an index for a particular Metric and Target.

Note: no indices will be built for metrics of type $$$IKMTRTYPESOURCE, as these intra-source entries will be sorted on the fly when calling any applicable sorted queries.

method CalculateCcUniMetrics(pCcUniId As %Integer, pHeadId As %Integer, pTailId As %Integer, Output pValues) as %Status [ Language = objectscript ]

This is the main method a custom MetricBuilder should implement to support metrics targeting CCs. Depending on the value of Type, the properties CurrentSrcId (for $$$IKMTRTYPESOURCE), CurrentFieldName and CurrentFieldValue (for $$$IKMTRTYPEGROUP) or neither of these (for $$$IKMTRTYPEDOMAIN) will define the scope for which metrics should be calculated.

For a given unique CC pCcUniId, this method should calculate all metrics it knows about and return them through pValues in an array indexed by metric name: pValues(metricName) = value

method CalculateCrcUniMetrics(pCrcUniId As %Integer, pHeadId As %Integer, pRelationId As %Integer, pTailId As %Integer, Output pValues) as %Status [ Language = objectscript ]

This is the main method a custom MetricBuilder should implement to support metrics targeting CRCs. Depending on the value of Type, the properties CurrentSrcId (for $$$IKMTRTYPESOURCE), CurrentFieldName and CurrentFieldValue (for $$$IKMTRTYPEGROUP) or neither of these (for $$$IKMTRTYPEDOMAIN) will define the scope for which metrics should be calculated.

For a given unique CRC pCrcUniId, this method should calculate all metrics it knows about and return them through pValues in an array indexed by metric name: pValues(metricName) = value

method CalculateEntUniMetrics(pEntUniId As %Integer, pEntUniValue As %String, Output pValues) as %Status [ Language = objectscript ]

This is the main method a custom MetricBuilder should implement to support metrics targeting entities. Depending on the value of Type, the properties CurrentSrcId (for $$$IKMTRTYPESOURCE), CurrentFieldName and CurrentFieldValue (for $$$IKMTRTYPEGROUP) or neither of these (for $$$IKMTRTYPEDOMAIN) will define the scope for which metrics should be calculated.

For a given unique entity pEntUniId, this method should calculate all metrics it knows about and return them through pValues in an array indexed by metric name: pValues(metricName) = value

method CalculatePathMetrics(pPathId As %Integer, pEntities As %List, Output pValues) as %Status [ Language = objectscript ]

This is the main method a custom MetricBuilder should implement to support metrics targeting Paths. Depending on the value of Type, the properties CurrentSrcId (for $$$IKMTRTYPESOURCE), CurrentFieldName and CurrentFieldValue (for $$$IKMTRTYPEGROUP) or neither of these (for $$$IKMTRTYPEDOMAIN) will define the scope for which metrics should be calculated.

For a given path pPathId, this method should calculate all metrics it knows about and return them through pValues in an array indexed by metric name: pValues(metricName) = value

method CalculateSentenceMetrics(pSentenceId As %Integer, Output pValues) as %Status [ Language = objectscript ]

This is the main method a custom MetricBuilder should implement to support metrics targeting sentences. Depending on the value of Type, the properties CurrentSrcId (for $$$IKMTRTYPESOURCE), CurrentFieldName and CurrentFieldValue (for $$$IKMTRTYPEGROUP) or neither of these (for $$$IKMTRTYPEDOMAIN) will define the scope for which metrics should be calculated.

For a given sentence pSentenceId, this method should calculate all metrics it knows about and return them through pValues in an array indexed by metric name: pValues(metricName) = value

method CalculateSourceMetrics(pSourceId As %Integer, Output pValues) as %Status [ Language = objectscript ]

This is the main method a custom MetricBuilder should implement to support metrics targeting sources. Depending on the value of Type, the properties CurrentSrcId (for $$$IKMTRTYPESOURCE), CurrentFieldName and CurrentFieldValue (for $$$IKMTRTYPEGROUP) or neither of these (for $$$IKMTRTYPEDOMAIN) will define the scope for which metrics should be calculated.

For a given source pSourceId in the context of a given source pSrcId, this method should calculate all metrics it knows about and return them through pValues in an array indexed by metric name: pValues(metricName) = value

method OnAfterBuildMetrics() as %Status [ Language = objectscript ]

Utility method called after a MetricBuilder instance starts building any metrics, in which custom code can be executed to clean up any auxiliary objects or data structures.

Note: depending on the value of SUPPORTSMULTIPROCESS, multiple MetricBuilder instances can be running alongside one another

method OnAfterBuildMetricsBatch(pFrom As %Integer, pTo As %Integer) as %Status [ Language = objectscript ]

Utility method called after a MetricBuilder starts building any metrics for a batch of elements, for metrics of type $$$IKMTRTYPEDOMAIN

method OnAfterBuildMetricsForGroup() as %Status [ Language = objectscript ]

Utility method called after a MetricBuilder instance finishes building any metrics for the group identified by CurrentFieldName and CurrentFieldValue, for metrics of type $$$IKMTRTYPEGROUP.

method OnAfterBuildMetricsForSource(pSrcId As %Integer) as %Status [ Language = objectscript ]

Utility method called after a MetricBuilder starts building any metrics for the source identified by pSrcId, for metrics of type $$$IKMTRTYPESOURCE.

method OnBeforeBuildMetrics() as %Status [ Language = objectscript ]

Utility method called before a MetricBuilder instance starts building any metrics, in which custom code can be executed to set up any auxiliary objects or data structures.

Note: depending on the value of SUPPORTSMULTIPROCESS, multiple MetricBuilder instances can be running alongside one another

method OnBeforeBuildMetricsBatch(pFrom As %Integer, pTo As %Integer) as %Status [ Language = objectscript ]

Utility method called before a MetricBuilder starts building any metrics for a batch of elements, for metrics of type $$$IKMTRTYPEDOMAIN

method OnBeforeBuildMetricsForGroup() as %Status [ Language = objectscript ]

Utility method called before a MetricBuilder instance starts building any metrics for the group identified by CurrentFieldName and CurrentFieldValue, for metrics of type $$$IKMTRTYPEGROUP.

method OnBeforeBuildMetricsForSource(pSrcId As %Integer) as %Status [ Language = objectscript ]

Utility method called before a MetricBuilder instance starts building any metrics for the source identified by pSrcId, for metrics of type $$$IKMTRTYPESOURCE.

Inherited Members

Inherited Methods (Including Private)

Feedback