Show / Hide Table of Contents

Class MetricsPlanExtensions

Extension methods for MetricsPlan.

Inheritance
Object
MetricsPlanExtensions
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Mangrove.MetricSetTransformers.Extensions
Assembly: MetricSetTransformers.dll
Syntax
public static class MetricsPlanExtensions

Methods

View Source

BaseTable(MetricsPlan)

Return the first base table for this metric plan

Declaration
public static Table BaseTable(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan

A MetricsPlan .

Returns
Type Description
Table

Base table.

Remarks

Here we understand this base table is the first table without aggregation.

View Source

BaseTables(MetricsPlan)

Returns all the tables before the first Aggregation tables.

Declaration
public static IEnumerable<Table> BaseTables(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan
Returns
Type Description
IEnumerable<Table>
Remarks

If the plan does not have any aggregation tables, then all the tables will be returned.

View Source

Clone(MetricsPlan, MetricSetMetadata, IMetricsPlanValidator)

Clone a MetricsPlan, only replacing its Metadata , and preserving everything else.

Declaration
public static MetricsPlan Clone(this MetricsPlan plan, MetricSetMetadata metadata, IMetricsPlanValidator validator)
Parameters
Type Name Description
MetricsPlan plan
MetricSetMetadata metadata
IMetricsPlanValidator validator
Returns
Type Description
MetricsPlan
View Source

Clone(MetricsPlan, IEnumerable<Expression>, IMetricsPlanValidator)

Clone a MetricsPlan, only replacing its collection of Expression nodes, and preserving everything else.

Declaration
public static MetricsPlan Clone(this MetricsPlan plan, IEnumerable<Expression> expressions, IMetricsPlanValidator validator)
Parameters
Type Name Description
MetricsPlan plan
IEnumerable<Expression> expressions
IMetricsPlanValidator validator
Returns
Type Description
MetricsPlan
View Source

Clone(MetricsPlan, IEnumerable<Expression>, IEnumerable<Table>, IMetricsPlanValidator)

Clone a MetricsPlan, only replacing its collections of Table and Expression nodes and preserving the Metadata and References.

Declaration
public static MetricsPlan Clone(this MetricsPlan plan, IEnumerable<Expression> expressions, IEnumerable<Table> tables, IMetricsPlanValidator validator)
Parameters
Type Name Description
MetricsPlan plan
IEnumerable<Expression> expressions
IEnumerable<Table> tables
IMetricsPlanValidator validator
Returns
Type Description
MetricsPlan
View Source

Clone(MetricsPlan, IReadOnlyDictionary<String, MemoryStream>, IMetricsPlanValidator)

Clone a MetricsPlan, only replacing its collection of "References"/> nodes, and preserving everything else.

Declaration
public static MetricsPlan Clone(this MetricsPlan plan, IReadOnlyDictionary<string, MemoryStream> references, IMetricsPlanValidator validator)
Parameters
Type Name Description
MetricsPlan plan
IReadOnlyDictionary<String, MemoryStream> references
IMetricsPlanValidator validator
Returns
Type Description
MetricsPlan
View Source

Clone(MetricsPlan, String)

Clone a MetricsPlan, only replacing its Version , and preserving everything else.

Declaration
public static MetricsPlan Clone(this MetricsPlan plan, string metricsetVersion)
Parameters
Type Name Description
MetricsPlan plan
String metricsetVersion
Returns
Type Description
MetricsPlan
View Source

ExperimentUnitTables(MetricsPlan)

Finds all experiment unit Table's.

Declaration
public static IEnumerable<Table> ExperimentUnitTables(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan
Returns
Type Description
IEnumerable<Table>
Remarks

NOTE: these are not the same as experiment unit level tables. Here we only keep tables at experiment unit level that also have descendants at the top aggregation level.

For example, consider the following tree structure:

source <- session <- user <- userOut <- sessionOut

User and sessionOut have the same number of aggregations between them and the source table, and so both are at the same "level", but only user table is ExperimentUnitTable because it has the aggreagtion userOut of maximum level as its descendant.

View Source

LeafExpressions(MetricsPlan)

Return all ColumnReference nodes from the MetricsPlan that are not parents, meaning no Expression references them.

Declaration
public static IEnumerable<Expression> LeafExpressions(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan
Returns
Type Description
IEnumerable<Expression>
View Source

LeafTables(MetricsPlan)

Return Tables that are not parents of other tables, meaning no Table references them.

Declaration
public static IEnumerable<Table> LeafTables(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan
Returns
Type Description
IEnumerable<Table>
View Source

Metrics(MetricsPlan)

A metric is a leaf ColumnReference on a leaf Table that does not depend on any Aggregands.

Declaration
public static IEnumerable<ColumnReference> Metrics(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan
Returns
Type Description
IEnumerable<ColumnReference>
Remarks

The restriction is needed to not consider segments as metrics.

View Source

Tables<T>(MetricsPlan)

All Table nodes in plan of type T.

Declaration
public static IReadOnlyList<T> Tables<T>(this MetricsPlan plan)
    where T : Table
Parameters
Type Name Description
MetricsPlan plan
Returns
Type Description
IReadOnlyList<T>
Type Parameters
Name Description
T
View Source

TablesAtExperimentUnitLevel(MetricsPlan)

Finds all Table's at the experiment unit level.

Declaration
public static IEnumerable<Table> TablesAtExperimentUnitLevel(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan
Returns
Type Description
IEnumerable<Table>
View Source

TableToExpressionMapping(MetricsPlan)

Produce a dictionary mapping a metric table to the collection of expressions which lie in that metric table.

Declaration
public static IReadOnlyDictionary<Table, ISet<Expression>> TableToExpressionMapping(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan

A MetricsPlan containing the Table nodes you care about.

Returns
Type Description
IReadOnlyDictionary<Table, ISet<Expression>>

Dictionary mapping table -> expressions in that table.

View Source

TopExperimentUnitTable(MetricsPlan)

Return the top Table (in the topological order) from experiment unit tables as defined by ExperimentUnitTables(MetricsPlan).

Declaration
public static Table TopExperimentUnitTable(this MetricsPlan plan)
Parameters
Type Name Description
MetricsPlan plan
Returns
Type Description
Table
View Source

TryFindTimestampColumn(MetricsPlan, out ColumnReference)

Declaration
public static bool TryFindTimestampColumn(this MetricsPlan plan, out ColumnReference timestampColumn)
Parameters
Type Name Description
MetricsPlan plan
ColumnReference timestampColumn
Returns
Type Description
Boolean
View Source

TryFindUnique<T>(MetricsPlan, out ColumnReference)

Declaration
public static bool TryFindUnique<T>(this MetricsPlan plan, out ColumnReference column)
    where T : class, IExpressionMetadata
Parameters
Type Name Description
MetricsPlan plan
ColumnReference column
Returns
Type Description
Boolean
Type Parameters
Name Description
T
View Source

TryFindVariantColumn(MetricsPlan, out ColumnReference)

This method will return true if there is exactly one ColumnReference with a VariantMetadata. That ColumnReference will be assigned to variantColumn. Otherwise it will return false.

Declaration
public static bool TryFindVariantColumn(this MetricsPlan plan, out ColumnReference variantColumn)
Parameters
Type Name Description
MetricsPlan plan
ColumnReference variantColumn
Returns
Type Description
Boolean
View Source

With(MetricsPlan, IMetricsPlanValidator, Func<Aggregation, Table>, Func<DataSource, Table>, Func<ExternTable, Table>, Func<Join, Table>, Func<TableReference, Table>, Func<Union, Table>, Func<Aggregand, Expression>, Func<BinaryAggregation, Expression>, Func<BinaryOperation, Expression>, Func<ColumnReference, Expression>, Func<DataSourceColumn, Expression>, Func<Extern, Expression>, Func<Filter, Expression>, Func<JoinKey, Expression>, Func<Literal, Expression>, Func<TernaryOperation, Expression>, Func<UnaryAggregation, Expression>, Func<UnaryOperation, Expression>, Func<UnionExpression, Expression>, Func<VectorOperation, Expression>, Func<UnaryWindowFunction, Expression>)

Transform a MetricsPlan using the provided set of operations on Table and then Expression nodes, in that order. Any operation not provided will be replaced with a no-op.

Declaration
public static MetricsPlan With(this MetricsPlan metricsPlan, IMetricsPlanValidator validator, Func<Aggregation, Table> aggregation = null, Func<DataSource, Table> dataSource = null, Func<ExternTable, Table> externTable = null, Func<Join, Table> join = null, Func<TableReference, Table> tableReference = null, Func<Union, Table> union = null, Func<Aggregand, Expression> aggregand = null, Func<BinaryAggregation, Expression> binaryAggregation = null, Func<BinaryOperation, Expression> binaryOperation = null, Func<ColumnReference, Expression> columnReference = null, Func<DataSourceColumn, Expression> dataSourceColumn = null, Func<Extern, Expression> extern = null, Func<Filter, Expression> filter = null, Func<JoinKey, Expression> joinKey = null, Func<Literal, Expression> literal = null, Func<TernaryOperation, Expression> ternaryOperation = null, Func<UnaryAggregation, Expression> unaryAggregation = null, Func<UnaryOperation, Expression> unaryOperation = null, Func<UnionExpression, Expression> unionExpression = null, Func<VectorOperation, Expression> vectorOperation = null, Func<UnaryWindowFunction, Expression> unaryWindowFunction = null)
Parameters
Type Name Description
MetricsPlan metricsPlan
IMetricsPlanValidator validator
Func<Aggregation, Table> aggregation
Func<DataSource, Table> dataSource
Func<ExternTable, Table> externTable
Func<Join, Table> join
Func<TableReference, Table> tableReference
Func<Union, Table> union
Func<Aggregand, Expression> aggregand
Func<BinaryAggregation, Expression> binaryAggregation
Func<BinaryOperation, Expression> binaryOperation
Func<ColumnReference, Expression> columnReference
Func<DataSourceColumn, Expression> dataSourceColumn
Func<Extern, Expression> extern
Func<Filter, Expression> filter
Func<JoinKey, Expression> joinKey
Func<Literal, Expression> literal
Func<TernaryOperation, Expression> ternaryOperation
Func<UnaryAggregation, Expression> unaryAggregation
Func<UnaryOperation, Expression> unaryOperation
Func<UnionExpression, Expression> unionExpression
Func<VectorOperation, Expression> vectorOperation
Func<UnaryWindowFunction, Expression> unaryWindowFunction
Returns
Type Description
MetricsPlan
View Source

WithAddedExpressions(MetricsPlan, IEnumerable<Expression>, IMetricsPlanValidator)

Clone a MetricsPlan, unioning its collection of Expression nodes with newExpressions, but keeping everything else the same.

Declaration
public static MetricsPlan WithAddedExpressions(this MetricsPlan metricsPlan, IEnumerable<Expression> newExpressions, IMetricsPlanValidator validator)
Parameters
Type Name Description
MetricsPlan metricsPlan
IEnumerable<Expression> newExpressions
IMetricsPlanValidator validator
Returns
Type Description
MetricsPlan
View Source

WithAddedResources(MetricsPlan, IDictionary<String, MemoryStream>, IMetricsPlanValidator)

Clone a MetricsPlan, unioning its collection of Expression nodes with newExpressions, but keeping everything else the same.

Declaration
public static MetricsPlan WithAddedResources(this MetricsPlan metricsPlan, IDictionary<string, MemoryStream> additionalResources, IMetricsPlanValidator validator)
Parameters
Type Name Description
MetricsPlan metricsPlan
IDictionary<String, MemoryStream> additionalResources
IMetricsPlanValidator validator
Returns
Type Description
MetricsPlan
View Source

WithAddedTablesAndExpressions(MetricsPlan, IEnumerable<Expression>, IEnumerable<Table>, IMetricsPlanValidator)

Clone a MetricsPlan, unioning its collection of Expression nodes with newExpressions, and its collection of Tables with newTables, but keeping everything else the same.

Declaration
public static MetricsPlan WithAddedTablesAndExpressions(this MetricsPlan metricsPlan, IEnumerable<Expression> newExpressions, IEnumerable<Table> newTables, IMetricsPlanValidator validator)
Parameters
Type Name Description
MetricsPlan metricsPlan
IEnumerable<Expression> newExpressions
IEnumerable<Table> newTables
IMetricsPlanValidator validator
Returns
Type Description
MetricsPlan
  • View Source
Back to top Generated by DocFX