Class MetricsPlan
Handle for the (de)serializable contract, containing flat lists of Expression and Table objects, any needed binaries, and MetricSetMetadata.
Inherited Members
Namespace: Mangrove.MetricSetSyntaxTree
Assembly: MetricSetSyntaxTree.dll
Syntax
public class MetricsPlan
Remarks
Concepts
What, conceptually, does a MetricsPlan represent? Fundamentally, it
captures a specification of how to compute some values ("metrics", hence the name of this
class). That description may not be fully complete, e.g. there may still be some wildcards
like #Start#
or #Flights#
, and it may have more metrics than one finally intends to
compute. A computation specification (MetricsPlan) may not initially be
in a format which lends to easy script-generation, but for that we have a battery of
IMetricsPlanTransformer objects for transforming a "raw"
MetricsPlan produced by compiling a metric set into a "modified"
MetricsPlan which may be passed into an emitter for script-generation.
Along the way, assumptions about MetricsPlan objects are expressed via
IMetricsPlanValidator objects.
Contents
A serialized MetricsPlan is actually a zip file, regardless of its file extension. The internal structure will look like:
package
__references__
*.jar
*.dll
AST.json
Properties
View SourceExpressions
All expressions (intermediate or not) in this MetricsPlan, given in no particular order.
Declaration
public IReadOnlyList<Expression> Expressions { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Expression> |
Metadata
Generic metadata (e.g., metric set name) for this object.
Declaration
public MetricSetMetadata Metadata { get; }
Property Value
Type | Description |
---|---|
MetricSetMetadata |
References
Mapping name -> binary (whether DLL or JAR file).
Declaration
[JsonIgnore]
public IReadOnlyDictionary<string, MemoryStream> References { get; }
Property Value
Type | Description |
---|---|
IReadOnlyDictionary<String, MemoryStream> |
Tables
All tables in this MetricsPlan, given in no particular order.
Declaration
public IReadOnlyList<Table> Tables { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Table> |
Methods
View SourceCreateValidMetricsPlan(IEnumerable<Expression>, IEnumerable<Table>, MetricSetMetadata, IMetricsPlanValidator, IReadOnlyDictionary<String, MemoryStream>)
Create a valid MetricsPlan using a validator to check that the MetricsPlan is a consistent object.
Declaration
public static MetricsPlan CreateValidMetricsPlan(IEnumerable<Expression> expressions, IEnumerable<Table> tables, MetricSetMetadata metadata, IMetricsPlanValidator validator, IReadOnlyDictionary<string, MemoryStream> references)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Expression> | expressions | |
IEnumerable<Table> | tables | |
MetricSetMetadata | metadata | |
IMetricsPlanValidator | validator | |
IReadOnlyDictionary<String, MemoryStream> | references |
Returns
Type | Description |
---|---|
MetricsPlan |
Remarks
See AggregateValidator to run multiple validations.
Deserialize(Stream)
Create a MetricsPlan from the stream corresponding to a serialized one.
Declaration
public static MetricsPlan Deserialize(Stream serialized)
Parameters
Type | Name | Description |
---|---|---|
Stream | serialized |
Returns
Type | Description |
---|---|
MetricsPlan |
Load(String)
Construct a MetricsPlan and contents from a file containing a serialized plan.
Declaration
public static MetricsPlan Load(string path)
Parameters
Type | Name | Description |
---|---|---|
String | path |
Returns
Type | Description |
---|---|
MetricsPlan |
Save(String, FileMode)
Save this object to given path.
Declaration
public void Save(string path, FileMode mode = FileMode.OpenOrCreate)
Parameters
Type | Name | Description |
---|---|---|
String | path | |
FileMode | mode |
Serialize()
Serialize this object and everything it contains as a stream.
Declaration
public Stream Serialize()
Returns
Type | Description |
---|---|
Stream |
ToString()
Pretty-print this MetricsPlan.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |