Skip to content

Commit

Permalink
added more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Mar 28, 2023
1 parent cd5cad5 commit 340ac5c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Microsoft.Azure.Cosmos/src/Telemetry/Sampler/DataSampler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public static List<RequestInfo> OrderAndSample(List<RequestInfo> requestInfoList

foreach (RequestInfo requestInfo in requestInfoList)
{
// Get a unique key identifier for an object
int key = requestInfo.GetHashCodeForSampler();

// Check if similar object is already present
if (sampledRawData.TryGetValue(key, out List<KeyValuePair<double, RequestInfo>> sortedData))
{
// Add the new object to the list
DataSampler.AddToList(orderBy, requestInfo, sortedData);

sortedData.Sort(DataComparer.Instance);
Expand Down Expand Up @@ -67,18 +69,21 @@ List<KeyValuePair<double, RequestInfo>> newSortedData

private static void AddToList(DataSamplerOrderBy orderBy, RequestInfo requestInfo, List<KeyValuePair<double, RequestInfo>> sortedData)
{
double valueToStore;
if (orderBy == DataSamplerOrderBy.Latency)
{
sortedData.Add(new KeyValuePair<double, RequestInfo>(requestInfo.GetP99Latency(), requestInfo));
valueToStore = requestInfo.GetP99Latency();
}
else if (orderBy == DataSamplerOrderBy.SampleCount)
{
sortedData.Add(new KeyValuePair<double, RequestInfo>(requestInfo.GetSampleCount(), requestInfo));
valueToStore = requestInfo.GetSampleCount();
}
else
{
throw new Exception("order by not supported. Only Supported values are Latency, SampleCount");
}

sortedData.Add(new KeyValuePair<double, RequestInfo>(valueToStore, requestInfo));
}
}

Expand Down

0 comments on commit 340ac5c

Please sign in to comment.