Skip to content

Commit

Permalink
Merge pull request #49 from NeilMacMullen/larger-summarizations
Browse files Browse the repository at this point in the history
Allow summarize by to list up to 10 properties
  • Loading branch information
NeilMacMullen authored Jul 13, 2024
2 parents 916ebd3 + 489e632 commit 3675f09
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
67 changes: 57 additions & 10 deletions libraries/KustoLoco.Core/Evaluation/SummaryKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public record struct SummaryKey
private object? O2;
private object? O3;
private object? O4;
private object? O5;
private object? O6;
private object? O7;
private object? O8;
private object? O9;

public SummaryKey()
{
Expand All @@ -22,20 +27,57 @@ public SummaryKey(object?[] objects)
Set(i, objects[i]);
}
}

/// <summary>
/// Sets a value in the key
/// </summary>
/// <remarks>
/// Use with care. SummaryKey is a struct so
/// Set only works locally or in preparation for passing
/// the record to a method.
/// </remarks>
public void Set(int i, object? o)
{
if (i >= num)
num = i + 1;
if (i == 0) O0 = o;
if (i == 1) O1 = o;
if (i == 2) O2 = o;
if (i == 3) O3 = o;
if (i == 4) O4 = o;
if (i > 4)
throw new NotImplementedException("summarize limited to 5 vals");
switch (i)
{
case 0:
O0 = o;
break;
case 1:
O1 = o;
break;
case 2:
O2 = o;
break;
case 3:
O3 = o;
break;
case 4:
O4 = o;
break;
case 5:
O5 = o;
break;
case 6:
O6 = o;
break;
case 7:
O7 = o;
break;
case 8:
O8 = o;
break;
case 9:
O9 = o;
break;
case > 9:
throw new NotImplementedException("summarize operator is limited to 10 properties");
}
}

/// <summary>
/// Creates an array of the values in the key
/// </summary>
public object?[] GetArray()
{
var ret = new object?[num];
Expand All @@ -44,6 +86,11 @@ public void Set(int i, object? o)
if (num > 2) ret[2] = O2;
if (num > 3) ret[3] = O3;
if (num > 4) ret[4] = O4;
if (num > 5) ret[5] = O5;
if (num > 6) ret[6] = O6;
if (num > 7) ret[7] = O7;
if (num > 8) ret[8] = O8;
if (num > 9) ret[9] = O9;
return ret;
}
}
}

This file was deleted.

0 comments on commit 3675f09

Please sign in to comment.