Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Maya-Painter committed Aug 1, 2023
1 parent 0ebb267 commit f9af873
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public BackendMetrics(
/// </summary>
public TimeSpan VMExecutionTime { get; }

internal static BackendMetrics CreateFromIEnumerable(IEnumerable<BackendMetrics> backendMetricsEnumerable)
internal static BackendMetrics Create(IEnumerable<BackendMetrics> backendMetricsEnumerable)
{
BackendMetricsAccumulator accumulator = default;
foreach (BackendMetrics backendMetrics in backendMetricsEnumerable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,39 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics

internal class BackendMetricsAccumulator
{
private readonly List<BackendMetrics> backendMetricsList;

public BackendMetricsAccumulator()
{
this.BackendMetricsList = new List<BackendMetrics>();
this.backendMetricsList = new List<BackendMetrics>();
}

private readonly List<BackendMetrics> BackendMetricsList;

public void Accumulate(BackendMetrics backendMetrics)
{
if (backendMetrics == null)
{
throw new ArgumentNullException(nameof(backendMetrics));
}

this.BackendMetricsList.Add(backendMetrics);
this.backendMetricsList.Add(backendMetrics);
}

public BackendMetrics GetBackendMetrics()
{
TimeSpan totalTime = default;
long retrievedDocumentCount = default;
long retrievedDocumentSize = default;
long outputDocumentCount = default;
long outputDocumentSize = default;
double indexHitRatio = default;
TimeSpan totalTime = TimeSpan.Zero;
long retrievedDocumentCount = 0;
long retrievedDocumentSize = 0;
long outputDocumentCount = 0;
long outputDocumentSize = 0;
double indexHitRatio = 0;
QueryPreparationTimesAccumulator queryPreparationTimesAccumulator = new QueryPreparationTimesAccumulator();
TimeSpan indexLookupTime = default;
TimeSpan documentLoadTime = default;
TimeSpan indexLookupTime = TimeSpan.Zero;
TimeSpan documentLoadTime = TimeSpan.Zero;
RuntimeExecutionTimesAccumulator runtimeExecutionTimesAccumulator = new RuntimeExecutionTimesAccumulator();
TimeSpan documentWriteTime = default;
TimeSpan vMExecutionTime = default;
TimeSpan documentWriteTime = TimeSpan.Zero;
TimeSpan vMExecutionTime = TimeSpan.Zero;

foreach (BackendMetrics backendMetrics in this.BackendMetricsList)
foreach (BackendMetrics backendMetrics in this.backendMetricsList)
{
indexHitRatio = ((outputDocumentCount * indexHitRatio) + (backendMetrics.OutputDocumentCount * backendMetrics.IndexHitRatio)) / (retrievedDocumentCount + backendMetrics.RetrievedDocumentCount);
totalTime += backendMetrics.TotalTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,34 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics

internal class ClientSideMetricsAccumulator
{
private readonly List<ClientSideMetrics> clientSideMetricsList;

public ClientSideMetricsAccumulator()
{
this.ClientSideMetricsList = new List<ClientSideMetrics>();
this.clientSideMetricsList = new List<ClientSideMetrics>();
}

private readonly List<ClientSideMetrics> ClientSideMetricsList;

public void Accumulate(ClientSideMetrics clientSideMetrics)
{
if (clientSideMetrics == null)
{
throw new ArgumentNullException(nameof(clientSideMetrics));
}

this.ClientSideMetricsList.Add(clientSideMetrics);
this.clientSideMetricsList.Add(clientSideMetrics);
}

public ClientSideMetrics GetClientSideMetrics()
{
long retries = default;
double requestCharge = default;
IEnumerable<FetchExecutionRange> fetchExecutionRanges = default;
long retries = 0;
double requestCharge = 0;
List<FetchExecutionRange> fetchExecutionRanges = new List<FetchExecutionRange>();

foreach (ClientSideMetrics clientSideMetrics in this.ClientSideMetricsList)
foreach (ClientSideMetrics clientSideMetrics in this.clientSideMetricsList)
{
retries += clientSideMetrics.Retries;
requestCharge += clientSideMetrics.RequestCharge;
fetchExecutionRanges = (fetchExecutionRanges ?? Enumerable.Empty<FetchExecutionRange>()).Concat(clientSideMetrics.FetchExecutionRanges);
fetchExecutionRanges.AddRange(clientSideMetrics.FetchExecutionRanges);
}

return new ClientSideMetrics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,36 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics

internal class IndexUtilizationInfoAccumulator
{
private readonly List<IndexUtilizationInfo> indexUtilizationInfoList;

public IndexUtilizationInfoAccumulator()
{
this.IndexUtilizationInfoList = new List<IndexUtilizationInfo>();
this.indexUtilizationInfoList = new List<IndexUtilizationInfo>();
}

private readonly List<IndexUtilizationInfo> IndexUtilizationInfoList;

public void Accumulate(IndexUtilizationInfo indexUtilizationInfo)
{
if (indexUtilizationInfo == null)
{
throw new ArgumentNullException(nameof(indexUtilizationInfo));
}

this.IndexUtilizationInfoList.Add(indexUtilizationInfo);
this.indexUtilizationInfoList.Add(indexUtilizationInfo);
}

public IndexUtilizationInfo GetIndexUtilizationInfo()
{
IEnumerable<SingleIndexUtilizationEntity> utilizedSingleIndexes = default;
IEnumerable<SingleIndexUtilizationEntity> potentialSingleIndexes = default;
IEnumerable<CompositeIndexUtilizationEntity> utilizedCompositeIndexes = default;
IEnumerable<CompositeIndexUtilizationEntity> potentialCompositeIndexes = default;
List<SingleIndexUtilizationEntity> utilizedSingleIndexes = new List<SingleIndexUtilizationEntity>();
List<SingleIndexUtilizationEntity> potentialSingleIndexes = new List<SingleIndexUtilizationEntity>();
List<CompositeIndexUtilizationEntity> utilizedCompositeIndexes = new List<CompositeIndexUtilizationEntity>();
List<CompositeIndexUtilizationEntity> potentialCompositeIndexes = new List<CompositeIndexUtilizationEntity>();

foreach (IndexUtilizationInfo indexUtilizationInfo in this.IndexUtilizationInfoList)
foreach (IndexUtilizationInfo indexUtilizationInfo in this.indexUtilizationInfoList)
{
utilizedSingleIndexes = (utilizedSingleIndexes ?? Enumerable.Empty<SingleIndexUtilizationEntity>()).Concat(indexUtilizationInfo.UtilizedSingleIndexes);
potentialSingleIndexes = (potentialSingleIndexes ?? Enumerable.Empty<SingleIndexUtilizationEntity>()).Concat(indexUtilizationInfo.PotentialSingleIndexes);
utilizedCompositeIndexes = (utilizedCompositeIndexes ?? Enumerable.Empty<CompositeIndexUtilizationEntity>()).Concat(indexUtilizationInfo.UtilizedCompositeIndexes);
potentialCompositeIndexes = (potentialCompositeIndexes ?? Enumerable.Empty<CompositeIndexUtilizationEntity>()).Concat(indexUtilizationInfo.PotentialCompositeIndexes);

utilizedSingleIndexes.AddRange(indexUtilizationInfo.UtilizedSingleIndexes);
potentialSingleIndexes.AddRange(indexUtilizationInfo.PotentialSingleIndexes);
utilizedCompositeIndexes.AddRange(indexUtilizationInfo.UtilizedCompositeIndexes);
potentialCompositeIndexes.AddRange(indexUtilizationInfo.PotentialCompositeIndexes);
}

return new IndexUtilizationInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics

internal class QueryMetricsAccumulator
{
private readonly List<QueryMetrics> queryMetricsList;

public QueryMetricsAccumulator()
{
this.QueryMetricsList = new List<QueryMetrics>();
this.queryMetricsList = new List<QueryMetrics>();
}

private readonly List<QueryMetrics> QueryMetricsList;

public void Accumulate(QueryMetrics queryMetrics)
{
if (queryMetrics == null)
{
throw new ArgumentNullException(nameof(queryMetrics));
}

this.QueryMetricsList.Add(queryMetrics);
this.queryMetricsList.Add(queryMetrics);
}

public QueryMetrics GetQueryMetrics()
Expand All @@ -32,7 +32,7 @@ public QueryMetrics GetQueryMetrics()
IndexUtilizationInfoAccumulator indexUtilizationInfoAccumulator = new IndexUtilizationInfoAccumulator();
ClientSideMetricsAccumulator clientSideMetricsAccumulator = new ClientSideMetricsAccumulator();

foreach (QueryMetrics queryMetrics in this.QueryMetricsList)
foreach (QueryMetrics queryMetrics in this.queryMetricsList)
{
backendMetricsAccumulator.Accumulate(queryMetrics.BackendMetrics);
indexUtilizationInfoAccumulator.Accumulate(queryMetrics.IndexUtilizationInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics

internal class QueryPreparationTimesAccumulator
{
private readonly List<QueryPreparationTimes> queryPreparationTimesList;

public QueryPreparationTimesAccumulator()
{
this.QueryPreparationTimesList = new List<QueryPreparationTimes>();
this.queryPreparationTimesList = new List<QueryPreparationTimes>();
}

private readonly List<QueryPreparationTimes> QueryPreparationTimesList;

public void Accumulate(QueryPreparationTimes queryPreparationTimes)
{
if (queryPreparationTimes == null)
{
throw new ArgumentNullException(nameof(queryPreparationTimes));
}

this.QueryPreparationTimesList.Add(queryPreparationTimes);
this.queryPreparationTimesList.Add(queryPreparationTimes);
}

public QueryPreparationTimes GetQueryPreparationTimes()
{
TimeSpan queryCompilationTime;
TimeSpan logicalPlanBuildTime;
TimeSpan physicalPlanBuildTime;
TimeSpan queryOptimizationTime;
TimeSpan queryCompilationTime = TimeSpan.Zero;
TimeSpan logicalPlanBuildTime = TimeSpan.Zero;
TimeSpan physicalPlanBuildTime = TimeSpan.Zero;
TimeSpan queryOptimizationTime = TimeSpan.Zero;

foreach (QueryPreparationTimes queryPreparationTimes in this.QueryPreparationTimesList)
foreach (QueryPreparationTimes queryPreparationTimes in this.queryPreparationTimesList)
{
queryCompilationTime += queryPreparationTimes.QueryCompilationTime;
logicalPlanBuildTime += queryPreparationTimes.LogicalPlanBuildTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics

internal class RuntimeExecutionTimesAccumulator
{
private readonly List<RuntimeExecutionTimes> runtimeExecutionTimesList;

public RuntimeExecutionTimesAccumulator()
{
this.RuntimeExecutionTimesList = new List<RuntimeExecutionTimes>();
this.runtimeExecutionTimesList = new List<RuntimeExecutionTimes>();
}

private readonly List<RuntimeExecutionTimes> RuntimeExecutionTimesList;

public void Accumulate(RuntimeExecutionTimes runtimeExecutionTimes)
{
if (runtimeExecutionTimes == null)
{
throw new ArgumentNullException(nameof(runtimeExecutionTimes));
}

this.RuntimeExecutionTimesList.Add(runtimeExecutionTimes);
this.runtimeExecutionTimesList.Add(runtimeExecutionTimes);
}

public RuntimeExecutionTimes GetRuntimeExecutionTimes()
{
TimeSpan queryEngineExecutionTime = default;
TimeSpan systemFunctionExecutionTime = default;
TimeSpan userDefinedFunctionExecutionTime = default;
TimeSpan queryEngineExecutionTime = TimeSpan.Zero;
TimeSpan systemFunctionExecutionTime = TimeSpan.Zero;
TimeSpan userDefinedFunctionExecutionTime = TimeSpan.Zero;

foreach (RuntimeExecutionTimes runtimeExecutionTimes in this.RuntimeExecutionTimesList)
foreach (RuntimeExecutionTimes runtimeExecutionTimes in this.runtimeExecutionTimesList)
{
queryEngineExecutionTime += runtimeExecutionTimes.QueryEngineExecutionTime;
systemFunctionExecutionTime += runtimeExecutionTimes.SystemFunctionExecutionTime;
Expand Down

0 comments on commit f9af873

Please sign in to comment.